Skip to content

Remove passive event listener detection and platform.passiveEvents - #9252

Merged
willeastcott merged 5 commits into
mainfrom
remove-passive-event-detection
Aug 29, 2026
Merged

Remove passive event listener detection and platform.passiveEvents#9252
willeastcott merged 5 commits into
mainfrom
remove-passive-event-detection

Conversation

@willeastcott

@willeastcott willeastcott commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Description

detectPassiveEvents() in platform.js probes whether the browser supports passive event listeners — a feature that shipped in every browser (Chrome 51, Firefox 49, Safari 10) years before WebGL2, which the engine requires. The probe can never return false in any environment able to run the engine, and it relies on the legacy addEventListener('testpassive', null, opts) null-listener trick.

  • The probe and the platform.passiveEvents flag are removed entirely.
  • The four listener attach/detach sites (Mouse#attach/detach, ElementInput#attach/detach) pass their options objects directly instead of branching on the flag.
  • Mouse no longer needs its platform import.

Why full removal rather than keeping the flag or tagging it @deprecated: the flag was @ignore'd (never documented), a GitHub-wide code search for platform.passiveEvents finds zero application usage (the only two matches are an engine fork's copy of these same internal call sites), and the failure mode is benign — reading the removed property yields undefined, so any copied ternary degrades to the boolean-capture listener form, which is valid in every browser. Nothing can crash.

Verified: lint clean; full unit suite 2337 passing with failures identical to the main baseline.

Checklist

  • I have read the contributing guidelines
  • My code follows the project's coding standards
  • This PR focuses on a single change

🤖 Generated with Claude Code

Passive event listeners shipped in every browser years before WebGL2,
which the engine requires, so the detectPassiveEvents probe in
platform.js (which also relied on the legacy null-listener trick) can
never return false in any environment able to run the engine.

platform.passiveEvents remains on the platform namespace as a literal
true for backwards compatibility. The four listener attach/detach sites
in Mouse and ElementInput now pass their options objects directly, and
Mouse no longer needs the platform import.

Behavioural note: in Node and worker environments (no window) the probe
used to throw and report false; the flag now reads true there as well.
The only consumers are browser-only listener paths, so nothing changes
in practice.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown

Build size report

This PR changes the size of the minified bundles.

Bundle Minified Gzip Brotli
playcanvas.min.js 2390.0 KB (−0.3 KB, −0.01%) 614.5 KB (−0.1 KB, −0.01%) 476.7 KB (+0.0 KB, +0.01%)
playcanvas.min.mjs 2387.3 KB (−0.3 KB, −0.01%) 613.3 KB (−0.1 KB, −0.02%) 476.3 KB (−0.1 KB, −0.01%)

A GitHub-wide code search finds no application usage (the only matches
are an engine fork's copy of the internal call sites), the flag was
@ignore'd and thus undocumented, and reading the removed property
degrades benignly: undefined is falsy, so any copied ternary falls back
to the boolean-capture listener form, which works in every browser.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@willeastcott willeastcott changed the title Remove passive event listener detection Remove passive event listener detection and platform.passiveEvents Aug 29, 2026
ElementInput used opts where Mouse uses options, and was missing the
AddEventListenerOptions type annotation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@willeastcott
willeastcott merged commit 727804e into main Aug 29, 2026
10 checks passed
@willeastcott
willeastcott deleted the remove-passive-event-detection branch August 29, 2026 08:59
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.

1 participant