Repository navigation
fix(player): honor runtime discovery and source in embeds - #5244
Conversation
jrusso1020
left a comment
There was a problem hiding this comment.
Thanks, this fixes #4002 and #4003.
- Runtime detection (#4002). shader-transitions also creates
window.__hf, so__hfwas never a reliable sign that the runtime had loaded. Keying on__player, which the runtime sets in the same synchronous init, fixes the src embeds that reported ready but wouldn't seek. runtime-src(#4003). ReusingruntimeSrcFromElementkeeps the existing http/https, same-origin or loopback rule and the pinned-CDN fallback.- Fail-fast. Replacing a timeout that could only ever fail removes no success path. Detaching
onerroron stop/restart, plus the script and document identity checks, keeps a stale error from failing a new document.
On the vitest setting, I checked happy-dom 20.9.0. handleDisabledFileLoadingAsSuccess only changes the synthetic event for a <script src> that loading-disabled happy-dom would otherwise fail synchronously. It's documented and not deprecated, and it can't hide a real failure: every load-failure test dispatches error by hand, and nothing in the player listens for script load. Without it, 5/552 player tests fail; with it, 552/552 pass.
Non-blocking suggestion: only compositionProbeReadiness.test.ts and composition-probe.test.ts need it. A per-file // @vitest-environment-options {"settings":{"handleDisabledFileLoadingAsSuccess":true}} docblock in those two files, with the config line removed, also passes 552/552 and keeps the rest of the suite on happy-dom's defaults.
— Rames
Fixes #4002
Fixes #4003
A
srcembed can mistake the sharedwindow.__hfshader namespace for the runtime bridge. On current main it can reportreadyfrom document metadata while seeking leaves the authored timeline at zero; nested scenes can remain unmounted. Check the actual__playerbridge so standalone timelines remain driveable and nested scenes receive the runtime.Use the existing validated
runtime-srcresolver for probe injection as well assrcdoc. A blocked or missing runtime now emits a load error with its URL, stops probing, and marks that document failed. Detach the error handler when stopping or restarting so an old script cannot fail the next document. Same-origin/loopback validation and pinned-CDN fallback stay intact.Follows the scope described in unmerged #4246, with before/after captures and additional failure/recovery coverage.
Before
Main at
188475aaf: CDN access blocked; every embed hasruntime-src="/local-runtime.js"and receivesseek(1). The shader namespace leaves its marker at x=40 instead of x=200. Nested scenes stay empty, and the plain nested embed fetches jsDelivr and times out.After
Identical fixture HTML, same blocked-CDN policy. All four embeds load and seek to x=200; nested scenes use
/local-runtime.js, expose__player, and register their child timelines. No CDN requests or browser runtime errors.Validation
runtime-srcrecovers and seeks correctly.