浏览代码

Fix crash issue with edge whe context is restored

David Catuhe 8 年之前
父节点
当前提交
95215dccac

文件差异内容过多而无法显示
+ 3700 - 3700
dist/preview release/babylon.d.ts


文件差异内容过多而无法显示
+ 2 - 2
dist/preview release/babylon.js


+ 16 - 13
dist/preview release/babylon.max.js

@@ -7781,19 +7781,22 @@ var BABYLON;
                         _this.onContextLostObservable.notifyObservers(_this);
                     };
                     this._onContextRestored = function (evt) {
-                        // Rebuild gl context
-                        _this._initGLContext();
-                        // Rebuild effects
-                        _this._rebuildEffects();
-                        // Rebuild textures
-                        _this._rebuildInternalTextures();
-                        // Rebuild buffers
-                        _this._rebuildBuffers();
-                        // Cache
-                        _this.wipeCaches(true);
-                        BABYLON.Tools.Warn("WebGL context successfully restored.");
-                        _this.onContextRestoredObservable.notifyObservers(_this);
-                        _this._contextWasLost = false;
+                        // Adding a timeout to avoid race condition at browser level
+                        setTimeout(function () {
+                            // Rebuild gl context
+                            _this._initGLContext();
+                            // Rebuild effects
+                            _this._rebuildEffects();
+                            // Rebuild textures
+                            _this._rebuildInternalTextures();
+                            // Rebuild buffers
+                            _this._rebuildBuffers();
+                            // Cache
+                            _this.wipeCaches(true);
+                            BABYLON.Tools.Warn("WebGL context successfully restored.");
+                            _this.onContextRestoredObservable.notifyObservers(_this);
+                            _this._contextWasLost = false;
+                        }, 0);
                     };
                     canvas.addEventListener("webglcontextlost", this._onContextLost, false);
                     canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);

文件差异内容过多而无法显示
+ 3700 - 3700
dist/preview release/babylon.module.d.ts


文件差异内容过多而无法显示
+ 2 - 2
dist/preview release/babylon.worker.js


文件差异内容过多而无法显示
+ 7165 - 7165
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


文件差异内容过多而无法显示
+ 2 - 2
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 16 - 13
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -7781,19 +7781,22 @@ var BABYLON;
                         _this.onContextLostObservable.notifyObservers(_this);
                     };
                     this._onContextRestored = function (evt) {
-                        // Rebuild gl context
-                        _this._initGLContext();
-                        // Rebuild effects
-                        _this._rebuildEffects();
-                        // Rebuild textures
-                        _this._rebuildInternalTextures();
-                        // Rebuild buffers
-                        _this._rebuildBuffers();
-                        // Cache
-                        _this.wipeCaches(true);
-                        BABYLON.Tools.Warn("WebGL context successfully restored.");
-                        _this.onContextRestoredObservable.notifyObservers(_this);
-                        _this._contextWasLost = false;
+                        // Adding a timeout to avoid race condition at browser level
+                        setTimeout(function () {
+                            // Rebuild gl context
+                            _this._initGLContext();
+                            // Rebuild effects
+                            _this._rebuildEffects();
+                            // Rebuild textures
+                            _this._rebuildInternalTextures();
+                            // Rebuild buffers
+                            _this._rebuildBuffers();
+                            // Cache
+                            _this.wipeCaches(true);
+                            BABYLON.Tools.Warn("WebGL context successfully restored.");
+                            _this.onContextRestoredObservable.notifyObservers(_this);
+                            _this._contextWasLost = false;
+                        }, 0);
                     };
                     canvas.addEventListener("webglcontextlost", this._onContextLost, false);
                     canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);

文件差异内容过多而无法显示
+ 7165 - 7165
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts


+ 16 - 13
src/babylon.engine.ts

@@ -842,26 +842,29 @@
                     };
 
                     this._onContextRestored = (evt: Event) => {
-                        // Rebuild gl context
-                        this._initGLContext();
+                        // Adding a timeout to avoid race condition at browser level
+                        setTimeout(()=> {
+                            // Rebuild gl context
+                            this._initGLContext();
 
-                        // Rebuild effects
-                        this._rebuildEffects();
+                            // Rebuild effects
+                            this._rebuildEffects();
 
-                        // Rebuild textures
-                        this._rebuildInternalTextures();
+                            // Rebuild textures
+                            this._rebuildInternalTextures();
 
-                        // Rebuild buffers
-                        this._rebuildBuffers();
+                            // Rebuild buffers
+                            this._rebuildBuffers();
 
-                        // Cache
-                        this.wipeCaches(true);
+                            // Cache
+                            this.wipeCaches(true);
 
-                        Tools.Warn("WebGL context successfully restored.");
+                            Tools.Warn("WebGL context successfully restored.");
 
-                        this.onContextRestoredObservable.notifyObservers(this);
+                            this.onContextRestoredObservable.notifyObservers(this);
 
-                        this._contextWasLost = false;
+                            this._contextWasLost = false;
+                        }, 0);
                     };
 
                     canvas.addEventListener("webglcontextlost", this._onContextLost, false);