[Webkit-unassigned] [Bug 205104] New: Feature Request: Implement the Wake Lock API

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Dec 10 23:33:56 PST 2019


https://bugs.webkit.org/show_bug.cgi?id=205104

            Bug ID: 205104
           Summary: Feature Request: Implement the Wake Lock API
           Product: WebKit
           Version: Safari Technology Preview
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: New Bugs
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: tomac at google.com

Many websites like recipe sites or tutorial sites have a legit desire to prevent the screen of a device from turning off. Since the user may be busy with performing a task (following the recipe or tutorial steps), in many cases they may not be able or willing to touch the screen to keep it awake, for example, because their hands are dirty with dough or glue. The current workaround for page authors to obtain the desired behavior is to play an invisible video and to loop it infinitely. The Wake Lock API instead provides them with a proper way to programmatically keep the screen awake via a screen wake lock. When the user navigates away from either the tab or multitasks away from their browser completely, the wake lock would be released automatically.

Spec: https://w3c.github.io/wake-lock/

Article: https://web.dev/wakelock/

Demo: https://wake-lock-demo.glitch.me/

Sample code:

```js
// The wake lock sentinel.
let wakeLock = null;

// Function that attempts to request a wake lock.
const requestWakeLock = async () => {
  try {
    wakeLock = await navigator.wakeLock.request('screen');
    wakeLock.addEventListener('release', () => {
      console.log('Wake Lock was released');
    });
    console.log('Wake Lock is active');
  } catch (err) {
    console.error(`${err.name}, ${err.message}`);
  }
};

// Request a wake lock…
await requestWakeLock();
// …and release it again after 5s.
window.setTimeout(() => {
  wakeLock.release();
  wakeLock = null;
}, 5000);
```

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20191211/6a8a7c31/attachment-0001.htm>


More information about the webkit-unassigned mailing list