Bug 1447549 - avoid crashing windows debug builds at startup when ::GetMessageTime returns 0, r=jimm.
authorFlorian Quèze <florian@queze.net>
Wed, 21 Mar 2018 23:35:00 +0100
changeset 409406 ada0ac5968f3bed9be8f1428bb857faf589463c6
parent 409405 e21a2a57d05dfe3c5ff8ba71131127fa781ffdd0
child 409407 8d39eba47c3c035cb095062c26c012361d697c35
push id33687
push userapavel@mozilla.com
push dateThu, 22 Mar 2018 09:31:48 +0000
treeherdermozilla-central@7771df14ea18 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1447549
milestone61.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 1447549 - avoid crashing windows debug builds at startup when ::GetMessageTime returns 0, r=jimm.
widget/SystemTimeConverter.h
--- a/widget/SystemTimeConverter.h
+++ b/widget/SystemTimeConverter.h
@@ -44,22 +44,27 @@ public:
   {
     static_assert(!IsSigned<Time>::value, "Expected Time to be unsigned");
   }
 
   template <typename CurrentTimeGetter>
   mozilla::TimeStamp
   GetTimeStampFromSystemTime(Time aTime,
                              CurrentTimeGetter& aCurrentTimeGetter) {
+    TimeStamp roughlyNow = TimeStamp::Now();
+
     // If the reference time is not set, use the current time value to fill
     // it in.
     if (mReferenceTimeStamp.IsNull()) {
+      // This sometimes happens when ::GetMessageTime returns 0 for the first
+      // message on Windows.
+      if (!aTime)
+        return roughlyNow;
       UpdateReferenceTime(aTime, aCurrentTimeGetter);
     }
-    TimeStamp roughlyNow = TimeStamp::Now();
 
     // Check for skew between the source of Time values and TimeStamp values.
     // We do this by comparing two durations (both in ms):
     //
     // i.  The duration from the reference time to the passed-in time.
     //     (timeDelta in the diagram below)
     // ii. The duration from the reference timestamp to the current time
     //     based on TimeStamp::Now.