@@ -1617,40 +1617,44 @@ RasterImage::NotifyDecodeComplete(const DecoderFinalStatus& aStatus,
16171617 mAnimationState ->SetDoneDecoding (true );
16181618 }
16191619
1620- if (!aStatus.mWasMetadataDecode && aTelemetry.mChunkCount ) {
1621- Telemetry::Accumulate (Telemetry::IMAGE_DECODE_CHUNKS , aTelemetry.mChunkCount );
1622- }
1620+ // Do some telemetry if this isn't a metadata decode.
1621+ if (!aStatus.mWasMetadataDecode ) {
1622+ if (aTelemetry.mChunkCount ) {
1623+ Telemetry::Accumulate (Telemetry::IMAGE_DECODE_CHUNKS , aTelemetry.mChunkCount );
1624+ }
16231625
1624- if (aStatus.mFinished ) {
1625- // Do some telemetry if this isn't a metadata decode.
1626- if (!aStatus.mWasMetadataDecode ) {
1626+ if (aStatus.mFinished ) {
16271627 Telemetry::Accumulate (Telemetry::IMAGE_DECODE_TIME ,
16281628 int32_t (aTelemetry.mDecodeTime .ToMicroseconds ()));
16291629
16301630 if (aTelemetry.mSpeedHistogram ) {
16311631 Telemetry::Accumulate (*aTelemetry.mSpeedHistogram , aTelemetry.Speed ());
16321632 }
16331633 }
1634+ }
16341635
1635- // Detect errors.
1636- if (aStatus.mHadError ) {
1637- DoError ();
1638- } else if (aStatus.mWasMetadataDecode && !mHasSize ) {
1639- DoError ();
1640- }
1636+ // Only act on errors if we have no usable frames from the decoder.
1637+ if (aStatus.mHadError &&
1638+ (!mAnimationState || mAnimationState ->KnownFrameCount () == 0 )) {
1639+ DoError ();
1640+ } else if (aStatus.mWasMetadataDecode && !mHasSize ) {
1641+ DoError ();
1642+ }
16411643
1644+ // XXX(aosmond): Can we get this far without mFinished == true?
1645+ if (aStatus.mFinished && aStatus.mWasMetadataDecode ) {
16421646 // If we were waiting to fire the load event, go ahead and fire it now.
1643- if (mLoadProgress && aStatus. mWasMetadataDecode ) {
1647+ if (mLoadProgress ) {
16441648 NotifyForLoadEvent (*mLoadProgress );
16451649 mLoadProgress = Nothing ();
16461650 NotifyProgress (FLAG_ONLOAD_UNBLOCKED );
16471651 }
1648- }
16491652
1650- // If we were a metadata decode and a full decode was requested, do it.
1651- if (aStatus.mFinished && aStatus.mWasMetadataDecode && mWantFullDecode ) {
1652- mWantFullDecode = false ;
1653- RequestDecodeForSize (mSize , DECODE_FLAGS_DEFAULT );
1653+ // If we were a metadata decode and a full decode was requested, do it.
1654+ if (mWantFullDecode ) {
1655+ mWantFullDecode = false ;
1656+ RequestDecodeForSize (mSize , DECODE_FLAGS_DEFAULT );
1657+ }
16541658 }
16551659}
16561660
0 commit comments