Skip to content

Commit 398f8cc

Browse files
committed
try...catch on destroying PIXI app
the destroy method doesn't check if its stage has already been destroyed so it will throw if we try to destroy twice
1 parent 7680a88 commit 398f8cc

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/components/Export.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,9 @@ const Def = class Export extends React.Component {
513513
if (draw.destroy) {
514514
draw.destroy();
515515
}
516-
app.destroy();
516+
try {
517+
app.destroy();
518+
} catch (e) {}
517519
}, mime);
518520
}
519521

@@ -729,7 +731,9 @@ const Def = class Export extends React.Component {
729731
if (draw.destroy) {
730732
draw.destroy();
731733
}
732-
app.destroy();
734+
try {
735+
app.destroy();
736+
} catch (e) {}
733737
};
734738

735739
me.frameId = requestIdleCallback(renderFrames);

src/components/Sketch.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ const Def = class Sketch extends React.Component {
215215
view = this.pixiApp.renderer.view;
216216
context = this.pixiApp.renderer.context;
217217

218-
this.pixiApp.destroy();
218+
try {
219+
this.pixiApp.destroy();
220+
} catch (e) {}
219221
}
220222

221223
const pixiOptions = assign({}, defaultPixiOptions, {
@@ -262,7 +264,9 @@ const Def = class Sketch extends React.Component {
262264
if (context) {
263265
contexts.push(context);
264266
}
265-
this.pixiApp.destroy();
267+
try {
268+
this.pixiApp.destroy();
269+
} catch (e) {}
266270
this.pixiApp = null;
267271
}
268272
}

0 commit comments

Comments
 (0)