Repository navigation
Home Screen app on iOS doesn't show changes made while it was in the background #3142
Unanswered
vitalibondar
asked this question in
Ideas and Issue Triage
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
On iPhone, with Fizzy added to the Home Screen, a card doesn't pick up changes made elsewhere once the app has been in the background. You switch away, someone moves the card or leaves a comment, you switch back, and the page still shows the old state. It stays that way until you pull to refresh or navigate away and back. On desktop the same change shows up live within a couple of seconds, so the server side and the cable connection look fine.
Steps
What I think is going on
Two things, both tied to coming back from the background.
iOS presumably suspends the page and drops the WebSocket, so the Turbo stream broadcasts sent while it was away never arrive, and nothing fetches them after the page resumes.
And the service worker (
/service-worker.js) serves documentsnetworkFirstwithnetworkTimeout: 3. Right after an iPhone wakes up the network is often slow for a few seconds, so a navigation in that window can get the cached copy instead of the current page. I haven't measured how often that part actually bites. But it would explain why a plain navigation right after resuming sometimes still shows stale content.What we're running
We self-host Fizzy and patched it locally by appending this to
application.js. After it went in, the same steps above show the new comment on return without any manual refresh (checked on an iPhone today).With
turbo-refresh-method=morphandturbo-refresh-scroll=preservealready on the page, the reload is barely noticeable and scroll position stays put. The 5 second threshold is arbitrary, it's just there so quick app switches don't trigger a fetch.This probably isn't the shape you'd want upstream (a Stimulus controller, or reconnecting the cable and letting streams catch up, might fit better). If it's useful I'm happy to open a PR along whichever lines you prefer.
All reactions