<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>255363</bug_id>
          
          <creation_ts>2023-04-12 13:59:50 -0700</creation_ts>
          <short_desc>Wake Lock permission denied after visibilitychange</short_desc>
          <delta_ts>2023-04-25 10:33:45 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>Safari 16</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>https://mdn.github.io/dom-examples/screen-wake-lock-api/</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="siim">webkit</reporter>
          <assigned_to name="Chris Dumez">cdumez</assigned_to>
          <cc>cdumez</cc>
    
    <cc>cryze92</cc>
    
    <cc>marcosc</cc>
    
    <cc>tomac</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1948319</commentid>
    <comment_count>0</comment_count>
    <who name="siim">webkit</who>
    <bug_when>2023-04-12 13:59:50 -0700</bug_when>
    <thetext>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 &quot;visibilitychange&quot; 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 &amp; 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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1949838</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-04-19 14:00:21 -0700</bug_when>
    <thetext>&lt;rdar://problem/108279602&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1950781</commentid>
    <comment_count>2</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2023-04-24 09:04:14 -0700</bug_when>
    <thetext>This is because we require transient activation to request the wake lock.
When you&apos;re calling request() from the visibility change handler, you don&apos;t have transient activation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1950796</commentid>
    <comment_count>3</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2023-04-24 10:08:23 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/13104</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1951108</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-04-25 10:33:43 -0700</bug_when>
    <thetext>Committed 263382@main (d901ad78bdb6): &lt;https://commits.webkit.org/263382@main&gt;

Reviewed commits have been landed. Closing PR #13104 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>