Browse Source

fix(WebGLTextures): iOS UIWebView OffscreenCanvas.getContext("2d")

cordova iOS (as of 5.0) still uses UIWebView,
which provides OffscreenCanvas,
also OffscreenCanvas.getContext("webgl"),
but not OffscreenCanvas.getContext("2d")!
Volker Buzek 6 years ago
parent
commit
18991001ff
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/renderers/webgl/WebGLTextures.js

+ 4 - 2
src/renderers/webgl/WebGLTextures.js

@@ -10,9 +10,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 	var _videoTextures = {};
 	var _canvas;
 
-	//
+	// cordova iOS (as of 5.0) still uses UIWebView, which provides OffscreenCanvas,
+	// also OffscreenCanvas.getContext("webgl"), but not OffscreenCanvas.getContext("2d")!
 
-	var useOffscreenCanvas = typeof OffscreenCanvas !== 'undefined';
+	var useOffscreenCanvas = typeof OffscreenCanvas !== 'undefined'
+		&& (new OffscreenCanvas(1, 1).getContext("2d")) !== null;
 
 	function createCanvas( width, height ) {