Guard against crash in debug mode caused by using a null TimeStamp in a subtraction
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 08 Feb 2012 22:22:30 -0500
changeset 89106 a3da29165fc211efe092fb145254606a723485a5
parent 89105 c569778c702205d84e1e603bafa40aaa76ef85f7
child 89107 6cf9f5c757ae462fc246b8379ccf281d2e4ceedc
push id22242
push userkgupta@mozilla.com
push dateWed, 14 Mar 2012 15:19:09 +0000
treeherdermozilla-central@936ef50fa498 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone13.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
Guard against crash in debug mode caused by using a null TimeStamp in a subtraction
gfx/layers/ipc/CompositorParent.cpp
--- a/gfx/layers/ipc/CompositorParent.cpp
+++ b/gfx/layers/ipc/CompositorParent.cpp
@@ -129,21 +129,24 @@ CompositorParent::ScheduleResumeOnCompos
 
 void
 CompositorParent::ScheduleComposition()
 {
   if (mCurrentCompositeTask) {
     return;
   }
 
-  TimeDuration delta = mozilla::TimeStamp::Now() - mLastCompose;
+  bool initialComposition = mLastCompose.IsNull();
+  TimeDuration delta;
+  if (!initialComposition)
+    delta = mozilla::TimeStamp::Now() - mLastCompose;
 
   printf_stderr("Schedule composition\n");
   mCurrentCompositeTask = NewRunnableMethod(this, &CompositorParent::Composite);
-  if (delta.ToMilliseconds() < 15) {
+  if (!initialComposition && delta.ToMilliseconds() < 15) {
     MessageLoop::current()->PostDelayedTask(FROM_HERE, mCurrentCompositeTask, 15 - delta.ToMilliseconds());
   } else {
     MessageLoop::current()->PostTask(FROM_HERE, mCurrentCompositeTask);
   }
 
 // Test code for async scrolling.
 #ifdef OMTC_TEST_ASYNC_SCROLLING
   static bool scrollScheduled = false;