Skip to content
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

The Recover Document (Woah!) pop-up still occurs despite the following #325

Open
MesaBlack opened this issue Aug 17, 2023 · 6 comments
Open

Comments

@MesaBlack
Copy link

It stilll happens, even if my storage is mostly empty as well as after undoing to recover.
It happens while I select a portion of a graphic.

@MesaBlack MesaBlack changed the title The Recover Document (Woah!) pop-up still occurs The Recover Document (Woah!) pop-up still occurs despite the following Aug 17, 2023
@1j01
Copy link
Owner

1j01 commented Aug 17, 2023

This is a very annoying pop-up, and I want to obliterate it.

This dialog has nothing to do with storage quota. It's concerned with RAM, not disk space.
It shows any time the canvas (ignoring the selection) becomes entirely transparent, because this is the only symptom that occurs when the browser decides to rudely toss out the canvas data when low on memory. This usually occurs after you've spent a lot of time and effort on a document, creating many undo states (each taking up memory), so it's important to preserve the document in the case that this happens.

The dialog is very much a kludge, and it has very stupid false positives, like if you hit Select All in a transparent document. Handling that one case would be fairly easy, but there are more complicated scenarios, like if you select all the opaque pixels manually with the Select or Free-Form Select tool. Simply preventing the dialog from showing during a tool action would leave it open to false negatives if the browser clears the canvas forcibly while making a selection.

For more background info, see #24
It's very possible there's something simple that I haven't thought of, to remove the need for this dialog.

@1j01
Copy link
Owner

1j01 commented Mar 9, 2024

I tried to make this dialog a little clearer and more compact in a0abbb3. I still want to get rid of it though.

Before:

old

After:

newer

Before (Expanded):

old expanded

After (Expanded):

newer expanded

@1j01
Copy link
Owner

1j01 commented Dec 30, 2024

Chrome supposedly added new events for canvas context loss/restoration that apply to non-WebGL contexts: contextlost and contextrestored.

That wiki page mentions another feature:

A new context creation parameter named 'storage' is to be added. Possible values are 'persistent' and 'discardable'. Usage: canvas.getContext('2d', {storage: 'discardable'});

This also sounds like the most useful, if I can just tell it to be persistent. However...

The default is 'persistent', which provides backwards compatible behavior for application that expect canvas backing store content to never be lost.

So I don't know if these things will actually help in practice, but in theory they seem intended to help with this scenario.

@MesaBlack
Copy link
Author

MesaBlack commented Dec 30, 2024

so maybe that's why the thing kept appearing?

@1j01
Copy link
Owner

1j01 commented Dec 31, 2024

@MesaBlack I'm not sure I understand the question, but, I was noting some possible avenues to eliminating the need for the dialog, not causes of the issue.
I'm not working on this right now, but I came across some mention of these events and I wanted to remember them in the future if I go to work on this, since they would be useful to explore. The events could help by directly detecting the scenario where the browser clears the canvas to save on memory usage.

(Further note to self: probably need to feature-detect these events before relying on them.)

@MesaBlack
Copy link
Author

I elaborated a bit

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

No branches or pull requests

2 participants