diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-22 17:19:14 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-22 17:19:14 -0800 |
commit | b988457c13f77f50e03b4e46fbef4d5e42cfcf33 (patch) | |
tree | d68348acae99a30bb855d84173b6e24ba9a1b9cc /src/library_browser.js | |
parent | ccb6463185a4f60a50fdfb5da34489eadf0188f2 (diff) |
listen to webglcontextcreationerror for information; fixes #1846
Diffstat (limited to 'src/library_browser.js')
-rw-r--r-- | src/library_browser.js | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/library_browser.js b/src/library_browser.js index 8444fb73..fbc609d7 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -250,15 +250,24 @@ mergeInto(LibraryManager.library, { contextAttributes.preserveDrawingBuffer = true; #endif - ['experimental-webgl', 'webgl'].some(function(webglId) { - return ctx = canvas.getContext(webglId, contextAttributes); - }); + var errorInfo = '?'; + function onContextCreationError(event) { + errorInfo = e.statusMessage || errorInfo; + } + canvas.addEventListener('webglcontextcreationerror', onContextCreationError, false); + try { + ['experimental-webgl', 'webgl'].some(function(webglId) { + return ctx = canvas.getContext(webglId, contextAttributes); + }); + } finally { + canvas.removeEventListener('webglcontextcreationerror', onContextCreationError, false); + } } else { ctx = canvas.getContext('2d'); } if (!ctx) throw ':('; } catch (e) { - Module.print('Could not create canvas - ' + e); + Module.print('Could not create canvas: ' + [errorInfo, e]); return null; } if (useWebGL) { |