Bug 1283462 - Fix race condition when notifying on image decoding progress. r=seth

This commit is contained in:
Andrew Osmond
2016-07-22 11:04:09 -04:00
parent 10db00d48b
commit 21a5312f01

View File

@@ -24,21 +24,21 @@ 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);
}));
}