Bug 254545 - New Wake Lock API does not work in Home Screen Web Apps
Summary: New Wake Lock API does not work in Home Screen Web Apps
Status: REOPENED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: Safari 17
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-03-27 13:35 PDT by siim
Modified: 2024-04-10 14:46 PDT (History)
14 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description siim 2023-03-27 13:35:08 PDT
New Wake Lock API works in Safari browser but does not work when web page is added to home screen.


https://whatpwacando.today/wake-lock
Comment 1 Chris Dumez 2023-03-27 14:25:40 PDT
Thank you for filing the bug and the reproduction case. I'll investigate when I have some spare cycles.

I have no idea why Home Screen web apps would behave differently than MobileSafari here.
Comment 2 Radar WebKit Bug Importer 2023-03-27 14:25:53 PDT
<rdar://problem/107284303>
Comment 3 siim 2023-03-27 14:28:12 PDT
Wake lock works:
iOS Safari in browser
iOS MS Edge in browser

Wake lock does not work:
iOS Safari added to home screen
iOS MS Edge added to home screen


iOS 16.4
iPhone 13
Comment 4 Chris Dumez 2023-03-27 14:29:24 PDT
(In reply to siim from comment #3)
> Wake lock works:
> iOS Safari in browser
> iOS MS Edge in browser
> 
> Wake lock does not work:
> iOS Safari added to home screen
> iOS MS Edge added to home screen
> 
> 
> iOS 16.4
> iPhone 13

One difference I can think of is WKWebView vs SafariViewController.
Comment 5 Jesper Bendtsen 2023-03-28 09:32:21 PDT
I have experienced the same thing, it works in Safari browser, but not in installed PWA.

iPhone 11 - iOS 16.4
iPad prod 2020 - iOS 16.4
Comment 6 Marcos Caceres 2023-03-29 19:13:10 PDT
Came up here to:
https://bugs.webkit.org/show_bug.cgi?id=205104#c8

With another test case:
https://pelord.github.io/wakeLockApiAddHomeScreen/
Comment 7 siim 2023-04-12 13:37:01 PDT
Also Wake Lock API does not work with "visibilitychange" event.

Unable to re set wake lock api after user goes to home screen and back to Safari.

NotAllowedError: Permission was denied

https://github.com/mdn/dom-examples/blob/main/screen-wake-lock-api/script.js

This example works fine in Android & Windows.
Comment 8 Chris Dumez 2023-04-12 13:38:00 PDT
(In reply to siim from comment #7)
> Also Wake Lock API does not work with "visibilitychange" event.
> 
> Unable to re set wake lock api after user goes to home screen and back to
> Safari.
> 
> NotAllowedError: Permission was denied
> 
> https://github.com/mdn/dom-examples/blob/main/screen-wake-lock-api/script.js
> 
> This example works fine in Android & Windows.

Please file a separate bug since this is a separate issue (please cc me).
Comment 9 siim 2023-04-12 14:05:33 PDT
(In reply to Chris Dumez from comment #8)
> Please file a separate bug since this is a separate issue (please cc me).

https://bugs.webkit.org/show_bug.cgi?id=255363
Comment 10 Chris Dumez 2023-04-25 10:24:48 PDT
We rely on the following code to keep the screen awake on iOS:
```
[UIApplication sharedApplication].idleTimerDisabled = YES;
```

This likely does't work in Home Screen Web Apps because they are not UIApplications but ViewServices. Looks like we need to find an alternate way to make this work for such apps.
Comment 11 Chris Dumez 2023-04-25 16:58:07 PDT
Pull request: https://github.com/WebKit/WebKit/pull/13179
Comment 12 EWS 2023-04-26 10:59:54 PDT
Committed 263419@main (bf7f0d4d340b): <https://commits.webkit.org/263419@main>

Reviewed commits have been landed. Closing PR #13179 and removing active labels.
Comment 13 PE Lord 2023-05-19 13:09:44 PDT
The fix do not seem to have landed into iOS 16.5 ... :(
Comment 14 Chris Dumez 2023-05-19 13:15:42 PDT
(In reply to PE Lord from comment #13)
> The fix do not seem to have landed into iOS 16.5 ... :(

This is true. I should also mention that the fix isn't in WebKit. We added API to WebKit to allow the Safari team to fix this (and thus closed this WebKit bug report). However, the issue won't be resolved until Safari actually adopts the new WebKit API.
Comment 15 Jesper Bendtsen 2023-07-26 00:10:24 PDT
in iOS 16.6 it doesn't work either :( fingers crossed for iOS 17...
Comment 16 siim 2023-08-22 22:56:16 PDT
Still not fixed in iOS 17 beta 7.
Comment 17 siim 2023-09-13 00:34:56 PDT
Still not fixed in iOS 17 RC
Comment 18 Vince 2023-09-13 12:47:30 PDT
Just installed iOS 17 Beta on iPad, and still doesn't work.
Comment 19 siim 2023-09-25 04:12:17 PDT
Still not fixed in iOS 17.0.1.


I guess it will be never fixed.

What a waste of time.
Comment 20 Chris Dumez 2023-09-25 12:02:49 PDT
WebKit is providing API for Safari to adopt. No further code change is expected in WebKit so there is no point in keeping this WebKit bug open.
Comment 21 Alexey Proskuryakov 2023-09-25 12:05:04 PDT
Please report this https://feedbackassistant.apple.com for better visibility within Apple.

You are also welcome and encouraged to comment here, however that's not as good as reporting feedback in the right place.
Comment 22 siim 2023-09-25 12:18:40 PDT
(In reply to Alexey Proskuryakov from comment #21)
> Please report this https://feedbackassistant.apple.com for better visibility
> within Apple.
> 
> You are also welcome and encouraged to comment here, however that's not as
> good as reporting feedback in the right place.

This website does not work with other browsers:

VM95:1  Uncaught (in promise) SyntaxError: Unterminated string in JSON at position 993 (line 1 column 994)

https://i.imgur.com/Ml5VgKU.png
Comment 23 siim 2023-09-25 12:23:45 PDT
Also broken in Safari.(In reply to Alexey Proskuryakov from comment #21)
> Please report this https://feedbackassistant.apple.com for better visibility
> within Apple.
> 
> You are also welcome and encouraged to comment here, however that's not as
> good as reporting feedback in the right place.

Also broken in Safari.

Please test your links before recommending them here...
Comment 24 Chris Dumez 2023-09-25 12:28:27 PDT
(In reply to siim from comment #23)
> Also broken in Safari.(In reply to Alexey Proskuryakov from comment #21)
> > Please report this https://feedbackassistant.apple.com for better visibility
> > within Apple.
> > 
> > You are also welcome and encouraged to comment here, however that's not as
> > good as reporting feedback in the right place.
> 
> Also broken in Safari.
> 
> Please test your links before recommending them here...

This site is working fine for me both in Safari and Chrome. The issue you're seeing could be caused by a browser extension. If not, I'm unsure what the issue is.

https://feedbackassistant.apple.com is the main Apple website to file bugs and we do get a lot of bugs report from this site.
Comment 25 siim 2023-09-25 12:35:17 PDT
I do not have any extensions on Safari.

I guess they do not want regular users feedback :)
Comment 26 siim 2023-09-25 12:39:59 PDT
https://i.imgur.com/RgU2eNC.png

Same JSON parse error in Safari:
Unhandled Promise Rejection: SyntaxError: JSON Parse error: Unterminated string
SyntaxError: JSON Parse error: Unterminated string
Comment 27 Chris Dumez 2023-09-25 12:42:03 PDT
(In reply to siim from comment #26)
> https://i.imgur.com/RgU2eNC.png
> 
> Same JSON parse error in Safari:
> Unhandled Promise Rejection: SyntaxError: JSON Parse error: Unterminated
> string
> SyntaxError: JSON Parse error: Unterminated string

At what step do you get this error?
Comment 28 siim 2023-09-25 12:52:22 PDT
(In reply to Chris Dumez from comment #27)

> At what step do you get this error?

2 seconds after login and I can see unread iOS beta news and then it crashes to blank page.
Comment 29 siim 2023-09-25 13:58:36 PDT
Managed to get screenshot before crash.

I guess untitled feedback is corrupted.

https://i.imgur.com/A39si4s.png
Comment 30 siim 2023-09-25 14:35:30 PDT
This feedback website is broken in iOS 17 iPhone 13 also.
Managed to add new feedback and choose iOS/iPad and after that it crashes to blank screen.
Comment 31 Jen Simmons 2023-09-26 09:51:06 PDT
rdar://108573133
Comment 32 Jen Simmons 2023-09-26 11:33:35 PDT
Closing this again, because the work needed in the WebKit engine is in fact complete. 

Web apps are interesting because they involve both the browser engine and other kinds of browser technology / operating system technology. 

Wake Lock API does not yet work in Home Screen Web Apps. We are aware; this is not unexpected. The work that's still needed for a complete fix _is_ being tracked and discussed — just not in the WebKit project, since the WebKit portion is done. 

Stay tuned.
Comment 33 PE Lord 2023-12-14 10:02:01 PST
Does this fix in webkit has landed in iOS 17.2?
Comment 34 siim 2023-12-15 00:49:30 PST
No

Still broken
Comment 35 Jesper Bendtsen 2023-12-17 00:06:28 PST
I'm really waiting for this to work in web apps, have been playing hidden video for years as a workaround. The downside with this method is that the video title and play and pause buttons appear on the front on iOS devices. Not cool. So Apple please prioritize this, been waiting since iOS 16.4 for a fix for web apps. The WebKit team has done their work a long time ago…
Comment 36 Danny Moerkerke 2024-01-09 13:44:40 PST
How can we report this to Apple? Otherwise this will probably never be fixed :-(
Comment 37 Marcos Caceres 2024-01-09 17:16:44 PST
Reopening... and don't don't worry, Apple people (e.g., me) do monitor these things. I'll check to see what's going on as this has possibly regressed.
Comment 38 Chris Dumez 2024-01-09 18:34:43 PST
@Marcos: There is no issue to fix on WebKit side, therefore there is no reason to have a WebKit bugzilla bug. There is already a radar and it is already assigned to the correct team at Apple. This issue was not forgotten.
Comment 39 Chris Dumez 2024-01-09 18:35:14 PST
(In reply to Danny Moerkerke from comment #36)
> How can we report this to Apple? Otherwise this will probably never be fixed
> :-(

feedbackassistant.apple.com is how people report bugs to Apple.
Comment 40 Marcos Caceres 2024-01-09 19:09:18 PST
Oh yeah, oops. Sorry, Chris. Forgot we’d already suggested that.
Comment 41 siim 2024-01-17 23:30:22 PST
Still not fixed in iOS 17.3.
Comment 42 siim 2024-02-08 02:37:41 PST
It is fixed in iOS 17.4 by removing PWA support entirely...

No PWA, no problem.

https://www.theregister.com/2024/02/08/apple_web_apps_eu/
Comment 43 siim 2024-02-15 12:14:37 PST
It is official now. Home Screen Apps are just bookmarks in iOS.

Thanks all @apple.com developers here for helping to kill open web.

https://open-web-advocacy.org/blog/apple-on-course-to-break-all-web-apps-in-eu-within-20-days/
Comment 44 PE Lord 2024-03-25 08:37:06 PDT
They finally changed their mind.

https://bugs.webkit.org/show_bug.cgi?id=268643#c50
Comment 45 siim 2024-04-02 09:04:39 PDT
The bug had its one-year anniversary last month.

Thanks Apple