Bug 181849 - "Add to homescreen" apps don't share storage with Safari
Summary: "Add to homescreen" apps don't share storage with Safari
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: Safari 11
Hardware: iPhone / iPad iOS 11
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-01-19 06:01 PST by Ashley Gullen
Modified: 2022-06-14 16:42 PDT (History)
11 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ashley Gullen 2018-01-19 06:01:37 PST
Web apps run from the home screen don't share storage with Safari. Demo:

1) Visit https://www.scirra.com/labs/bugs/iosstorage/
2) Enter the number 123 and press "Save"
3) Add the page to home screen
4) Close Safari and open the home screen app
5) Press "Load"

Expected result: text should change to "Loaded: 123"
Observed result: text changed to "Loaded: null"

6) In the home screen app, enter the number 456 and press "Save"
7) Close the home screen app and open Safari again to the same page
8) In Safari, press "Load"

Expected result: text should change to "Loaded: 456"
Observed result: text changed to "Loaded: 123"

Our PWA (editor.construct.net) can save entire user projects in to IndexedDB. Users who use the web app risk losing their work due to this bug. It's also inconvenient since details like saved logins are not remembered between the two.
Comment 1 Thomas Steiner 2018-02-27 07:27:30 PST
Right now the only working hack (that I am aware of) to get session data over from Safari to Web.app is by using `window.location.query` :-/, documented here: https://stackoverflow.com/questions/21109615/ios7-safari-saving-to-home-screen-and-persist-token/21292179#21292179.
Comment 2 Radar WebKit Bug Importer 2018-03-20 09:11:26 PDT
<rdar://problem/38665631>
Comment 3 Brent Fulgham 2022-02-01 15:33:01 PST
The current behavior (on Apple platforms) is by design. Home Screen apps are created as isolated entities without shared state with the browser.
Comment 4 Ashley Gullen 2022-02-02 04:09:01 PST
I would be surprised if this is really by design, since from the perspective of the user, it looks like a serious data loss issue. In practice users will go through a process like this:

1) Use a web app in Safari, and produce some work in it, which the web app saves to storage for them.
2) Decide they like the web app, so use "Add to homescreen" to access it more conveniently.
3) Load up the homescreen app, but all their work is missing! They will probably panic and contact support asking why did your app delete all their work?
4) Web app developer has to patiently explain that it's iOS that seemingly deleted all their work, and explain how they can go back to the Safari browser to find their work again. At this point they either have to delete the homescreen app and just stick to Safari, or try to figure out how to transfer their work from Safari across to the homescreen app.

Given this is a potentially serious data loss issue, the design should be changed - especially since this design could be viewed as an intentional way to hobble web apps and increase pressure to publish to the App Store.