RESOLVED FIXED 180523
Page visibility api does not function with standalone safari apps
https://bugs.webkit.org/show_bug.cgi?id=180523
Summary Page visibility api does not function with standalone safari apps
andj2223
Reported 2017-12-07 00:40:00 PST
The page visibility api does not function properly with homescreen apps on the iPhone/iPad on iOS 11. To repro: 1. In Safari on an iPhone or iPad with iOS 11, go to https://andrewjdr.github.io/pagevis-api-safari-standalone-broken/ 2. Add this to your homescreen. 3. Open the newly created homescreen app. 4. Start playing the video. 5. Press the sleep button on the iPhone/iPad. 6. Unexpectedly, the visibilitychange event handler is never called, and the audio continues to play. Furthermore, document.hidden is always "false", even when the screen is locked (verified via setInterval in web inspector). Compare this to the expected result, which you can observe by performing the same steps within safari proper (without going through the homescreen app): 1. In Safari on an iPhone or iPad with iOS 11, go to https://andrewjdr.github.io/pagevis-api-safari-standalone-broken/ 2. Start playing the video. 3. Press the sleep button on the iPhone/iPad. 4. As expected, visibilitychange handler is called, and the audio stops playing. document.hidden is correctly set to "true" when the screen is locked. I believe this is a major issue, because homescreen apps that are computation heavy (and thus battery-consuming) have no way of detecting that the device has been locked so that they can stop their expensive computations or work. Additionally, onblur/onfocus events also do not fire. As far as I know, there is no way of detecting that the page is no longer visible from a homescreen app when the screen becomes locked.
Attachments
andj2223
Comment 1 2017-12-07 00:42:39 PST
This is apparently a known issue and has been present since 11.0.2, because the following page mentions it: https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API "[4] From iOS 11.0.2 onwards, the values are not correct in standalone mode (when you press "Add to Homescreen") and when the screen is locked (you pressed the power button). The value for hidden is false and visibilityState is visible." Also, for the future record, an archive.org link - https://web.archive.org/web/20171207084209/https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API Is anything being done about this? It's a rather significant issue.
Radar WebKit Bug Importer
Comment 2 2017-12-07 14:19:19 PST
andj2223
Comment 3 2018-01-08 01:32:16 PST
Have there been any updates on this? Thanks.
andj2223
Comment 4 2018-03-14 22:15:48 PDT
For the record, I just tested with the latest iOS 11.3 beta 5 and this bug is still present.
Chris Dumez
Comment 5 2018-09-19 13:40:05 PDT
(In reply to andj2223 from comment #4) > For the record, I just tested with the latest iOS 11.3 beta 5 and this bug > is still present. I cannot seem to reproduce with your test page on iOS 12 / iPad.
andj2223
Comment 6 2018-09-19 17:15:53 PDT
Hi Chris, Thanks for taking a look. This issue was present in iOS 11, but it appears that it was fixed at some point in iOS 12.
Chris Dumez
Comment 7 2018-09-20 09:24:47 PDT
(In reply to andj2223 from comment #6) > Hi Chris, Thanks for taking a look. This issue was present in iOS 11, but it > appears that it was fixed at some point in iOS 12. Thanks for confirming!
Note You need to log in before you can comment on or make changes to this bug.