Offscreen canvas issue - document is not defined

I upgraded my repo from alpha 22 to alpha 38 today. Now I’m getting this error:

ReferenceError: document is not defined
    at Engine2.ThinEngine2._checkForMobile (thinEngine.ts:745)
    at Engine2.ThinEngine2 (thinEngine.ts:749)
    at new Engine2 (engine.ts:528)

I’m running my scene in an OffscreenCanvas worker where document is indeed not defined. I noticed these changes came in with these commits:

Is there any chance this could be fixed to work with Offscreen Canvas workers?

1 Like

On it

cc @PolygonalSun FYI

Will be on next nightly

2 Likes

@Deltakosh I also notice the offscreen demo is having an issue. Would any of these changes have affected the demo?

https://www.babylonjs.com/demos/offscreen/

Uncaught ReferenceError: window is not defined
at Function.get (babylon.js:16)
at new t (babylon.js:16)
at createScene (/demos/offscreen/index.js:3)
at onmessage (/demos/offscreen/worker.js:12)

This issue will be solved after this is merged and updated in the cdn - Fix window reference in computePressure by RaananW · Pull Request #10914 · BabylonJS/Babylon.js (github.com)

2 Likes

thanks @RaananW

You’re the man!