Failure/Error: TypeError: Cannot read property 'trackUbosInFrame' of undefined

We are running specs against preview.

Yesterday all of them failed with

Cannot read property 'trackUbosInFrame' of undefined.

I switched back to 4.2.0 and all the tests passed as usual, but I decided to report to understand if this is an expected behavior.

We are not touching trackUbosInFrame in any way and this property is not familiar to me. We are mostly loading files.

Thanks

This sounds bad and might be related to our latest merges @Evgeni_Popov ?

@kmitov it is impossible to fix without a repro unfortunately :frowning: could you share one in the playground ? Or online with a none minified version ?

It would seem your are using uniform buffers (so most probably materials) before the engine is fully initialized…

Another possibility is that you used the new WebGPU engine but tested it in a browser that does not support it, but I don’t think you did that(?)

I’ve reproduced it

      const engine = new BABYLON.Engine();
      this.scene = new BABYLON.Scene(engine);

and the error is

TypeError: Cannot read property 'trackUbosInFrame' of undefined
    at new e (https://preview.babylonjs.com/babylon.js:16:635642)
    at t._createUbo (https://preview.babylonjs.com/babylon.js:16:237048)
    at new t (https://preview.babylonjs.com/babylon.js:16:226446)
    ...

I now see that in some specs we construct the Engine without a canvas. We don’t nee a canvas for this spec and for many of the specs. There are no materials involved in the spec. The whole spec after that is

      this.scene = new BABYLON.Scene(engine);
      this.stepBabylonNode = new BABYLON.Node("node", this.scene);
      this.stepBabylonNode.metadata = {
        ...
      };

      const node = this.scene.getNodeByID("node")
      expect(...that we can read metadata from the node...)

I checked if the constructor for Engine requires a canvas and it is

new Engine(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>,

It is Nullable. It should be possible to pass null?

Thanks.
I would try to reproduce it in playground, I will have to see how to construct an engine there .

Here it is reproduced in playground

TypeError: Cannot read property 'trackUbosInFrame' of undefined
    at new e (babylon.js:16)
    at t._createUbo (babylon.js:16)
    at new t (babylon.js:16)
    at createScene (<anonymous>:4:17)
    at <anonymous>:40:9
    at Function.e.FastEval (babylon.playground.js:16)
    at t.<anonymous> (babylon.playground.js:16)
    at babylon.playground.js:16
    at Object.next (babylon.playground.js:16)
    at s (babylon.playground.js:16)

Actually a canvas is required and if you do not intent to use it you should use a NullEngine.

1 Like

Thanks. I will.

@Evgeni_Popov

Is this still an issue in 5.0.0-alpha.5? I’m trying to test WebGPUEngine in Chrome Canary (Version 89.0.4358.2 (Official Build) canary (arm64)) - I have #enable-unsafe-webgpu enabled & some other WebGPU sample pages work without issues.

Repro here - Babylon.js Playground passing in the existing canvas to WebGPUEngine as well.

I was able to repro w/ an x86_64 build of Chrome Canary on another machine as well, so I don’t believe its due to arm architecture differences.

But you are not waiting for engine.initAsync which is mandatory in WebGPU ?

1 Like

Yep that resolves this property issue - I must have missed reading about await engine.initAsync();.

Updated playground fixing initAsync here https://playground.babylonjs.com/#KKHTA3#1 - it doesn’t render probably because playground isn’t meant to have an async createScene fn.

I would advise you to wait on the final support for webgpu as it is currently not available in playground and here you are trying to use is on an engine with a webglcontext already created. You won t be able to use it in the playground like this.

2 Likes

Can you explain how did you fix it?

Update: I think I figured it out. The problem was that my script was trying to create an engine before the canvas required was loaded. So I edited it so that the script loads after all the document elements has been finished loading or created.

1 Like