Crash when upgrading from 8.4.1 to 8.25.2 due to module import assumption

Great news, we shipped our Babylon.js WebXR application to the Meta Horizon store! We had to get very detailed with tree-shaking and imports to meet the app startup time requirements.

Good news, we finally figured out how to upgrade beyond v7.33 without breaking all our unit tests!

Bad news, v8.25.2 has a regression (introduced sometime after 8.4.1) where it assumes a module will be in place even though it’s not used in our app and therefore isn’t included in the bundle. This causes a crash on startup that we worked around by manually adding a no-op shim, but should be fixed upstream. I’d just post a PR for you all, but GitHub template says post here first :slight_smile:

In 8.25, ObjectRenderer.render unconditionally toggles outlineRenderer.enabled (for outlines) even if the OutlineRenderer class wasn’t imported in a modular bundle.

Our workaround diff (but this should really be fixed upstream):

// Babylon 8.25: ObjectRenderer.render toggles outlineRenderer.enabled even when outlineRenderer is not imported.
// In modular builds where '@babylonjs/core/Rendering/outlineRenderer' is not bundled, getOutlineRenderer is undefined.
// Provide a lightweight no-op shim to avoid runtime errors without pulling the full outline renderer into the bundle.

const anyScene = scene as any;
if (typeof anyScene.getOutlineRenderer !== 'function') {
  anyScene.getOutlineRenderer = () => ({ enabled: false });
}
1 Like

Congrats on the release!

cc @ryantrem for the import

In fact, outlineRenderer should be checked for non nullness before setting the property. This PR will fix the problem:

2 Likes

thanks!! :tada:

I was coming here to report the same thing but in 8.26.0 I guess we’ll have this patched in 8.26.1? :blush:

Correct :smiley:

1 Like