Bug 1283462 - Fix race condition when notifying on image decoding progress. r=seth
authorAndrew Osmond <aosmond@mozilla.com>
Fri, 22 Jul 2016 11:04:09 -0400
changeset 306936 343a4eced34bdb2c610da8d439da348f1e159eaa
parent 306935 63b876fe012a5311643eb6d0b568e0c250ab18cc
child 306937 4730019ab44c34c7fe99e347647a25ba2b53b628
push id79975
push userryanvm@gmail.com
push dateThu, 28 Jul 2016 02:23:05 +0000
treeherdermozilla-inbound@5f98e30cc66e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersseth
bugs1283462
milestone50.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 1283462 - Fix race condition when notifying on image decoding progress. r=seth
image/IDecodingTask.cpp
--- a/image/IDecodingTask.cpp
+++ b/image/IDecodingTask.cpp
@@ -19,31 +19,31 @@ namespace image {
 // Helpers for sending notifications to the image associated with a decoder.
 ///////////////////////////////////////////////////////////////////////////////
 
 static void
 NotifyProgress(NotNull<Decoder*> aDecoder)
 {
   MOZ_ASSERT(aDecoder->HasProgress() && !aDecoder->IsMetadataDecode());
 
+  Progress progress = aDecoder->TakeProgress();
+  nsIntRect invalidRect = aDecoder->TakeInvalidRect();
+  SurfaceFlags surfaceFlags = aDecoder->GetSurfaceFlags();
+
   // Synchronously notify if we can.
   if (NS_IsMainThread() &&
       !(aDecoder->GetDecoderFlags() & DecoderFlags::ASYNC_NOTIFY)) {
-    aDecoder->GetImage()->NotifyProgress(aDecoder->TakeProgress(),
-                                         aDecoder->TakeInvalidRect(),
-                                         aDecoder->GetSurfaceFlags());
+    aDecoder->GetImage()->NotifyProgress(progress, invalidRect, surfaceFlags);
     return;
   }
 
   // We're forced to notify asynchronously.
   NotNull<RefPtr<Decoder>> decoder = aDecoder;
   NS_DispatchToMainThread(NS_NewRunnableFunction([=]() -> void {
-    decoder->GetImage()->NotifyProgress(decoder->TakeProgress(),
-                                        decoder->TakeInvalidRect(),
-                                        decoder->GetSurfaceFlags());
+    decoder->GetImage()->NotifyProgress(progress, invalidRect, surfaceFlags);
   }));
 }
 
 static void
 NotifyDecodeComplete(NotNull<Decoder*> aDecoder)
 {
   // Synchronously notify if we can.
   if (NS_IsMainThread() &&