diff --git a/src/mol-canvas3d/canvas3d.ts b/src/mol-canvas3d/canvas3d.ts
index 9176c5338b899c06e3c343213ee7e43219b96ce2..b04242f6f634ca315874c280748c0a2b3c2e1f89 100644
--- a/src/mol-canvas3d/canvas3d.ts
+++ b/src/mol-canvas3d/canvas3d.ts
@@ -135,7 +135,7 @@ interface Canvas3D {
readonly stats: RendererStats
readonly interaction: Canvas3dInteractionHelper['events']
- dispose(): void
+ dispose(options?: { doNotForceWebGLContextLoss?: boolean }): void
}
const requestAnimationFrame = typeof window !== 'undefined'
@@ -705,7 +705,7 @@ namespace Canvas3D {
get interaction() {
return interactionHelper.events;
},
- dispose: () => {
+ dispose: (options?: { doNotForceWebGLContextLoss?: boolean }) => {
contextRestoredSub.unsubscribe();
scene.clear();
@@ -715,7 +715,7 @@ namespace Canvas3D {
renderer.dispose();
interactionHelper.dispose();
- gl.getExtension('WEBGL_lose_context')?.loseContext();
+ if (!options?.doNotForceWebGLContextLoss) gl.getExtension('WEBGL_lose_context')?.loseContext();
}
};
diff --git a/src/mol-plugin/context.ts b/src/mol-plugin/context.ts
index cc94a312f9466a42af545d4e3bd7d87d93287975..1d785a6c95632383174f58d642ab4cb631e8c982 100644
--- a/src/mol-plugin/context.ts
+++ b/src/mol-plugin/context.ts
@@ -256,10 +256,10 @@ export class PluginContext {
return PluginCommands.State.RemoveObject(this, { state: this.state.data, ref: StateTransform.RootRef });
}
- dispose() {
+ dispose(options?: { doNotForceWebGLContextLoss?: boolean }) {
if (this.disposed) return;
this.commands.dispose();
- this.canvas3d?.dispose();
+ this.canvas3d?.dispose(options);
this.ev.dispose();
this.state.dispose();
this.managers.task.dispose();