-
-
Notifications
You must be signed in to change notification settings - Fork 585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can lose image when out of memory, including auto-save if you interact #24
Comments
Could check |
Data loss confirmed in the wild: https://youtu.be/GTOntYcgIqM?t=80 |
I don't think this happens all the time, but here all canvases gone transparent (including tool options and the color wells (which use canvases so that dark mode browser extensions don't change the colors)): If it always happened with all canvases at once, we could run detection of datalessness on a color well, or even have a specific 1x1 sentinel canvas to detect this, but sadly I don't think that's the case. |
Oh, another possibility for mitigating this might be to store undos not as canvases, but as imagedata arrays - hopefully then the browser won't be so callus with erasing it! Also we could save multiple autosaves! Once every N edits, up to some number of saves per session. And as for detecting data loss on the canvas, it would be simple if jspaint was architected to always update state discretely for undoable operations - if it used a pattern of Anyways, I think improving autosave is the most important, giving it multiple save points per session and making it more accessible/discoverable by popping up with a recovery dialog instead of just having it tucked away in a menu (File > Manage Storage). |
btw I have switched over to ImageData, which led to implementing a helper layer for tools so I could refactor them so they didn't use horrible hacks of accessing the undo stack (which was canvases and is now imagedata), and that led to implementing The Grid... which was a much more exciting feature so I didn't remember to put an update here, but... so it should now crash the tab fully instead, or if the browser just clears the main canvas, you should still be able to undo (theoretically) Multiple autosave is still needed, and/or at least addressing the browser-clears-the-canvas thing directly by detecting when it goes transparent. I think it would be better to have a dialog that's kind of annoying/weird if you clear the canvas to transparent on purpose than leaving surprised users to fend for themselves in trying to recover their work. Something like "Woah, did you do that? [Yes, I want a blank canvas] [Restore my work]" |
Alright, tested this and found that editing very large images it does tend to crash the page instead, which is good! (I'm guessing with a smaller image over a longer period of time it would likely still lose the canvases, because it wouldn't be trying to allocate as much memory at once.) Also, I found a way to consistently & easily cause chrome to clear all the canvases: make a selection and press numpad plus repeatively to enlarge the selection exponentially.(If you keep pressing it while it's lagging or otherwise do it too many times you can still get it to crash the tab, or freeze up your entire browser, so you have to be a little careful. |
When chrome runs out of memory, canvases get erased, and when you see your image is gone you'll probably naturally try to undo (speaking from experience), but that actually then destroys the last memory of the image, because it saves over the autosave with more nothingness.
So: we should detect if the canvas suspiciously becomes blank. Maybe also the undo history canvases (just the one, when undoing/redoing, I guess should work).
I wonder if there's a good way to simulate out of memory conditions, rather than just loading web apps with terribly expensive memory usage.
The text was updated successfully, but these errors were encountered: