lunapaint / vscode-luna-paint

A raster image editor extension for VS Code
https://marketplace.visualstudio.com/items?itemName=Tyriar.luna-paint
282 stars 27 forks source link

If retainContextWhenHidden is false, history may not be restored and become corrupted #24

Open Tyriar opened 3 years ago

Tyriar commented 3 years ago

Repro:

  1. Set "luna.retainContextWhenHidden": false
  2. Restart VS Code
  3. Open a large image (eg. 1000x1000)
  4. Make a change
  5. Change tabs
  6. Change back
  7. Try undo

This problem gets worse because if undoing before the change tabs as the entire redo stack disappears as well. It happens because Luna Paint rejects the backup promise when the image size is over a certain threshold (defined by luna.hotExitMaxPixels) since it can cause the canvas to become unresponsive while drawing. The history stack is included in the hot exit backup since chances are decent that it's larger than the image payload itself.

https://github.com/microsoft/vscode/issues/113507 is needed from VS Code in order to properly backup backgrounded tabs and have the extension explicitly dispose of the context itself.

Tyriar commented 2 years ago

Changing to an enhancement since luna.retainContextWhenHidden is more of a developer option. I've added a note to the setting that this could happen with hot exit in the meantime.

Tyriar commented 2 years ago

The corruption isn't as bad as it used to be but can still happen as the history stacks get out of sync, for example:

  1. Set "luna.retainContextWhenHidden": false
  2. Restart VS Code
  3. Open a large image (eg. 1000x1000)
  4. Make a change
  5. Change tabs
  6. Change back
  7. Make a change
  8. Undo (undos the change change in 8)
  9. Undo, does nothing 🐛
  10. Redo, applies the change in 8 🐛
  11. Redo, does nothing 🐛