Skip to content

Playground validation: fix undefined renderImage in the scriptToRun path - #1822

Merged
bkaradzic-microsoft merged 1 commit into
BabylonJS:masterfrom
bkaradzic-microsoft:fix-validation-renderimage
Aug 7, 2026
Merged

Playground validation: fix undefined renderImage in the scriptToRun path#1822
bkaradzic-microsoft merged 1 commit into
BabylonJS:masterfrom
bkaradzic-microsoft:fix-validation-renderimage

Conversation

@bkaradzic-microsoft

Copy link
Copy Markdown
Member

Problem

loadPlayground declares its third parameter as referenceImage:

function loadPlayground(test, done, referenceImage, compareFunction) {

but the test.scriptToRun branch passes renderImage:

setTimeout(function () {
    try {
        currentScene = eval(scriptCode);
        processCurrentScene(test, renderImage, done, compareFunction);   // <-- not in scope

renderImage is not bound in that scope. It is only the parameter name of
processCurrentScene(test, renderImage, done, compareFunction). So the moment
a scriptToRun scene is evaluated, the call throws
ReferenceError: renderImage is not defined, the enclosing catch logs it,
and the test is marked failed.

Every other call site in loadPlayground already passes referenceImage,
and processCurrentScene forwards the argument straight through to
evaluateScreenshot(test, screenshot, renderImage, ...) where it is used as
the reference image to compare against. referenceImage is clearly the
intended value.

Why this was never noticed

The scriptToRun tests could not reach this line. They wait on
request.onreadystatechange, and the JsRuntimeHost XMLHttpRequest
polyfill never invokes it -- RaiseEvent only dispatches handlers registered
via addEventListener, and there are no on<event> property accessors at
all. So the request completed (readyState 4, status 200) but the
callback never ran and the test hung until the harness timeout.

That is fixed separately in BabylonJS/JsRuntimeHost#TBD. With the polyfill fixed,
these tests finally get as far as evaluating the scene -- and immediately hit
this ReferenceError.

Effect

Tests affected: Fog, Polygon, Lines, Lens, Self shadowing, GUI, Procedural
textures. They are currently excluded on every graphics API (D3D11, D3D12,
OpenGL, Vulkan, Metal, WebGPU) because they hang, so this is not WebGPU/Dawn
specific -- it affects every rendering backend.

With this fix plus the JsRuntimeHost one, locally:

Test Before After
Fog hang pass
Lines hang pass
Lens hang pass
Self shadowing hang pass
Polygon hang fails fast (earcut is not defined)
GUI hang fails fast (pixel diff 10.3%)
Procedural textures hang fails fast (name is not defined)

The three remaining failures are separate, unrelated issues that were previously
invisible; they now surface as fast, actionable errors instead of a hang.

… path

`loadPlayground` declares its third parameter as `referenceImage`, but the
`test.scriptToRun` branch passes `renderImage` to `processCurrentScene`.
`renderImage` is not bound in that scope, so as soon as the scene script is
evaluated the call throws `ReferenceError: renderImage is not defined`, the
surrounding catch reports it, and the test fails.

Every other call site in `loadPlayground` already passes `referenceImage`,
and `processCurrentScene` forwards the argument straight to
`evaluateScreenshot(test, screenshot, renderImage, ...)` as the reference
image to compare against -- so `referenceImage` is the intended value.

This was latent until now: the `scriptToRun` tests could never reach this
line, because they wait on `request.onreadystatechange`, which the
JsRuntimeHost XMLHttpRequest polyfill never invokes (it only dispatches
handlers registered through `addEventListener`). Those tests therefore hung
until the harness timeout rather than running, which is why they are currently
excluded on every graphics API. With that polyfill gap fixed in JsRuntimeHost,
the tests get this far and immediately hit the ReferenceError.

With both fixed, Fog, Lines, Lens and Self shadowing pass; Polygon, GUI and
Procedural textures now fail fast with actionable, unrelated errors instead of
hanging.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 88569c10-a7ff-4373-9a58-afa9c68b8c09
Copilot AI lite review requested due to automatic review settings August 6, 2026 23:31

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.

Pull request overview

Fixes a runtime ReferenceError in the native playground validation harness when running tests via the scriptToRun path by passing the correct in-scope reference image argument into processCurrentScene.

Changes:

  • Replace an out-of-scope renderImage identifier with referenceImage in the test.scriptToRun execution branch.
  • Align the scriptToRun branch with the other loadPlayground call sites that already pass referenceImage through to screenshot comparison.

@bkaradzic-microsoft
bkaradzic-microsoft enabled auto-merge (squash) August 7, 2026 04:36
@bkaradzic-microsoft
bkaradzic-microsoft merged commit 04448f2 into BabylonJS:master Aug 7, 2026
34 checks passed
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.

4 participants