Bug 254545
Summary: | New Wake Lock API does not work in Home Screen Web Apps | ||
---|---|---|---|
Product: | WebKit | Reporter: | siim <webkit> |
Component: | New Bugs | Assignee: | Chris Dumez <cdumez> |
Status: | REOPENED | ||
Severity: | Normal | CC: | af, bedney, boris.brudnoy, cdumez, clshortfuse, cryze92, drmoerkerke, dwaynemac, echrs, ehsan.herai, ggaren, ik, jensimmons, jesperbendtsen83, marcosc, me, pierre-etienne.lord, robert.gergeo, sbehrens1414, tomac, vincent.tremblay-lavoie, webkit-bug-importer, webkit, wiedemann.m, zazi.dx |
Priority: | P2 | Keywords: | InRadar |
Version: | Safari 17 | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
siim
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
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Chris Dumez
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.
Radar WebKit Bug Importer
<rdar://problem/107284303>
siim
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
Chris Dumez
(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.
Jesper Bendtsen
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
Marcos Caceres
Came up here to:
https://bugs.webkit.org/show_bug.cgi?id=205104#c8
With another test case:
https://pelord.github.io/wakeLockApiAddHomeScreen/
siim
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.
Chris Dumez
(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).
siim
(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
Chris Dumez
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.
Chris Dumez
Pull request: https://github.com/WebKit/WebKit/pull/13179
EWS
Committed 263419@main (bf7f0d4d340b): <https://commits.webkit.org/263419@main>
Reviewed commits have been landed. Closing PR #13179 and removing active labels.
PE Lord
The fix do not seem to have landed into iOS 16.5 ... :(
Chris Dumez
(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.
Jesper Bendtsen
in iOS 16.6 it doesn't work either :( fingers crossed for iOS 17...
siim
Still not fixed in iOS 17 beta 7.
siim
Still not fixed in iOS 17 RC
Vince
Just installed iOS 17 Beta on iPad, and still doesn't work.
siim
Still not fixed in iOS 17.0.1.
I guess it will be never fixed.
What a waste of time.
Chris Dumez
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.
Alexey Proskuryakov
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.
siim
(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
siim
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...
Chris Dumez
(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.
siim
I do not have any extensions on Safari.
I guess they do not want regular users feedback :)
siim
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
Chris Dumez
(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?
siim
(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.
siim
Managed to get screenshot before crash.
I guess untitled feedback is corrupted.
https://i.imgur.com/A39si4s.png
siim
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.
Jen Simmons
rdar://108573133
Jen Simmons
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.
PE Lord
Does this fix in webkit has landed in iOS 17.2?
siim
No
Still broken
Jesper Bendtsen
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…
Danny Moerkerke
How can we report this to Apple? Otherwise this will probably never be fixed :-(
Marcos Caceres
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.
Chris Dumez
@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.
Chris Dumez
(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.
Marcos Caceres
Oh yeah, oops. Sorry, Chris. Forgot we’d already suggested that.
siim
Still not fixed in iOS 17.3.
siim
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/
siim
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/
PE Lord
They finally changed their mind.
https://bugs.webkit.org/show_bug.cgi?id=268643#c50
siim
The bug had its one-year anniversary last month.
Thanks Apple
Dwayne Macgowan
i'm having this issue on iPhone 14, iOS 17.5.1
Sean Ray Dvir
This bug still exists in the latest version of iOS.
Any updates?
Something to let us at least hope for a future where we can ship web apps properly on iOS?
ik
"There is already a radar and it is already assigned to the correct team at Apple. This issue was not forgotten."
https://bugs.webkit.org/show_bug.cgi?id=254545#c38
That was 9 months ago. iOS 16.4 was released 18 months ago.
Would be nice if someone could send a memo or something to that team? I mean, I imagine WebKit folks who worked on this feature would like their colleagues to take their work seriously and fix this?
< Sorry for sounding snarky, but it would be a shame to have this take 3 years like fixing background audio in web apps did. >
William J. Edney
Looks like this is still not fixed in iOS 18.0
Can others verify?
Continuing to use the 'video element' hack for now, but its hacky and leaves detritus on the lock screen.
Any update Apple folks?
Cheers,
- Bill
Carlos Lopez
Video playback no longer works as a suitable fallback. An iPad will dim and lock regardless. This has completely degraded the state of our application. I have about 40 upset users who will need to migrate to Android devices.
webkit
I'm also encountering this issue in a PWA that I am developing. I need the screen to stay awake because the user is reading a document while operating an instrument with both hands with no opportunity to send input that would keep the screen at normal brightness.
webkit
This bug is still present in iOS 18.1 for installed PWA apps / bookmarked sites. The wakelock works when the page is running in Safari, but does not work when the app / page was opened from the home screen.
A simple way to confirm this is to try the 'Enable Wake Lock' button on this page:
https://progressier.com/pwa-capabilities/screen-wake-lock
from safari (works) and from a page opened from the home screen (does not work).
Maximilian Wiedemann
The bug still seems to be present in iOS 18.2 for PWAs.
Working fine in Safari. In PWA, even though it gives you a proper WakeLockSentinel object and rejection reason, it still goes to sleep.
Tested using the previously mentioned https://progressier.com/pwa-capabilities/screen-wake-lock and my own web app.
Sam Behrens
This bug seems to be fixed with 18.2.1. Can someone else on 18.2.1 confirm?
Sam Behrens
(In reply to Sam Behrens from comment #54)
> This bug seems to be fixed with 18.2.1. Can someone else on 18.2.1 confirm?
Nevermind. I’m sorry to give anyone a false sense of hope. I hadn’t realized that I had changed my phone settings. WebKit team/Apple, please address this bug.
ehsan.herai
Has anyone got any workaround?
btw I've already tried video-playing solution.
Dwayne Macgowan
i'm using @scottjgilroy/no-sleep and it works on iphone
Nikki Bernobic
Issue still present on 18.3.1...
Danny Moerkerke
(In reply to Dwayne Macgowan from comment #57)
> i'm using @scottjgilroy/no-sleep and it works on iphone
Please read the issue description, this doesn't work for web apps that have been added to the Home Screen.
The library you mentioned uses the native wakeLock under the hood so it will work in the browser but not when the web app is added to the Home Screen.
Nikki Bernobic
(In reply to Danny Moerkerke from comment #59)
> (In reply to Dwayne Macgowan from comment #57)
> > i'm using @scottjgilroy/no-sleep and it works on iphone
>
> Please read the issue description, this doesn't work for web apps that have
> been added to the Home Screen.
>
> The library you mentioned uses the native wakeLock under the hood so it will
> work in the browser but not when the web app is added to the Home Screen.
FWIW, I've found a demo page that showcases multiple libraries (https://sgilroy.github.io/nosleep.page) and the library mentioned above seems to work in PWA mode.
Danny Moerkerke
(In reply to Nikki Bernobic from comment #60)
> (In reply to Danny Moerkerke from comment #59)
> > (In reply to Dwayne Macgowan from comment #57)
> > > i'm using @scottjgilroy/no-sleep and it works on iphone
> >
> > Please read the issue description, this doesn't work for web apps that have
> > been added to the Home Screen.
> >
> > The library you mentioned uses the native wakeLock under the hood so it will
> > work in the browser but not when the web app is added to the Home Screen.
>
> FWIW, I've found a demo page that showcases multiple libraries
> (https://sgilroy.github.io/nosleep.page) and the library mentioned above
> seems to work in PWA mode.
On iOS 18.3.1 this works, except for the first library.
But comment #50 suggests this no longer works on iPadOS.
Carlos Lopez
"Where this API isn't supported, an empty silent video is played to emulate this behaviour (using NoSleep.js)."
Video playback is hit or miss and doesn't work when the page actually uses audio/video stream like WebRTC. I mentioned this before, and I ultimately ended up losing the client and the $200K/yr contract that came with it.