RESOLVED CONFIGURATION CHANGED Bug 211018
iOS PWAs using Service Workers freeze after being backgrounded
https://bugs.webkit.org/show_bug.cgi?id=211018
Summary iOS PWAs using Service Workers freeze after being backgrounded
Jamie Nguyen
Reported 2020-04-25 03:03:37 PDT
Created attachment 397555 [details] Test case (Airhorn + UpUp) Steps to reproduce: 1. Open iOS Safari. 2. Navigate to https://airhorner.com/ 3. Click Share, then Save to Home Screen. 4. Click App Icon from Home Screen. 5. Click the horn, it works. 6. Background the App (ie, go back to Home Screen). 7. Wait 5 seconds. 8. Click App Icon from Home Screen. 9. Click the horn, it doesn't work. App seems frozen. I found this to be reproducible with every PWA I tested. To rule out a problem with Workbox, I created an Airhorn test case with Workbox swapped out for an alternative PWA library called UpUp. I've attached this test case, but it's also available here: Website: https://jamielinux.github.io/ios-service-worker-bug/ Source: https://github.com/jamielinux/ios-service-worker-bug Hardware/software details: - iPhone XS Max - iOS 13.4.1
Attachments
Test case (Airhorn + UpUp) (2.10 MB, application/gzip)
2020-04-25 03:03 PDT, Jamie Nguyen
no flags
Radar WebKit Bug Importer
Comment 1 2020-04-25 17:27:25 PDT
youenn fablet
Comment 2 2020-04-27 06:50:29 PDT
I could not repro on a recent WebKit build.
youenn fablet
Comment 3 2020-04-27 06:55:24 PDT
I would guess the WebProcess running the service worker stays suspended. From my testing, the service worker runs in the WebProcess of the page which gets resumed. If you attach your iOS device to a Mac, you can try debugging with Safari web inspector. You should see entries like: Develop -> Phone: Web airhorner.com (for the page or service worker) Web airhorner.com (for the service worker or the page)
Daniel Sweet
Comment 4 2020-04-27 09:24:30 PDT
I _can_ reproduce this, separately. iOS 13.4.1, iPhone 11 Pro. See the following repo for an extremely minimal reproduction: https://github.com/quicktype/ios-pwa-freeze-bug In particular, this never happens in Mobile Safari. This only happens on PWAs added directly to the home screen. This is a complete freeze of all JavaScript execution contexts when visibility states are changed. Simply put, the PWA container sometimes forgets to resume all JavaScript execution contexts. If you disable Service Workers, there are no problems. This might also surface with Web Workers, but I haven't tested them. This is _not_ an infinite loop in either the page JS context or the Service Worker JS context. I suspect it's a race condition involving suspending multiple JS execution contexts when the visibility state changes.
Daniel Sweet
Comment 5 2020-05-12 19:09:43 PDT
As of 2020-05-12, I can reproduce this on iOS 13.4.1 without even involving any Service Worker. This is a more severe bug than it looks, and our end users are currently frequently hitting it. I can't share the specific web app that triggers the behavior without Service Workers involved publicly, but can share privately with Apple Employees upon request.
youenn fablet
Comment 6 2020-05-13 06:25:35 PDT
A sysdiagnose (that can be shared privately) might be useful.
youenn fablet
Comment 7 2020-05-18 01:01:26 PDT
Chris pointed out this might be related/fixed with https://trac.webkit.org/changeset/261034
Daniel Sweet
Comment 8 2020-05-26 10:11:02 PDT
Did https://trac.webkit.org/changeset/261034 make it into iOS 13.5? I have not been able to reproduce the freezing problem as of iOS 13.5 with https://github.com/quicktype/ios-pwa-freeze-bug, so it is possible that this has been fixed.
Fithive Dev
Comment 9 2020-05-26 16:42:36 PDT
We are experiencing this bug with our pwa service worker. The pwa is installed/added to home screen and it doesn't happen every time. However it does happen intermittently and we have enough users of the app that we have started getting many reports of this happening on ios 13. We are considering detecting ios and disabling service workers all together - as our app is mostly only useful when connected online.
verypublicyeah913j
Comment 10 2020-07-24 20:18:30 PDT
This is happening consistently with all web apps I've added to the home screen on iOS 13.6. 1. Add https://airhorner.com/ to the home screen. 2. Open it. 3. Go to the home screen. 4. Wait 20 seconds. 5. Open it. 6. It's frozen. Users are really annoyed.
Ingolf Wunder
Comment 11 2020-08-06 11:26:09 PDT
Yeh, it was fixed in 13.5 for us, but it appeard in 13.6 again ... Please Apple fix it asap!!!!!!
Sanjay Kumar
Comment 12 2020-08-06 11:59:24 PDT
I can confirm that this is not fixed. Backgrounding a PWA will very often cause a freeze upon re-launch. It happens in iOS 14 beta 2 for my app (fly.avnav.com) and every other known PWA that I have tested (twitter lite etc.). One thing I noticed is that if App freezes on a page with scrolling then it still shows some sign of life with a bouncing effect - meaning its responding to at least one input. But rest of the UI is frozen/inactive - no response to any input. Web App seems to just hang. I thought this was due to an infinite loop in my WebAssembly code but that's not the case. I tried removing Service Worker to see if problem would go away but can not say conclusively that it did - I think i have seen it freeze even without Service Worker. But I can go back and test. This is very serious problem since you have to kill processes frequently to use a PWA - making almost all major PWAs un-usable. Please fix - for iOS 14 at least ! Thank you !!
Sanjay Kumar
Comment 13 2020-08-12 11:35:15 PDT
Youenn Fablet - do we need to create another ticket for this ? This does not seem to get attention otherwise and its a very serious bug. All PWAs that I have tried including my own App are all unusable right now iOS/iPadOS Safari (they all hang on re-launch from homescreen icon). Thanks
Miguel Ripoll
Comment 14 2020-08-18 12:35:41 PDT
I'm experiencing the same issue with my transit web app, I'd be a little bit upset if this bug persists in iOS 14 as well. Hopefully this bug gets prioritized, thank you.
Jamie
Comment 15 2020-08-19 13:39:28 PDT
Also experiencing this issue. Removing the service worker does not fix it, as it appears to be cached. I can't believe this is marked as P2 and not assigned to anyone. At my company this would be a RED ALERT and everyone would work non-stop until it was fixed.
Chris Dumez
Comment 16 2020-08-19 16:04:01 PDT
Has anybody tried iOS 14 beta? I have just tried the provided repro steps on iOS 14 beta and could not reproduce the issue.
Sanjay Kumar
Comment 17 2020-08-19 16:06:59 PDT
Yes, I am running iOS14 beta and seeing my App freeze all the time.
Chris Dumez
Comment 18 2020-08-19 16:18:56 PDT
(In reply to Sanjay Kumar from comment #17) > Yes, I am running iOS14 beta and seeing my App freeze all the time. Please indicate which beta.
Maciej Stachowiak
Comment 19 2020-08-19 17:09:47 PDT
For anyone who can reproduce this, especially on iOS 14 beta, can you please reproduce the problem and attach a sysdiagnose? The easiest way to get one is via Feedback Assistant.
Maciej Stachowiak
Comment 20 2020-08-19 17:12:04 PDT
Sanjay Kumar
Comment 21 2020-08-19 19:29:54 PDT
Something has changed in the last four days. I just downloaded iPadOS 14 Beta 5 on my Air and now it seems fixed - I could not get to hang in last hour plus of trying. But my iPhone which is on automatic update and probably has not received the latest beta, it does still hang.
Chris Dumez
Comment 22 2020-08-20 10:09:24 PDT
(In reply to Sanjay Kumar from comment #21) > Something has changed in the last four days. > > I just downloaded iPadOS 14 Beta 5 on my Air and now it seems fixed - I > could not get to hang in last hour plus of trying. > > But my iPhone which is on automatic update and probably has not received > the latest beta, it does still hang. Could others please confirm this is indeed fixed in Beta 5? This would explain why I was unable to reproduce myself.
Daniel Sweet
Comment 23 2020-08-25 09:42:44 PDT
I can also confirm this was fixed in iOS 13.5 and regressed in iOS 13.6. If anything, the problem became even more severe in iOS 13.6. Just like iOS 13.3, we're now seeing reports of PWAs freezing without Service Workers involved at all. It's becoming a massive support pain for us.
Kris Manning
Comment 24 2020-08-25 22:36:40 PDT
Still seeing this bug in 13.6.1 latest update.
Ingolf Wunder
Comment 25 2020-08-26 01:36:28 PDT
Confirmed. Still existing @13.6.1.
Chris Dumez
Comment 26 2020-08-26 08:48:24 PDT
(In reply to Ingolf Wunder from comment #25) > Confirmed. Still existing @13.6.1. I am asking to confirm this was indeed fixed in iOS 14 beta 5 (not iOS 13)
Daniel Sweet
Comment 27 2020-08-26 17:05:05 PDT
More on the freeze bugs I've been seeing, in addition to the Service Worker freeze bug: I have been able to reliably reproduce freezing with a PWA that only embeds an MP3 using the <audio> tag. On iOS 13.6.1, if I play the file, then immediately (while still loading or under 2 seconds in) switch into another app, and then back into the PWA, I see the complete freeze after only a handful of switches. It's the same freeze as the Service Worker one: I can't move the page around, JavaScript execution is completely stopped, and the Remote Debugger doesn't receive any data from, nor can it send Console commands to, my iPhone. I can't reproduce this problem on iOS 14 beta 6, but it would be ideal if we could get this resolved in iOS 13.x before iOS 14 is out, and without asking our users to necessarily upgrade to iOS 14 when it does come out. Especially considering that it was resolved in iOS 13.5 and regressed in iOS 13.6.
Rotem
Comment 28 2020-09-05 05:14:00 PDT
Happens for me too in 13.6.1. Just have to switch to background and reopen, and it freezes. Very frustrating.
Ingolf Wunder
Comment 29 2020-09-06 14:47:36 PDT
13.7 Update: Minimizing/Maximizing seems fixed (at least on iPadPro / iPhone SE), but when switching from one App to PWA it still freezes :/ ... C'mon Apple!!!!!!!!
mustafa.0x
Comment 30 2020-09-09 10:06:09 PDT
I have several popular PWAs. This very frustrating bug is happening with all of them.
Ingolf Wunder
Comment 31 2020-09-18 08:27:34 PDT
fixed in iOS 14
Jody Wheeler
Comment 32 2021-11-24 10:58:19 PST
Has anyone else experienced this still happening in iOS 15.1?
Šime Vidas
Comment 33 2021-12-30 01:09:56 PST
I have tested the steps to reproduce on iOS 15.1 (iPhone 8). The issue seems to be fixed now. I returned from Airhorner to home screen, used other apps and even turned off the screen for over a minute, but when I open Airhorner again, it still works (produces sound).
Note You need to log in before you can comment on or make changes to this bug.