Issue with double engine instancing after creating a screenshot

Hello all,

I am currently working on upgrading my project from babylonjs version 6.43.0 to version 7.5.0. and i’m encountering a issue:

The issue started when i tried to use some functionality to show gui elements when hovering over a mesh.
I get the error: ‘Uncaught Error: getFontOffset is not implemented’.

The scene will also turn white on WebGPU or the default background color on WebGL2.

After some debugging i found out that my project was creating 2 engines:

The first engine that is created is the one i have setup myself.

The second engine i think is created during the flow off the Tools.CreateScreenshotUsingRenderTargetAsync().
More specific when the function _createDumpRenderer is triggerd from the DumpTools class.
This function creates a new engine that is then used when adding a TextBlock to a Rectangle as a control and results in the error: ‘Uncaught Error: getFontOffset is not implemented’ .

I have reproduced the issue in this playground:

The app will throw the ‘getFontOffset is not implemented’ error when hovering over the sphere.

Note: If you where to push the run button after a refresh and before hovering over the sphere, it will work as intened.

When starting from a fresh page and you look at the console:
You can see that there are 2 engines created.

When i comment out the function BABYLON.Tools.CreateScreenshotUsingRenderTargetAsync() only one engine is created.

I have created this playground where the line to create the screenshot has been commented out:

Did i find a issue or am i using the screenshot tool incorrect?

(extra note: The playgrounds are setup starting on webGPU. If you would like to test it with webGL2 you need to open a new playground and paste the code there and push the run button once. If you where to press the run button twice it will work as intended.)

Thanks in advance!

Oh, nice bug you caught there!!!

The main problem is that the ADT is using the latest created engine to get the font offset. It is true that a new engine is created to create the snapshot (and that hasn’t changed), but it shouldn’t use this engine for anything else other than the screennshot process. Try running the playground again - it will work then. Because there is no need for an extra engine, as the static engine for the screenshot process was already created. I will submit a PR to fix that very soon!

1 Like

This PR has two fixes for the issue - Fix GetFontOffset missing in ThinEngine by RaananW · Pull Request #15058 · BabylonJS/Babylon.js (github.com) . Waiting for reviews :slight_smile:

1 Like

Thanks for the quick response!

1 Like