Bug 1222596. If RasterImage::LookupFrame does (some) sync decoding and encouters an error we don't want to return the surface with an error. r=seth

If the sync decoding the LookupFrame does encounters an error it will set mError on the RasterImage, which LookupFrame callers check before calling LookupFrame. But they've called LookupFrame before the error was encountered, so we check if the frame has had Abort called on it to determine if we should return it at all.

We only does this if one of the sync decode flags was passed in because IsAborted needs to get the imgFrame's monitor, so we don't want to block consumers that haven't asked for decoding.
This commit is contained in:
Timothy Nikkel 2016-04-01 12:44:17 -05:00
parent 7db1b1b28a
commit b0b9bfd047
3 changed files with 21 additions and 0 deletions

View File

@ -368,6 +368,15 @@ RasterImage::LookupFrame(uint32_t aFrameNum,
result.DrawableRef()->WaitUntilFinished();
}
// If we could have done some decoding in this function we need to check if
// that decoding encountered an error and hence aborted the surface. We want
// to avoid calling IsAborted if we weren't passed any sync decode flag because
// IsAborted acquires the monitor for the imgFrame.
if (aFlags & (FLAG_SYNC_DECODE | FLAG_SYNC_DECODE_IF_FAST) &&
result.DrawableRef()->IsAborted()) {
return DrawableFrameRef();
}
return Move(result.DrawableRef());
}

View File

@ -997,6 +997,13 @@ imgFrame::Abort()
mMonitor.NotifyAll();
}
bool
imgFrame::IsAborted() const
{
MonitorAutoLock lock(mMonitor);
return mAborted;
}
bool
imgFrame::IsFinished() const
{

View File

@ -209,6 +209,11 @@ public:
*/
void Abort();
/**
* Returns true if this imgFrame has been aborted.
*/
bool IsAborted() const;
/**
* Returns true if this imgFrame is completely decoded.
*/