Bug 736481 - 6/7 - WebGL lost context handling: check if we still have a canvas - r=jgilbert, a=blocking-fennec
authorBenoit Jacob <bjacob@mozilla.com>
Sat, 21 Apr 2012 16:48:22 -0400
changeset 95396 b8bdcf5ef5ce40bca3813a37444fdd9b2fe95805
parent 95395 e855654fef7e02ce1bbc0dda4f921f352cf21e7f
child 95397 dd21fdb6971322b93b7814b9965e139ffcc4d06a
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert, blocking-fennec
bugs736481
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 736481 - 6/7 - WebGL lost context handling: check if we still have a canvas - r=jgilbert, a=blocking-fennec
content/canvas/src/WebGLContext.cpp
--- a/content/canvas/src/WebGLContext.cpp
+++ b/content/canvas/src/WebGLContext.cpp
@@ -1050,16 +1050,23 @@ WebGLContext::DummyFramebufferOperation(
 // Note that this timer mechanism is not used unless one of these 3 criteria
 // are met.
 // At a bare minimum, from context lost to context restores, it would take 3
 // full timer iterations: detection, webglcontextlost, webglcontextrestored.
 NS_IMETHODIMP
 WebGLContext::Notify(nsITimer* timer)
 {
     TerminateContextLossTimer();
+
+    if (!HTMLCanvasElement()) {
+        // the canvas is gone. That happens when the page was closed before we got
+        // this timer event. In this case, there's nothing to do here, just don't crash.
+        return NS_OK;
+    }
+
     // If the context has been lost and we're waiting for it to be restored, do
     // that now.
     if (mContextStatus == ContextLostAwaitingEvent) {
         bool defaultAction;
         nsContentUtils::DispatchTrustedEvent(HTMLCanvasElement()->OwnerDoc(),
                                              (nsIDOMHTMLCanvasElement*) HTMLCanvasElement(),
                                              NS_LITERAL_STRING("webglcontextlost"),
                                              true,