Skip to content

Comments

fix(wakelock): screen-saver prevention breaks after Fire TV app-switch#100

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/disable-screen-saver-fire-tv
Draft

fix(wakelock): screen-saver prevention breaks after Fire TV app-switch#100
Copilot wants to merge 3 commits intomainfrom
copilot/disable-screen-saver-fire-tv

Conversation

Copy link
Contributor

Copilot AI commented Feb 22, 2026

wakelock.js silently stopped preventing the screen saver after the user switched away from and returned to the guide page on Fire TV / Silk Browser. Two independent bugs:

Bugs fixed

  • NoSleep video never resumed — browsers pause <video> elements when the page is hidden. The old handler guarded on !noSleepVideo (always false once the element was created), so the canvas-stream stayed paused for the rest of the session.

  • Wake Lock sentinel release-event race — the browser releases the sentinel asynchronously on hide. If the release event fires after the page-visible visibilitychange, wakeLockSentinel is still non-null at the check and re-acquisition is skipped, leaving the lock permanently dropped.

Changes

  • static/js/wakelock.js — rewrote the visibilitychange handler with three branches:

    State on page-show Action
    NoSleep video exists and is paused video.play()
    Wake Lock in use, sentinel gone requestWakeLock()
    Sentinel still exists Re-request a fresh sentinel (wins the race), release old one; fall back to video on failure
    document.addEventListener('visibilitychange', function () {
      if (document.visibilityState !== 'visible') return;
      if (noSleepVideo) {
        if (noSleepVideo.paused) { noSleepVideo.play().catch(function () {}); }
      } else if (!wakeLockSentinel) {
        requestWakeLock();
      } else {
        navigator.wakeLock.request('screen').then(function (newSentinel) {
          try { wakeLockSentinel.release(); } catch (e) {}
          wakeLockSentinel = newSentinel;
          newSentinel.addEventListener('release', function () { wakeLockSentinel = null; });
        }).catch(function () { wakeLockSentinel = null; startNoSleepVideo(); });
      }
    });
  • CHANGELOG.md — v4.6.0 entry.

Original prompt

This section details on the original issue you should resolve

<issue_title>Fire TV (Silk Browser) Disable screen saver from appearing while not in full screen video</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: thehack904 <35552907+thehack904@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix screen saver issue in Fire TV Silk Browser Prevent screen saver on Fire TV (Silk Browser) while browsing the guide Feb 22, 2026
Copilot AI requested a review from thehack904 February 22, 2026 01:15
… page re-show

- Resume paused canvas-stream video when page becomes visible again;
  browsers pause media while hidden so the old code left it permanently paused
- Re-request the Wake Lock sentinel immediately on page-show to win the
  race where the sentinel's release event fires after visibilitychange
- Update CHANGELOG.md for v4.6.0

Co-authored-by: thehack904 <35552907+thehack904@users.noreply.github.com>
Copilot AI changed the title Prevent screen saver on Fire TV (Silk Browser) while browsing the guide fix(wakelock): screen-saver prevention breaks after Fire TV app-switch Feb 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fire TV (Silk Browser) Disable screen saver from appearing while not in full screen video

2 participants