Exploding GLB Model Files

Hey guys, and I am looking into an issue which appeared over night with loading GLB models. The issue is an unusual one, as I have not touched the code related to loading files in a few days, and the LoadAssetContainerAsync function is completing and returning a container. I am working on building a useful case, but I am hoping that the error might be familiar to any of you.

Some ms after the LoadAssetContainer’s then call to console.log, I get the following error messages:

The scene contains two sphere models, and no textures. Scenes containing only cameras, have no problems to load.

(Pardon me for the long string):

Uncaught TypeError: engine._debugInsertMarker is not a function
node_modules main.ef096215e2b6c01fe72d.js:195880
expandRGBDTexture rgbdTextureTools.ts:73
node_modules main.ef096215e2b6c01fe72d.js:115724
expandRGBDTexture rgbdTextureTools.ts:67
node_modules main.ef096215e2b6c01fe72d.js:162615
load texture.ts:357
node_modules main.ef096215e2b6c01fe72d.js:162615
node_modules main.ef096215e2b6c01fe72d.js:56489
node_modules main.ef096215e2b6c01fe72d.js:56522
onload_1 thinEngine.ts:3278
loadHandler fileTools.ts:190
node_modules main.ef096215e2b6c01fe72d.js:160104
node_modules main.ef096215e2b6c01fe72d.js:56128
node_modules main.ef096215e2b6c01fe72d.js:56167
Texture texture.ts:378
node_modules main.ef096215e2b6c01fe72d.js:113812
node_modules main.ef096215e2b6c01fe72d.js:157510
PBRBaseMaterial pbrBaseMaterial.ts:895
PBRMaterial pbrMaterial.ts:754
node_modules main.ef096215e2b6c01fe72d.js:321313
node_modules main.ef096215e2b6c01fe72d.js:321338
node_modules main.ef096215e2b6c01fe72d.js:317302
node_modules main.ef096215e2b6c01fe72d.js:321801
node_modules main.ef096215e2b6c01fe72d.js:321763
node_modules main.ef096215e2b6c01fe72d.js:321801
node_modules main.ef096215e2b6c01fe72d.js:321333
node_modules main.ef096215e2b6c01fe72d.js:321286
node_modules main.ef096215e2b6c01fe72d.js:320464
node_modules main.ef096215e2b6c01fe72d.js:320384
node_modules main.ef096215e2b6c01fe72d.js:320355
node_modules main.ef096215e2b6c01fe72d.js:317287
node_modules main.ef096215e2b6c01fe72d.js:321786
node_modules main.ef096215e2b6c01fe72d.js:321763
node_modules main.ef096215e2b6c01fe72d.js:321786
node_modules main.ef096215e2b6c01fe72d.js:320317
node_modules main.ef096215e2b6c01fe72d.js:320180
node_modules main.ef096215e2b6c01fe72d.js:319997
promise callback*./node_modules/ main.ef096215e2b6c01fe72d.js:319976
node_modules main.ef096215e2b6c01fe72d.js:319951
promise callback*./node_modules/ main.ef096215e2b6c01fe72d.js:319927
node_modules main.ef096215e2b6c01fe72d.js:322563
promise callback*./node_modules/ main.ef096215e2b6c01fe72d.js:322523
node_modules main.ef096215e2b6c01fe72d.js:80516
dataCallback sceneLoader.ts:509
successCallback sceneLoader.ts:544
node_modules main.ef096215e2b6c01fe72d.js:322472
promise callback*./node_modules/ main.ef096215e2b6c01fe72d.js:322471
onReadyStateChange fileTools.ts:416
node_modules main.ef096215e2b6c01fe72d.js:169793
retryLoop fileTools.ts:442
requestFile fileTools.ts:447
node_modules main.ef096215e2b6c01fe72d.js:160341
node_modules main.ef096215e2b6c01fe72d.js:226527
node_modules main.ef096215e2b6c01fe72d.js:322644
node_modules main.ef096215e2b6c01fe72d.js:322466
manifestChecked sceneLoader.ts:552
node_modules main.ef096215e2b6c01fe72d.js:80080
node_modules main.ef096215e2b6c01fe72d.js:80504
node_modules main.ef096215e2b6c01fe72d.js:80543
node_modules main.ef096215e2b6c01fe72d.js:80542
loadSceneContainer asset-manager.js:207
node_modules main.ef096215e2b6c01fe72d.js:336582
node_modules main.ef096215e2b6c01fe72d.js:336578
loadSceneContainer asset-manager.js:205
loadSceneModel asset-manager.js:194
node_modules main.ef096215e2b6c01fe72d.js:336582
node_modules main.ef096215e2b6c01fe72d.js:336578
loadSceneModel asset-manager.js:179
loadDefaultScene service-injector.js:96
node_modules main.ef096215e2b6c01fe72d.js:336412
node_modules main.ef096215e2b6c01fe72d.js:336408
loadDefaultScene service-injector.js:81

postProcessManager.ts:118:23
directRender postProcessManager.ts:118
expandRGBDTexture rgbdTextureTools.ts:73
executeWhenCompiled effect.ts:510
expandRGBDTexture rgbdTextureTools.ts:67
notifyObservers observable.ts:336
load texture.ts:357
notifyObservers observable.ts:336
_prepareWebGLTextureContinuation thinEngine.ts:3698
_prepareWebGLTexture thinEngine.ts:3738
self-hosted:1173
onload_1 thinEngine.ts:3278
loadHandler fileTools.ts:190
(Async: EventListener.handleEvent)
LoadImage fileTools.ts:213
self-hosted:1173
_createTextureBase thinEngine.ts:3289
createTexture thinEngine.ts:3326
Texture texture.ts:378
CreateFromBase64String texture.ts:846
GetEnvironmentBRDFTexture brdfTextureTools.ts:29
PBRBaseMaterial pbrBaseMaterial.ts:895
PBRMaterial pbrMaterial.ts:754
_createDefaultMaterial glTFLoader.ts:1815
createMaterial glTFLoader.ts:1842
createMaterial ExtrasAsMetadata.ts:92
_extensionsCreateMaterial glTFLoader.ts:2378
_applyExtensions glTFLoader.ts:2330
_extensionsCreateMaterial glTFLoader.ts:2378
createMaterial glTFLoader.ts:1836
_loadMaterialAsync glTFLoader.ts:1779
_loadMeshPrimitiveAsync glTFLoader.ts:840
_loadMeshAsync glTFLoader.ts:750
loadNodeAsync glTFLoader.ts:713
loadNodeAsync ExtrasAsMetadata.ts:60
_extensionsLoadNodeAsync glTFLoader.ts:2358
_applyExtensions glTFLoader.ts:2330
_extensionsLoadNodeAsync glTFLoader.ts:2358
loadNodeAsync glTFLoader.ts:668
loadSceneAsync glTFLoader.ts:519
_loadAsync glTFLoader.ts:309
(Async: promise callback)
_loadAsync glTFLoader.ts:281
importMeshAsync glTFLoader.ts:257
(Async: promise callback)
importMeshAsync glTFLoader.ts:229
loadAssetContainerAsync glTFFileLoader.ts:637
(Async: promise callback)
loadAssetContainerAsync glTFFileLoader.ts:593
LoadAssetContainer sceneLoader.ts:1033
dataCallback sceneLoader.ts:509
successCallback sceneLoader.ts:544
requestFile glTFFileLoader.ts:539
(Async: promise callback)
requestFile glTFFileLoader.ts:538
onReadyStateChange fileTools.ts:416
(Async: EventListener.handleEvent)
addEventListener webRequest.ts:110
retryLoop fileTools.ts:442
requestFile fileTools.ts:447
RequestFile fileTools.ts:483
_requestFile scene.ts:4906
_requestFile glTFFileLoader.ts:728
requestFile glTFFileLoader.ts:533
manifestChecked sceneLoader.ts:552
_LoadData sceneLoader.ts:576
LoadAssetContainer sceneLoader.ts:1021
LoadAssetContainerAsync sceneLoader.ts:1056
LoadAssetContainerAsync sceneLoader.ts:1055
loadSceneContainer asset-manager.js:207

I upgraded recently to support some additional extensions, but was able to work without issue for some time after.

@babylonjs/core@5.0.0-alpha.22
@babylonjs/loaders@5.0.0-alpha.22

After some debugging I have located more clearly the source of the error:

In postProcessManager.ts there is a call to: engine._debugInsertMarker, which exists on ThinEngine but not the Engine instance available at scene creation time (prototype). Tracing backwards, it is being called during the creation of PBRMaterials when environment textures are generated (and call PostProcessManager.directRender). Commenting the line out returns functionality as expected.

The function is being added through engine.debugging.js, although it is not clear to me why it is missing from the engine prototype I am using. The engine is being created using the following calls:

const canvas = document.getElementById(“render-canvas”) as HTMLCanvasElement;
const engine = new Engine(canvas, true, {}, true);

None of these parts of the code have changed in months, and I have been using CreateSceneModule throughout to create scenes directly from the engine.

Robert

Pardon me, but that call fails everywhere it is being made.

I think you are using tree shaking? This PR should fix the problem:

I am using tree shaking, and thanks Evgeni.

r

Hey @Evgeni_Popov , and I have installed 5.0.0-alpha.24 which solves the issue as you expected. Thanks.

I am getting an error with the following code in defaultRenderingPipeline and am wondering if it is also being caused by tree shaking:

this._scene.enableDepthRenderer is not a function

Is it possible that this is being stripped out? I am enabling depthOfField from a json object which contains render settings, and it not being called in the code elsewhere.

r

I think you should import rendering/depthRendererSceneComponent. See Babylon.js ES6 support with Tree Shaking | Babylon.js Documentation

Thanks.