aboutsummaryrefslogtreecommitdiff
path: root/src/library_browser.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-11-22 17:19:14 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-11-22 17:19:14 -0800
commitb988457c13f77f50e03b4e46fbef4d5e42cfcf33 (patch)
treed68348acae99a30bb855d84173b6e24ba9a1b9cc /src/library_browser.js
parentccb6463185a4f60a50fdfb5da34489eadf0188f2 (diff)
listen to webglcontextcreationerror for information; fixes #1846
Diffstat (limited to 'src/library_browser.js')
-rw-r--r--src/library_browser.js17
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) {