diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-12-07 10:37:25 -0500 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-12-07 10:37:25 -0500 |
commit | 1a007b1631509b9d72499a8f4402294017ee04dc (patch) | |
tree | 92f8b0341497c7bd4e53aa82c690346536a244c3 /src/library_browser.js | |
parent | df11c6f1fd1636a355b83a1c48b3a890596e6a32 (diff) | |
parent | eb083723747a90cb6ab9853fec8d6e8ef54748bc (diff) |
Merge branch 'incoming'
Diffstat (limited to 'src/library_browser.js')
-rw-r--r-- | src/library_browser.js | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/library_browser.js b/src/library_browser.js index 8444fb73..b368c6ac 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 = event.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) { @@ -854,7 +863,7 @@ mergeInto(LibraryManager.library, { var styleSheet = document.styleSheets[0]; var rules = styleSheet.cssRules; for (var i = 0; i < rules.length; i++) { - if (rules[i].cssText.substr(0, 5) == 'canvas') { + if (rules[i].cssText.substr(0, 6) == 'canvas') { styleSheet.deleteRule(i); i--; } |