Bug 1442037 - Fix an incorrect assert in DecoderFactory::CloneAnimationDecoder. r=tnikkel

When cloning an animated image decoder, we asserted that
Decoder::HasAnimation was true. This is incorrect because if the decoder
has yet to complete the metadata decoding, or it has but only finds out
the image is animated when it discovers the second frame, then we will
try to clone a valid animated image decoder, but fail the assertion.
Instead, this patch verifies the image type supports animations.
This commit is contained in:
Andrew Osmond 2018-03-01 19:38:58 -05:00
Родитель 32939c5d14
Коммит bd5718ece1
1 изменённых файлов: 9 добавлений и 3 удалений

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

@ -229,10 +229,16 @@ DecoderFactory::CreateAnimationDecoder(DecoderType aType,
DecoderFactory::CloneAnimationDecoder(Decoder* aDecoder)
{
MOZ_ASSERT(aDecoder);
MOZ_ASSERT(aDecoder->HasAnimation());
RefPtr<Decoder> decoder = GetDecoder(aDecoder->GetType(), nullptr,
/* aIsRedecode = */ true);
// In an ideal world, we would assert aDecoder->HasAnimation() but we cannot.
// The decoder may not have detected it is animated yet (e.g. it did not even
// get scheduled yet, or it has only decoded the first frame and has yet to
// rediscover it is animated).
DecoderType type = aDecoder->GetType();
MOZ_ASSERT(type == DecoderType::GIF || type == DecoderType::PNG,
"Calling CloneAnimationDecoder for non-animating DecoderType");
RefPtr<Decoder> decoder = GetDecoder(type, nullptr, /* aIsRedecode = */ true);
MOZ_ASSERT(decoder, "Should have a decoder now");
// Initialize the decoder.