Skip to content

Commit

Permalink
Make sure an engine with exception is cleared (#16151)
Browse files Browse the repository at this point in the history
  • Loading branch information
RaananW authored Feb 6, 2025
1 parent 8257a72 commit 8006d50
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/dev/core/src/Misc/dumpTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@ async function _CreateDumpRenderer(): Promise<DumpToolsEngine> {
};
import("../Engines/thinEngine")
.then(({ ThinEngine: thinEngineClass }) => {
const engineInstanceCount = EngineStore.Instances.length;
try {
canvas = new OffscreenCanvas(100, 100); // will be resized later
engine = new thinEngineClass(canvas, false, options);
} catch (e) {
if (engineInstanceCount < EngineStore.Instances.length) {
// The engine was created by another instance, let's use it
EngineStore.Instances.pop()?.dispose();
}
// The browser either does not support OffscreenCanvas or WebGL context in OffscreenCanvas, fallback on a regular canvas
canvas = document.createElement("canvas");
engine = new thinEngineClass(canvas, false, options);
Expand Down

0 comments on commit 8006d50

Please sign in to comment.