Issue #2073 - m-c 523950: Discard decoded frames of very large GIF animations (squashed)

Controlled by image.animated.decode-on-demand.threshold-kb, default 256MB

Includes squashed bugfixes/regressions:
 - m-c 1444537: Shutting down the decode pool should make animated decoders bail early
 - m-c 1628606: Make sure to mark the surface cache entry available before sending the frame complete notification
 - m-c 1502275: Skip recreating the decoder after redecode errors if an animated image is reset
 - m-c 1443232: Don't insert frames into our AnimationFrameBuffer that we consider in error and unusable
This commit is contained in:
Martok 2022-12-31 22:55:46 +01:00 committed by roytam1
commit e96122ede2
25 changed files with 925 additions and 63 deletions

View file

@ -853,7 +853,8 @@ RasterImage::ResetAnimation()
}
MOZ_ASSERT(mAnimationState, "Should have AnimationState");
mAnimationState->ResetAnimation();
MOZ_ASSERT(mFrameAnimator, "Should have FrameAnimator");
mFrameAnimator->ResetAnimation(*mAnimationState);
NotifyProgress(NoProgress, mAnimationState->FirstFrameRefreshArea());
@ -1183,10 +1184,13 @@ RasterImage::Decode(const IntSize& aSize,
// Create a decoder.
RefPtr<IDecodingTask> task;
if (mAnimationState && aPlaybackType == PlaybackType::eAnimated) {
bool animated = mAnimationState && aPlaybackType == PlaybackType::eAnimated;
if (animated) {
size_t currentFrame = mAnimationState->GetCurrentAnimationFrameIndex();
task = DecoderFactory::CreateAnimationDecoder(mDecoderType, WrapNotNull(this),
mSourceBuffer, mSize,
decoderFlags, surfaceFlags);
decoderFlags, surfaceFlags,
currentFrame);
mAnimationState->UpdateState(mAnimationFinished, this, mSize);
// If the animation is finished we can draw right away because we just draw
// the final frame all the time from now on. See comment in