diff --git a/specs/latest/1.0/index.html b/specs/latest/1.0/index.html index 7b6884421..e34515228 100644 --- a/specs/latest/1.0/index.html +++ b/specs/latest/1.0/index.html @@ -3773,6 +3773,81 @@

The Context Creation Error Event

errorInfo); } + +

The Context Recreation Ready Event

+ +

+ When the user agent is to fire a WebGL + context recreation ready at a canvas, it must perform the following steps: + +

    + +
  1. Fire a WebGL context event named + "webglcontextrecreationready" at canvas, if the initial context creation failed caused by temporary hardware issues. + You might see such issues at a certain rate by extremely high trafficing WebGL only websites.
  2. + +
+ +

+ +
+ This event is designed under the background of surging online visits to more + and more extremely high traffic WebGL only websites. Nowadays daily visits at + the level of 10 million to a single WebGL dependent webpage are not rare. + (Theorically at least a visit per 8.6 milliseconds) + User client GPUs are often shared between applications. If another GPU dependent + application causes temporary hardware issues, like running long shaders. + A certain percentage of website users can run into such situations, hence fail to + create WebGL context. We lack such an context independent event to inform users + when is the most applicable timepoint to recreate context. +
+ +
+ + The following code illustrates how an application can recreate context if the initial creation failed: + +
var gl = null;
+var errorInfo = "";
+function createContext() {
+
+    var gl = canvas.getContext("webgl");
+    if(!gl) {
+      alert("A WebGL context could not be created at the moment.\nReason: " +
+            errorInfo + 
+            "A event will be fired if hardware is ready again. Possibly in less than 30 seconds depending on specific hardwares.");
+    }
+    
+    return gl;
+}
+
+function onContextCreationError(event) {
+
+  canvas.removeEventListener(
+     "webglcontextcreationerror",
+     onContextCreationError, false);
+
+  errorInfo = e.statusMessage || "Unknown";
+}
+
+canvas.addEventListener(
+    "webglcontextcreationerror",
+    onContextCreationError, false);
+
+function onContextRecreationReady(event) {
+
+  canvas.removeEventListener(
+     "webglcontextrecreationready",
+     onContextRecreationReady, false);
+
+  gl = createContext();
+}
+
+canvas.addEventListener(
+    "webglcontextrecreationready",
+    onContextRecreationReady, false);
+
+gl = createContext();
+