Bug 255363 - Wake Lock permission denied after visibilitychange
Summary: Wake Lock permission denied after visibilitychange
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: Safari 16
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL: https://mdn.github.io/dom-examples/sc...
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-04-12 13:59 PDT by siim
Modified: 2023-04-25 10:33 PDT (History)
5 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-04-12 13:59:50 PDT
Wake Lock releases when app is not visible. This is expected and is same in all platforms (iOS, Android, Windows)

document.visibilitychange event is used to aquire wake lock after user has started using app again.

In iOS Wake Lock does not work after "visibilitychange" event to re-aquire wake lock if user *goes to home screen*.
If apps are changed *without going to home screen*, then wake lock is re-aquired or stays active.

Error message: NotAllowedError: Permission was denied

Expected result:
There should be permission to re-aquire wake lock after going back to home screen & back to Safari.
There are no permission errors in Android or Windows.


Example:
https://mdn.github.io/dom-examples/screen-wake-lock-api/

Code:
https://github.com/mdn/dom-examples/blob/main/screen-wake-lock-api/script.js
Comment 1 Radar WebKit Bug Importer 2023-04-19 14:00:21 PDT
<rdar://problem/108279602>
Comment 2 Chris Dumez 2023-04-24 09:04:14 PDT
This is because we require transient activation to request the wake lock.
When you're calling request() from the visibility change handler, you don't have transient activation.
Comment 3 Chris Dumez 2023-04-24 10:08:23 PDT
Pull request: https://github.com/WebKit/WebKit/pull/13104
Comment 4 EWS 2023-04-25 10:33:43 PDT
Committed 263382@main (d901ad78bdb6): <https://commits.webkit.org/263382@main>

Reviewed commits have been landed. Closing PR #13104 and removing active labels.