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 {
149
149
if ( this . glProgram )
150
150
return ;
151
151
152
+ // if the device is lost, silently ignore
153
+ const gl = device . gl ;
154
+ if ( gl . isContextLost ( ) ) {
155
+ return ;
156
+ }
157
+
152
158
let startTime = 0 ;
153
159
Debug . call ( ( ) => {
154
160
this . compileDuration = 0 ;
155
161
startTime = now ( ) ;
156
162
} ) ;
157
163
158
- const gl = device . gl ;
159
164
const glProgram = gl . createProgram ( ) ;
160
165
this . glProgram = glProgram ;
161
166
@@ -235,6 +240,11 @@ class WebglShader {
235
240
236
241
glShader = gl . createShader ( isVertexShader ? gl . VERTEX_SHADER : gl . FRAGMENT_SHADER ) ;
237
242
243
+ // if the device is lost, silently ignore
244
+ if ( ! glShader && gl . isContextLost ( ) ) {
245
+ return glShader ;
246
+ }
247
+
238
248
gl . shaderSource ( glShader , src ) ;
239
249
gl . compileShader ( glShader ) ;
240
250
@@ -268,11 +278,16 @@ class WebglShader {
268
278
*/
269
279
finalize ( device , shader ) {
270
280
281
+ // if the device is lost, silently ignore
282
+ const gl = device . gl ;
283
+ if ( gl . isContextLost ( ) ) {
284
+ return true ;
285
+ }
286
+
271
287
// if the program wasn't linked yet (shader was not created in batch)
272
288
if ( ! this . glProgram )
273
289
this . link ( device , shader ) ;
274
290
275
- const gl = device . gl ;
276
291
const glProgram = this . glProgram ;
277
292
const definition = shader . definition ;
278
293
You can’t perform that action at this time.
0 commit comments