Skip to content

[MediaCapabilities] Protect MediaCapabilities JS wrapper from GC#1678

Open
asurdej-comcast wants to merge 1 commit into
WebPlatformForEmbedded:wpe-2.46from
asurdej-comcast:media_caps
Open

[MediaCapabilities] Protect MediaCapabilities JS wrapper from GC#1678
asurdej-comcast wants to merge 1 commit into
WebPlatformForEmbedded:wpe-2.46from
asurdej-comcast:media_caps

Conversation

@asurdej-comcast
Copy link
Copy Markdown

@asurdej-comcast asurdej-comcast commented May 21, 2026

Add GenerateIsReachable=ReachableFromNavigator to prevent wrapper GC. The MediaCapabilities interface is annotated [SameObject] in the spec, meaning navigator.mediaCapabilities must return the same object on every access. Without GC protection, the JS wrapper can be collected when no JS reference holds it, causing a new wrapper to be created on next access. This breaks object identity and loses any user-set properties.

This fixes an issue with ShakaPlayer that sets its own, custom navigator.mediaCapabilities.decodingInfo wrapper JS function that provides DRM data in addition to native decodingInfo impl.
See https://github.com/shaka-project/shaka-player/blob/ce7ee4b76f1fd6104519fe6f20fe7dda9d759eaf/lib/polyfill/mcap_encryption_scheme.js#L131

53edfff

Build-Tests Layout-Tests
✅ 🛠 wpe-246-amd64-build ✅ 🧪 wpe-246-amd64-layout
✅ 🛠 wpe-246-arm32-build ✅ 🧪 wpe-246-arm32-layout

Add GenerateIsReachable=ReachableFromNavigator to prevent wrapper GC.
The MediaCapabilities interface is annotated [SameObject] in the spec,
meaning navigator.mediaCapabilities must return the same object on every
access. Without GC protection, the JS wrapper can be collected when no
JS reference holds it, causing a new wrapper to be created on next access.
This breaks object identity and loses any user-set properties.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants