Skip to content

refactor: drop vendor-prefixed Page Visibility API support#8638

Merged
willeastcott merged 1 commit into
mainfrom
refactor/drop-vendor-visibility-prefixes
Apr 22, 2026
Merged

refactor: drop vendor-prefixed Page Visibility API support#8638
willeastcott merged 1 commit into
mainfrom
refactor/drop-vendor-visibility-prefixes

Conversation

@willeastcott
Copy link
Copy Markdown
Contributor

@willeastcott willeastcott commented Apr 22, 2026

Summary

  • Drops legacy vendor-prefixed Page Visibility API handling (mozvisibilitychange, msvisibilitychange, webkitvisibilitychange and the paired mozHidden / msHidden / webkitHidden attribute lookup) from AppBase.
  • Registers a single unprefixed visibilitychange listener in init(), tears it down with a single removeEventListener in destroy(), and rewrites isHidden() to read document.hidden directly.
  • Removes the now-unused internal _hiddenAttr property.

Rationale

The unprefixed Page Visibility API (document.hidden + visibilitychange) is universally supported by the engine's target browsers (WebGL 2 baseline: Chrome 56+, Firefox 51+, Safari 15+, Edge 79+). keyboard.js already only uses the unprefixed event, so this brings AppBase in line.

Public API

  • AppBase#isHidden() — unchanged signature and return semantics, only the internal implementation changed.
  • _hiddenAttr was private (underscore-prefixed, not a declared class field) and had no external consumers.

Test plan

  • npx eslint src/framework/app-base.js — clean.
  • Launch an engine example, switch browser tab away and back, confirm audio suspends/resumes as before.

The unprefixed `visibilitychange` event and `document.hidden` property are
supported by all browsers the engine targets (WebGL 2 baseline). Remove
the `moz`/`ms`/`webkit` fallbacks from AppBase and the now-unused
`_hiddenAttr` internal property.

Made-with: Cursor
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes legacy vendor-prefixed Page Visibility API handling from AppBase and standardizes visibility tracking on the unprefixed document.hidden + visibilitychange API.

Changes:

  • Register only the unprefixed visibilitychange listener during init().
  • Simplify isHidden() to return document.hidden directly.
  • Simplify teardown in destroy() by removing only the unprefixed listener (and implicitly removing the need for _hiddenAttr).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@willeastcott willeastcott merged commit 4d3f5cd into main Apr 22, 2026
12 checks passed
@willeastcott willeastcott deleted the refactor/drop-vendor-visibility-prefixes branch April 22, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: audio enhancement Request for a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants