aboutsummaryrefslogtreecommitdiff
path: root/src/library_browser.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-12-07 10:37:25 -0500
committerAlon Zakai <alonzakai@gmail.com>2013-12-07 10:37:25 -0500
commit1a007b1631509b9d72499a8f4402294017ee04dc (patch)
tree92f8b0341497c7bd4e53aa82c690346536a244c3 /src/library_browser.js
parentdf11c6f1fd1636a355b83a1c48b3a890596e6a32 (diff)
parenteb083723747a90cb6ab9853fec8d6e8ef54748bc (diff)
Merge branch 'incoming'
Diffstat (limited to 'src/library_browser.js')
-rw-r--r--src/library_browser.js19
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--;
}