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

**URL:** <https://forum.babylonjs.com/t/failure-error-typeerror-cannot-read-property-trackubosinframe-of-undefined/16087>\
**Category:** Bugs\
**Created:** [November 27, 2020, 4:50pm UTC](https://forum.babylonjs.com/t/failure-error-typeerror-cannot-read-property-trackubosinframe-of-undefined/16087 "2020-11-27T16:50:02Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![kmitov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kmitov/32/4969_2.png) [@kmitov](https://forum.babylonjs.com/u/kmitov)\
**Post date:** [November 27, 2020, 4:50pm UTC](https://forum.babylonjs.com/t/failure-error-typeerror-cannot-read-property-trackubosinframe-of-undefined/16087/1 "2020-11-27T16:50:02Z")

</div>

We are running specs against preview.

Yesterday all of them failed with

```auto
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

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [November 27, 2020, 5:06pm UTC](https://forum.babylonjs.com/t/failure-error-typeerror-cannot-read-property-trackubosinframe-of-undefined/16087/2 "2020-11-27T17:06:52Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [November 27, 2020, 5:30pm UTC](https://forum.babylonjs.com/t/failure-error-typeerror-cannot-read-property-trackubosinframe-of-undefined/16087/3 "2020-11-27T17:30:14Z")

</div>

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(?)

---

<div class="post-metadata">

**Author:** ![kmitov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kmitov/32/4969_2.png) [@kmitov](https://forum.babylonjs.com/u/kmitov)\
**Post date:** [November 28, 2020, 7:55am UTC](https://forum.babylonjs.com/t/failure-error-typeerror-cannot-read-property-trackubosinframe-of-undefined/16087/4 "2020-11-28T07:55:44Z")

</div>

I’ve reproduced it

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

```

and the error is

```auto
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

```auto
      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

```auto
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 .

---

<div class="post-metadata">

**Author:** ![kmitov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kmitov/32/4969_2.png) [@kmitov](https://forum.babylonjs.com/u/kmitov)\
**Post date:** [November 28, 2020, 7:58am UTC](https://forum.babylonjs.com/t/failure-error-typeerror-cannot-read-property-trackubosinframe-of-undefined/16087/5 "2020-11-28T07:58:33Z")

</div>

Here it is reproduced in playground

> **[Babylon.js Playground](https://playground.babylonjs.com/#43XKM7)**

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [November 28, 2020, 10:32am UTC](https://forum.babylonjs.com/t/failure-error-typeerror-cannot-read-property-trackubosinframe-of-undefined/16087/6 "2020-11-28T10:32:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kmitov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kmitov/32/4969_2.png) [@kmitov](https://forum.babylonjs.com/u/kmitov)\
**Post date:** [November 28, 2020, 11:10am UTC](https://forum.babylonjs.com/t/failure-error-typeerror-cannot-read-property-trackubosinframe-of-undefined/16087/7 "2020-11-28T11:10:21Z")

</div>

Thanks. I will.

---

<div class="post-metadata">

**Author:** ![flux159](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/flux159/32/12112_2.png) [@flux159](https://forum.babylonjs.com/u/flux159)\
**Post date:** [December 21, 2020, 6:11pm UTC](https://forum.babylonjs.com/t/failure-error-typeerror-cannot-read-property-trackubosinframe-of-undefined/16087/8 "2020-12-21T18:11:32Z")

</div>

@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](https://austineng.github.io/webgpu-samples/?wgsl=0#twoCubes) work without issues.

Repro here - [Babylon.js Playground](https://playground.babylonjs.com/#KKHTA3) 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.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [December 21, 2020, 6:17pm UTC](https://forum.babylonjs.com/t/failure-error-typeerror-cannot-read-property-trackubosinframe-of-undefined/16087/9 "2020-12-21T18:17:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![flux159](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/flux159/32/12112_2.png) [@flux159](https://forum.babylonjs.com/u/flux159)\
**Post date:** [December 21, 2020, 6:27pm UTC](https://forum.babylonjs.com/t/failure-error-typeerror-cannot-read-property-trackubosinframe-of-undefined/16087/10 "2020-12-21T18:27:11Z")

</div>

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](https://playground.babylonjs.com/#KKHTA3#1) - it doesn’t render probably because playground isn’t meant to have an async createScene fn.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [December 21, 2020, 6:29pm UTC](https://forum.babylonjs.com/t/failure-error-typeerror-cannot-read-property-trackubosinframe-of-undefined/16087/11 "2020-12-21T18:29:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![\_Cri5](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/_cri5/32/13066_2.png) [@\_Cri5](https://forum.babylonjs.com/u/_Cri5)\
**Post date:** [December 23, 2020, 5:11am UTC](https://forum.babylonjs.com/t/failure-error-typeerror-cannot-read-property-trackubosinframe-of-undefined/16087/12 "2020-12-23T05:11:45Z")

</div>

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.
