Clicking to place an object while the game is autosaving causes the click to be delayed until the autosave is complete but uses the mouse position and keyboard modifiers (e.g. shift) when the autosave ends.
For example, if I try to place a ghost wall (shift-click) while autosaving (because I was placing lots of walls and the autosave suddenly started) and then release shift while waiting for the autosave to finish an actual wall will get placed wherever the mouse happens to be when the save finishes. I would expect either no action (the click is ignored because the game was paused) or all aspects of the action as input (i.e. a ghost wall placed at the location of the mouse when the click occurred) to happen.
To reproduce:
1. Load any map large enough to have a non-trivial autosave time.
2. Select a wall object and hold shift to trigger ghost placement mode.
3. Wait until an autosave occurs.
3a. Click the mouse near the player.
3b. Release the shift button.
3c. Move the mouse to a new location within build range of the player.
4. Wait until the autosave completes.
5. Observe wall built at the final location of the mouse instead of ghost wall at original location or no wall.
This behavior has been around for a long time (and is pretty minor) but it finally annoyed me enough to make a report. It's pretty annoying when you have to stop building and undo stuff because the autosave caused things to get misplaced.
[0.18.3] Clicking during autosaving causes strange behavior
[0.18.3] Clicking during autosaving causes strange behavior
- Attachments
-
- 2020-02-01-1512-32.webm
- (2.56 MiB) Downloaded 76 times
-
- factorio-current.log
- (5.57 KiB) Downloaded 81 times
Re: [0.18.3] Clicking during autosaving causes strange behavior
Thanks for the report. I'm not sure if this is worth the refactoring it will involve to fix or if it's "ok" as is.
If you want to get ahold of me I'm almost always on Discord.
-
- Burner Inserter
- Posts: 5
- Joined: Wed Feb 19, 2020 7:52 pm
- Contact:
Re: [0.18.3] Clicking during autosaving causes strange behavior
It is not just placing items, but it is also inventory transfers, copying items (as in with the Copy tool) and probably other things too. It seems it is a race condition that leaves a window open for a click event during the beginning of the save when it should be blocked. It is much much worse if you have any kind of mod that does any operations for example Noxys Trees which iterates over all the chunks during save.
If you are transferring items to a chest from your inventory while this happens, it can accidentally transfer all your inventory/as much as can fit in the chest, which then might spill a bunch of random junk onto a belt, clog up your factory, and leave you with several minutes of cleanup to do.
Here's an easy way to reproduce. It might make sense to have the autosave interval very short.
1. Install the Noxy's Trees mod (makes it easier to reproduce but it 100% happens without this mod)
2. Have a lot of chunks discovered, have trees enabled in map gen settings
3. Open /editor (it happens when playing too, but again, easier to hit)
4. Have a whole bunch of stuff in your inventory.
5. Put an empty chest with a stack inserter emptying it, onto a belt, then picked up by another stack inserter into another chest
6. Open the chest so you can see the stacks
7. Start transferring items by clicking them in the Editor inventory
8. Keep clicking stacks until the Autosave starts
If you are clicking to transfer a stack to the chest when the Autosave starts, it will transfer that stack plus about everything else in your inventory in my experience.
I hope this info helps if you decide to investigate fixing it - which I hope you do. It's really frustrating when you accidentally transfer all your inventory because the "stupid autosave" happened exactly when you clicked something. Wherever Noxy's Trees is inserting itself into the save process makes the bug much easier to hit, this may provide some clues I hope.
If you are transferring items to a chest from your inventory while this happens, it can accidentally transfer all your inventory/as much as can fit in the chest, which then might spill a bunch of random junk onto a belt, clog up your factory, and leave you with several minutes of cleanup to do.
Here's an easy way to reproduce. It might make sense to have the autosave interval very short.
1. Install the Noxy's Trees mod (makes it easier to reproduce but it 100% happens without this mod)
2. Have a lot of chunks discovered, have trees enabled in map gen settings
3. Open /editor (it happens when playing too, but again, easier to hit)
4. Have a whole bunch of stuff in your inventory.
5. Put an empty chest with a stack inserter emptying it, onto a belt, then picked up by another stack inserter into another chest
6. Open the chest so you can see the stacks
7. Start transferring items by clicking them in the Editor inventory
8. Keep clicking stacks until the Autosave starts
If you are clicking to transfer a stack to the chest when the Autosave starts, it will transfer that stack plus about everything else in your inventory in my experience.
I hope this info helps if you decide to investigate fixing it - which I hope you do. It's really frustrating when you accidentally transfer all your inventory because the "stupid autosave" happened exactly when you clicked something. Wherever Noxy's Trees is inserting itself into the save process makes the bug much easier to hit, this may provide some clues I hope.