Bug 1628606. Make sure to mark the surface cache entry available before sending the frame complete notification. r=aosmond

We use FRAME_UPDATE and FRAME_COMPLETE notifications to check if we should resolve/reject img.decode promises. But all of the FRAME_UPDATE/FRAME_COMPLETE notifications for image/test/crashtests/1443232-1.gif come before we change the surface cache entry from a placeholder to available. So RequestDecodeForSize returns false and we don't resolve and we don't get anymore notifications.

In this case the DECODE_COMPLETE notifications comes after we mark the surface cache entry as available so checking if we should resolve for DECODE_COMPLETEs would also work, but it seems reasonable for consumers to expect that they can get a frame after getting a FRAME_COMPLETE notification for it.

Differential Revision: https://phabricator.services.mozilla.com/D70312

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Timothy Nikkel 2020-04-09 13:17:40 +00:00
Родитель f48b0c59a3
Коммит 41d66a8b53
1 изменённых файлов: 11 добавлений и 1 удалений

Просмотреть файл

@ -231,6 +231,16 @@ void AnimationSurfaceProvider::Run() {
continue;
}
// If there is output available we want to change the entry in the surface
// cache from a placeholder to an actual surface now before NotifyProgress
// call below so that when consumers get the frame complete notification
// from the NotifyProgress they can actually get a surface from the surface
// cache.
bool checkForNewFrameAtYieldResult = false;
if (result == LexerResult(Yield::OUTPUT_AVAILABLE)) {
checkForNewFrameAtYieldResult = CheckForNewFrameAtYield();
}
// Notify for the progress we've made so far.
if (mImage && mDecoder->HasProgress()) {
NotifyProgress(WrapNotNull(mImage), WrapNotNull(mDecoder));
@ -249,7 +259,7 @@ void AnimationSurfaceProvider::Run() {
// animation may advance even during shutdown, which keeps us decoding, and
// thus blocking the decode pool during teardown.
MOZ_ASSERT(result == LexerResult(Yield::OUTPUT_AVAILABLE));
if (!CheckForNewFrameAtYield() ||
if (!checkForNewFrameAtYieldResult ||
DecodePool::Singleton()->IsShuttingDown()) {
return;
}