Bug 709384. Manage our scheduled state better when animation frame requests are canceled. r=roc
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 15 Dec 2011 08:53:06 -0500
changeset 84278 3eb0d74456112141a6d3889f06867d4ffa897150
parent 84277 28f79e3efeb4e6dfa488a92ae00617226340a4f2
child 84279 ec462ccd642bf145389cd94339b3e470ead91ab0
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs709384
milestone11.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 709384. Manage our scheduled state better when animation frame requests are canceled. r=roc
content/base/crashtests/709384.html
content/base/crashtests/crashtests.list
content/base/src/nsDocument.cpp
new file mode 100644
--- /dev/null
+++ b/content/base/crashtests/709384.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<script>
+  mozCancelRequestAnimationFrame(mozRequestAnimationFrame(function() {}));
+  mozRequestAnimationFrame(function() {});
+</script>
--- a/content/base/crashtests/crashtests.list
+++ b/content/base/crashtests/crashtests.list
@@ -97,8 +97,9 @@ load 679459.html
 load 679689-1.html
 load 682463.html
 load 693212.xhtml
 load 698974-1.html
 load 700090-1.html
 load 700090-2.html
 load 700512.html
 load xhr_html_nullresponse.html
+load 709384.html
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -8090,21 +8090,22 @@ nsIDocument::ScheduleFrameRequestCallbac
   *aHandle = newHandle;
   return NS_OK;
 }
 
 void
 nsIDocument::CancelFrameRequestCallback(PRInt32 aHandle)
 {
   // mFrameRequestCallbacks is stored sorted by handle
-  mFrameRequestCallbacks.RemoveElementSorted(aHandle);
-
-  // Not going to worry about unscheduling our refresh driver
-  // callback.  It'll just be a no-op when it happens, if we have no
-  // more frame request callbacks.
+  if (mFrameRequestCallbacks.RemoveElementSorted(aHandle) &&
+      mFrameRequestCallbacks.IsEmpty() &&
+      mPresShell && IsEventHandlingEnabled()) {
+    mPresShell->GetPresContext()->RefreshDriver()->
+      RevokeFrameRequestCallbacks(this);
+  }
 }
 
 nsresult
 nsDocument::GetStateObject(nsIVariant** aState)
 {
   // Get the document's current state object. This is the object backing both
   // history.state and popStateEvent.state.
   //