Skip to content

Enable SPZ and GUI Input validation tests via harness workarounds - #1959

Merged
bkaradzic-microsoft merged 2 commits into
BabylonJS:masterfrom
bkaradzic-microsoft:es-module-import-workaround
Oct 22, 2026
Merged

bkaradzic-microsoft merged 2 commits into
BabylonJS:masterfrom
bkaradzic-microsoft:es-module-import-workaround

Conversation

@bkaradzic-microsoft

@bkaradzic-microsoft bkaradzic-microsoft commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Enables three validation tests that were excluded only because of browser-only features Babylon Native doesn't have yet. Each is handled by an opt-in harness workaround in validation_native.js (documented in AddingNewValidationTests.md). As with the existing workarounds, these mark Babylon Native bugs to be fixed properly later.

es-module-import — "Gaussian Splatting SPZ SH", "SPZ v3 - Splat"

Babylon.js loads the SPZ decoder by passing inline ES-module source (import createSpzModule from '<url>'; ...) to Tools.LoadScript with useModule. Babylon Native has no ES module loader, so this fails. While installed, the workaround wraps Tools.LoadScript for module loads only:

  • Each default import is fetched. It must end in a single export default name; anything else is rejected.
  • import.meta.url is bound to the module's URL, and the module is evaluated with Function.
  • The rest of the inline body runs as an async function.

The original LoadScript is restored after each test.

Both SPZ tests stay excluded on JavaScriptCore. On the Linux JSC CI jobs the SPZ decoder module never finishes loading, so createScene times out after 600 s and the job hits its time limit.

global-self — "GUI Input Test"

Babylon Native doesn't define self. When an InputText takes focus, AdvancedDynamicTexture.registerClipboardEvents calls self.addEventListener and throws a ReferenceError. For the duration of the test the workaround defines self as the polyfilled window.

Reference images

gsplat-spz-sh.png, gsplat-spz-v3.png and guiInputTest.png are synced to the current Babylon.js references. The old copies predate Babylon.js rendering changes. For example, SPZ v3 differs by 5.4% from the old reference but matches the current one exactly.

Testing

Win32 D3D11 / V8 with the npm babylonjs 9.29.0 bundles: all 474 enabled tests pass, including the three newly enabled ones (SPZ SH 0.029%, SPZ v3 0%, GUI Input 2.1%).

Copilot AI balanced review requested due to automatic review settings October 21, 2026 23:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The global-self workaround needs to remove test-added clipboard listeners so they do not retain disposed GUI objects across tests.

1 open issue
What changed in this PR

Enables three previously excluded validation tests through opt-in harness workarounds for browser features missing from Babylon Native.

Changes:

  • Adds limited ES-module loading support for the two SPZ tests.
  • Temporarily defines self for the GUI Input test.
  • Documents both workarounds and enables the affected tests.
File Description
Documentation/​AddingNewValidationTests.md Documents the new workarounds and their limits.
Apps/​Playground/​Scripts/​validation_native.js Implements and restores the per-test workarounds.
Apps/​Playground/​Scripts/​config.json Enables three tests with their required workarounds.

Review effort: Balanced

Comment thread Apps/Playground/Scripts/validation_native.js
Babylon.js loads the SPZ decoder (and Manifold/recast) by handing inline ES
module source such as `import createSpzModule from '<url>'; ...await ...` to
Tools.LoadScript with useModule. Browsers run that as <script type="module">;
Babylon Native's script hosts have no ES module loader, so upstream
Tools._LoadScriptNative rejects it and the "Gaussian Splatting SPZ SH" and
"SPZ v3 - Splat" tests cannot decode their splats.

Rather than add a partial ES-module evaluator to Babylon.js core, keep the
shim in the test harness, opt-in per test like the other workarounds. While
installed it wraps Tools.LoadScript for module loads only: each default import
is fetched, must end in a sole `export default name` (Emscripten EXPORT_ES6
output, as @adobe/spz ships), has import.meta.url bound to its URL, and is
evaluated with Function; the remaining inline source runs as an async function
with the imports as parameters. Any other module syntax is rejected instead of
being misread. Non-module loads go to the original LoadScript, and the
original is restored after each test.

The gsplat-spz-sh.png and gsplat-spz-v3.png references are synced to the
current Babylon.js ones; the old copies predate a Babylon.js splat rendering
change, so SPZ v3 differs by 5.4% against them even when it renders exactly
like Babylon.js (no pixel difference against the current reference).

Both SPZ tests stay excluded on JavaScriptCore: on the Linux JSC CI job the
SPZ decoder module never finishes loading and createScene times out after
600s, which pushed the job past its time limit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae
@bkaradzic-microsoft
bkaradzic-microsoft force-pushed the es-module-import-workaround branch from fc7b076 to d7e268e Compare October 22, 2026 00:19
Browsers and workers define the global `self`; Babylon Native does not.
When an InputText takes focus, AdvancedDynamicTexture.registerClipboardEvents
calls self.addEventListener, so "GUI Input Test" throws
"ReferenceError: self is not defined" from the render loop and fails.

Rather than carry a Babylon.js GUI change only for this test, add an opt-in
harness workaround (tracked as a bug to fix properly later): while the test
runs, `self` is defined as the polyfilled window, which already provides
addEventListener/removeEventListener, and it is removed afterwards. Other
tests keep the host's real globals.

Verified with a babylon.gui.js that has the original self.addEventListener
code: the test passes with the same pixel difference as with the Babylon.js fix,
and the full 714-test sweep has no other self failures. The test is enabled,
and guiInputTest.png is synced to the current Babylon.js reference.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae
@bkaradzic-microsoft
bkaradzic-microsoft force-pushed the es-module-import-workaround branch from d7e268e to c5e9327 Compare October 22, 2026 00:52

@bghgary bghgary left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[Reviewed by Copilot on behalf of @bghgary]

LGTM

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.

3 participants