Issue with recent dumpTools changes in web worker context

Hello babylonjs !

The recent 8.35.0 babylonjs release brought changes to the dumpTools.ts file which have had unfortunate consequences on our project.

The issue is that when we’re in a web worker context. The window object is thus undefined.

Therefore, the thinEngine.IsSupported method can not return true because of this condition: !!window.WebGLRenderingContext.

And so this recently added error message pops : DumpData: No WebGL context available. Cannot dump data.

The mentioned isSupported method :

    public static isSupported(): boolean {
        if (this._HasMajorPerformanceCaveat !== null) {
            return !this._HasMajorPerformanceCaveat;
        }

        if (this._IsSupported === null) {
            try {
                const tempcanvas = AbstractEngine._CreateCanvas(1, 1);
                const gl = tempcanvas.getContext("webgl") || (tempcanvas as any).getContext("experimental-webgl");

                this._IsSupported = gl != null && !!window.WebGLRenderingContext;
            } catch (e) {
                this._IsSupported = false;
            }
        }

        return this._IsSupported;
    }

Thanks in advance for looking at this issue.

1 Like

cc @alexchuber

Thanks for the report!

For reference, this is the repro I used to test: Babylon.js Playground

3 Likes