File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
src/platform/graphics/webgl Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -149,13 +149,18 @@ class WebglShader {
149149 if ( this . glProgram )
150150 return ;
151151
152+ // if the device is lost, silently ignore
153+ const gl = device . gl ;
154+ if ( gl . isContextLost ( ) ) {
155+ return ;
156+ }
157+
152158 let startTime = 0 ;
153159 Debug . call ( ( ) => {
154160 this . compileDuration = 0 ;
155161 startTime = now ( ) ;
156162 } ) ;
157163
158- const gl = device . gl ;
159164 const glProgram = gl . createProgram ( ) ;
160165 this . glProgram = glProgram ;
161166
@@ -235,6 +240,11 @@ class WebglShader {
235240
236241 glShader = gl . createShader ( isVertexShader ? gl . VERTEX_SHADER : gl . FRAGMENT_SHADER ) ;
237242
243+ // if the device is lost, silently ignore
244+ if ( ! glShader && gl . isContextLost ( ) ) {
245+ return glShader ;
246+ }
247+
238248 gl . shaderSource ( glShader , src ) ;
239249 gl . compileShader ( glShader ) ;
240250
@@ -268,11 +278,16 @@ class WebglShader {
268278 */
269279 finalize ( device , shader ) {
270280
281+ // if the device is lost, silently ignore
282+ const gl = device . gl ;
283+ if ( gl . isContextLost ( ) ) {
284+ return true ;
285+ }
286+
271287 // if the program wasn't linked yet (shader was not created in batch)
272288 if ( ! this . glProgram )
273289 this . link ( device , shader ) ;
274290
275- const gl = device . gl ;
276291 const glProgram = this . glProgram ;
277292 const definition = shader . definition ;
278293
You can’t perform that action at this time.
0 commit comments