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

Switch to persistent storage to avoid data loss #9362

Closed
jryans opened this issue Apr 2, 2019 · 11 comments · Fixed by matrix-org/matrix-react-sdk#4092
Closed

Switch to persistent storage to avoid data loss #9362

jryans opened this issue Apr 2, 2019 · 11 comments · Fixed by matrix-org/matrix-react-sdk#4092
Assignees
Labels
A-E2EE-Cross-Signing A-Storage Storage layer of the app, including IndexedDB, local storage, etc. T-Enhancement

Comments

@jryans
Copy link
Collaborator

jryans commented Apr 2, 2019

We can request "persistent storage" from the browser (navigator.storage.persist) so that it won't remove data when space is low.

Browsers decide whether to approve / deny differently:

  • Chrome: Approved only if your site is deemed "important" to the user (visited frequently, bookmarked, etc.)
  • Firefox: Shows a browser permission prompt for the user to decide

Since at least one browser prompts the user, we would we need to consider when is the right time to request this and present the right messaging around it.

@jryans jryans added feature X-Needs-Design A-Storage Storage layer of the app, including IndexedDB, local storage, etc. labels Apr 2, 2019
@jryans jryans mentioned this issue Apr 2, 2019
5 tasks
@jryans jryans changed the title Consider switching to persistent storage to data loss Consider switching to persistent storage to avoid data loss Apr 2, 2019
@bwindels
Copy link
Contributor

Fwiw, the prompt looks like this (triggered from the console here):

image

@jryans
Copy link
Collaborator Author

jryans commented Feb 19, 2020

We really, really should sort out the UX and try to do this... Every time I see a rageshake from someone's IDB being trashed, I feel the anger from the other side of the tubes, and it feels to the user like Riot has failed them. 😭

@jryans
Copy link
Collaborator Author

jryans commented Feb 19, 2020

@nadonomy, can you think of a good moment in the app lifetime that would make sense to request persistent stoarge (knowing that some browsers will show the user a permission prompt)? This should help massively with storage issues on web.

Here are some possible ideas:

  • Add a button in Settings to request manually (not discoverable, only helps users who happen to press it)
  • After N days of use, show toast / nag bar / something in app which would request persistent storage from the browser on user approval (so that the possible browser prompt is in context of user action)

@bwindels
Copy link
Contributor

Another suggestion:

  • show a dialog "We need to store your keys reliably" or something when joining the first encrypted room.

@nadonomy
Copy link
Contributor

@nadonomy, can you think of a good moment in the app lifetime that would make sense to request persistent stoarge (knowing that some browsers will show the user a permission prompt)? This should help massively with storage issues on web.

I think this really comes down to understanding the browsers intentions better. From the issue, can you clarify Chromes behaviour?

If Chrome only approves "important" sites, can we be deterministic about whether we're important? If we're important does using persistent storage require any user interaction? If we're not, can we still request?

Do we know how Safari behaves?

@bwindels
Copy link
Contributor

Do we know how Safari behaves?

Safari doesn't support persistent storage yet.

@bwindels
Copy link
Contributor

bwindels commented Feb 19, 2020

If Chrome only approves "important" sites, can we be deterministic about whether we're important? If we're important does using persistent storage require any user interaction? If we're not, can we still request?

Not sure what their heuristic is, but in any case, Chrome never prompts (only FF does), and instead silently run their heuristic to grant or deny your request for persistent storage. I think it mainly comes down to how much you've used a certain website, with it perhaps becoming a bit more picky if you are short on disk space. If the request is denied though, we're off no worse than we are today.

@jryans
Copy link
Collaborator Author

jryans commented Feb 19, 2020

If Chrome only approves "important" sites, can we be deterministic about whether we're important?

I believe this 2016 annoucement is the most detailed version I've seen, but it's possible it's changed since:

Beginning with Chrome 55, Chrome will automatically grant the persistence permission if any of the following are true:

  • The site is bookmarked (and the user has 5 or less bookmarks)
  • The site has high site engagement
  • The site has been added to home screen
  • The site has push notifications enabled

The permission is automatically denied in all other cases.

If we're important does using persistent storage require any user interaction? If we're not, can we still request?

No, for Chrome at least, requesting persistent storage is always silent and we can keep requesting whenever we like.

@jryans
Copy link
Collaborator Author

jryans commented Feb 19, 2020

@ara4n has suggested we could just always request on app load. That's certainly technically easy, but it would mean an immediate permission on load for at least Firefox users, which may push some people away.

We could wait until after you've logged in, which is similarly easy and bit less scary...?

@nadonomy
Copy link
Contributor

Given how different browsers have wildly different interaction models to present to users, I'm kind of inclined to agree that this is the browsers lifting for the most part, rather than ours.

We could wait until after you've logged in, which is similarly easy and bit less scary...?

This seems reasonable.

@jryans jryans changed the title Consider switching to persistent storage to avoid data loss Switch to persistent storage to avoid data loss Feb 19, 2020
@jryans
Copy link
Collaborator Author

jryans commented Feb 19, 2020

I have added this to the current phase for E2EE by default, as this issue only becomes more urgent once we have default encrypted rooms.

@jryans jryans removed the feature label Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-E2EE-Cross-Signing A-Storage Storage layer of the app, including IndexedDB, local storage, etc. T-Enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants