@babylonjs/core 7.39.2 → 7.39.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -184,16 +184,22 @@ export class ThinEngine extends AbstractEngine {
184
184
  this._onContextLost = (evt) => {
185
185
  evt.preventDefault();
186
186
  this._contextWasLost = true;
187
+ deleteStateObject(this._gl);
187
188
  Logger.Warn("WebGL context lost.");
188
189
  this.onContextLostObservable.notifyObservers(this);
189
190
  };
190
191
  this._onContextRestored = () => {
191
192
  this._restoreEngineAfterContextLost(() => this._initGLContext());
192
193
  };
193
- canvas.addEventListener("webglcontextlost", this._onContextLost, false);
194
194
  canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
195
195
  options.powerPreference = options.powerPreference || "high-performance";
196
196
  }
197
+ else {
198
+ this._onContextLost = () => {
199
+ deleteStateObject(this._gl);
200
+ };
201
+ }
202
+ canvas.addEventListener("webglcontextlost", this._onContextLost, false);
197
203
  if (this._badDesktopOS) {
198
204
  options.xrCompatible = false;
199
205
  }
@@ -3229,8 +3235,8 @@ export class ThinEngine extends AbstractEngine {
3229
3235
  // Events
3230
3236
  if (IsWindowObjectExist()) {
3231
3237
  if (this._renderingCanvas) {
3232
- if (!this._doNotHandleContextLost) {
3233
- this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
3238
+ this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
3239
+ if (this._onContextRestored) {
3234
3240
  this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
3235
3241
  }
3236
3242
  }