Skip to content

Added save file manager to prevent autosave locking - #651

Closed
Micheus wants to merge 1 commit into
dgud:masterfrom
Micheus:mv/autosave-refactoring
Closed

Micheus wants to merge 1 commit into
dgud:masterfrom
Micheus:mv/autosave-refactoring

Conversation

@Micheus

@Micheus Micheus commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

This commit introduces a save file manager to avoid the lag/lock caused by
autosave when working on projects with a high polycount. The issue was
discussed on Discord, where users noted that autosave could freeze the
application because file saving runs in the same main process.

With modern memory availability, Wings3D can handle the data demands of
high‑poly projects relatively well. However, autosave becomes inconvenient
due to the blocking behavior of the current saving mechanism. The new save
file manager separates this process, preventing locks and making saving and
autosaving smoother.

I also took in account a comment present in the wings_file:autosave/1:

%% Maybe this should be spawned to another process
%% to let the autosaving be done in the background.
%% But I don't want to copy a really big model either.

NOTE: Thanks to @rv3 and @unity for suggest this kind of stuff at Discord.

This commit introduces a save file manager to avoid the lag/lock caused by
autosave when working on projects with a high polycount. The issue was
discussed on Discord, where users noted that autosave could freeze the
application because file saving runs in the same main process.

With modern memory availability, Wings3D can handle the data demands of
high‑poly projects relatively well. However, autosave becomes inconvenient
due to the blocking behavior of the current saving mechanism. The new save
file manager separates this process, preventing locks and making saving and
autosaving smoother.

I also took in acount a comment present in the wings_file:autosave/1:
%% Maybe this should be spawned to another process
%% to let the autosaving be done in the background.
%% But I don't want to copy a really big model either.
@Micheus
Micheus force-pushed the mv/autosave-refactoring branch from be1aa65 to cf1fed7 Compare September 9, 2026 12:26
@Micheus

Micheus commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

I used GPT to help me code the server since I hadn’t worked on something like this before.

To evaluate the performance gain, I used my Wheel project, which has 573K polygons. I ran tests disabling compression and also tried different compression levels. Currently, Wings3D uses a compress option without a level parameter, so I don’t know which level it defaults to (0 = disabled, 1..9). The documentation doesn’t specify this either.
* The data bellow was computed from a average of 6-9 measurements.

1. Lock Duration Comparison

Selection Current Implementation — Lock New Implementation — Lock Lock Reduction
Nothing 10.185 s 2.160 s 78.8%
Some 10.240 s 2.160 s 78.9%
All 10.516 s 2.160 s 79.5%

2. Total Time by Compression Level

Compression Level Some Nothing All
Default (?) 12.497 s 12.640 s 12.757 s
No Compression (0) 12.405 s 10.066 s 9.926 s
Level 1 8.555 s 8.171 s 8.100 s
Level 2 15.887 s 10.839 s 15.559 s
Level 9 32.610 s 31.812 s 31.354 s

3. Overall Recording Time Comparison

Selection Current Implementation New Implementation — Level 1 Total Time Reduction
Nothing 10.185 s 8.171 s 19.8%
Some 10.240 s 8.555 s 16.5%
All 10.516 s 8.100 s 23.0%

4. Performance Summary

Selection Current Total Time New Total Time (Level 1) Compression / Lock Time Overall Time Reduction Lock Time Reduction
Nothing 10.185 s 8.171 s 2.160 s 19.8% 78.8%
Some 10.240 s 8.555 s 2.160 s 16.5% 78.9%
All 10.516 s 8.100 s 2.160 s 23.0% 79.5%

@Micheus

Micheus commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

@dgud , I hope you cold evaluate this new implementation and suggest/fix anything I may be wrong since it's a new land for me. It's working as far as I have tested the possible conditions without a hard crash.

‎src/wings_save_manager.erl - The new server module;
‎src/wings.erl - command(saved,_) was adjusted to handle the code before made by wings_file. In this case, add file name to the recent list because of the server doesn't access about the wx module;
‎src/wings_ff_wings.erl - The only change was to export/1. Unfortunately the other lines changes are related to extra spaces which VSCode already promote a clean-up;
‎src/wings_file.erl - add_recent/1 was exported because the server cannot access the wx module. The save_now, save_selected and autosave were adjusted to use the server;
‎src/wings_pref.erl - this fix was necessary because during autosave tests I found it could crash with an invalid path. It was using the preferences sub-set path which my was pointing to an old drive no longer present. The change ensure the path is valid;
‎src/wings_view.erl - the change was made to ensure any non window module can send the events to the main module wings.

@dgud

dgud commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Ok I have reworked this and merged a variant I liked, thanks for the basic work.

@dgud dgud closed this Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants