Bug 172461 - A big animated image can be decoded as a large static image before receiving all the data
Summary: A big animated image can be decoded as a large static image before receiving ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Images (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Said Abou-Hallawa
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-05-22 12:09 PDT by Said Abou-Hallawa
Modified: 2017-05-22 18:51 PDT (History)
4 users (show)

See Also:


Attachments
Patch (4.75 KB, patch)
2017-05-22 12:10 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (5.34 KB, patch)
2017-05-22 17:16 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Said Abou-Hallawa 2017-05-22 12:09:16 PDT
This case happened while testing a page with 11 large animated images and it happened only with an image with size = 75MB and 377 frames. So getting a layout test for this scenario will not be easy.

This scenario leads to assertions in BitmapImage::imageFrameAvailableAtIndex() and BitmapImage::draw() since these function expects the decoding of an animated image is completely separate from the beginning and from the beginning. We need to handle the case of decoding the first frame for the first repetition different from decoding the other frames and from the other repetitions.
Comment 1 Said Abou-Hallawa 2017-05-22 12:10:58 PDT
Created attachment 310897 [details]
Patch
Comment 2 Radar WebKit Bug Importer 2017-05-22 13:08:02 PDT
<rdar://problem/32332901>
Comment 3 Radar WebKit Bug Importer 2017-05-22 13:08:07 PDT
<rdar://problem/32332897>
Comment 4 Simon Fraser (smfr) 2017-05-22 13:24:04 PDT
Comment on attachment 310897 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=310897&action=review

> Source/WebCore/ChangeLog:3
> +        A big animated image can be decoded as a large static image before receiving all the data

I don't understand this title. Is it that we fail to animate the image?

> Source/WebCore/ChangeLog:10
> +        A big animated image can be recognized as a large static image. Then the
> +        real frameCount() is fetched once more data is received and the animation
> +        may start even before finishing the decoding of the first frame.

Don't we get the metadata before the first frame, though?
Comment 5 Said Abou-Hallawa 2017-05-22 15:13:09 PDT
Comment on attachment 310897 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=310897&action=review

>> Source/WebCore/ChangeLog:3
>> +        A big animated image can be decoded as a large static image before receiving all the data
> 
> I don't understand this title. Is it that we fail to animate the image?

I meant the image can be recognized as a static large image because its frameCount() is 1 so we request decoding it as a static large image. Then when more data is received, the value of frameCount becomes > 1 so it begins to animate. When the first frame finishes decoding, BitmapImage::imageFrameAvailableAtIndex() gets called. This function expects to receive the nextFrame not the currentFrame for animated images.

>> Source/WebCore/ChangeLog:10
>> +        may start even before finishing the decoding of the first frame.
> 
> Don't we get the metadata before the first frame, though?

Yes we do. But some of the metadata can change when more data is received. One of these metadata is the frameCount(). See ImageFrameCache::clearMetadata().
Comment 6 Simon Fraser (smfr) 2017-05-22 15:27:55 PDT
Comment on attachment 310897 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=310897&action=review

>>> Source/WebCore/ChangeLog:3
>>> +        A big animated image can be decoded as a large static image before receiving all the data
>> 
>> I don't understand this title. Is it that we fail to animate the image?
> 
> I meant the image can be recognized as a static large image because its frameCount() is 1 so we request decoding it as a static large image. Then when more data is received, the value of frameCount becomes > 1 so it begins to animate. When the first frame finishes decoding, BitmapImage::imageFrameAvailableAtIndex() gets called. This function expects to receive the nextFrame not the currentFrame for animated images.

It seems like the better title would be "Avoid moving to the second frame of an animated image before the first frame has finished decoding".

This stuff about "recognizing" that an image is animated is confusing.
Comment 7 Said Abou-Hallawa 2017-05-22 17:16:34 PDT
Created attachment 310960 [details]
Patch
Comment 8 WebKit Commit Bot 2017-05-22 18:51:07 PDT
Comment on attachment 310960 [details]
Patch

Clearing flags on attachment: 310960

Committed r217262: <http://trac.webkit.org/changeset/217262>
Comment 9 WebKit Commit Bot 2017-05-22 18:51:09 PDT
All reviewed patches have been landed.  Closing bug.