Skip to content

Commit

Permalink
Bug 1222596. If RasterImage::LookupFrame does (some) sync decoding an…
Browse files Browse the repository at this point in the history
…d 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.
  • Loading branch information
tnikkel committed Apr 1, 2016
1 parent 3c2517c commit 3b71751
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions image/RasterImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
7 changes: 7 additions & 0 deletions image/imgFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,13 @@ imgFrame::Abort()
mMonitor.NotifyAll();
}

bool
imgFrame::IsAborted() const
{
MonitorAutoLock lock(mMonitor);
return mAborted;
}

bool
imgFrame::IsFinished() const
{
Expand Down
5 changes: 5 additions & 0 deletions image/imgFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ class imgFrame
*/
void Abort();

/**
* Returns true if this imgFrame has been aborted.
*/
bool IsAborted() const;

/**
* Returns true if this imgFrame is completely decoded.
*/
Expand Down

0 comments on commit 3b71751

Please sign in to comment.