Bug 233545

Summary: Support Animated JPEG-XL images
Product: WebKit Reporter: Yoshiaki Jitsukawa <yoshiaki.jitsukawa>
Component: ImagesAssignee: Yoshiaki Jitsukawa <yoshiaki.jitsukawa>
Status: RESOLVED FIXED    
Severity: Normal CC: don.olmstead, sabouhallawa, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 208235    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description Yoshiaki Jitsukawa 2021-11-28 17:09:24 PST
JPEG-XL can have animations but currently the decoder decodes only the first frame.
Comment 1 Yoshiaki Jitsukawa 2021-11-30 01:38:33 PST
Created attachment 445396 [details]
Patch
Comment 2 Yoshiaki Jitsukawa 2021-11-30 01:40:59 PST
Created attachment 445397 [details]
Patch
Comment 3 Radar WebKit Bug Importer 2021-12-05 17:10:20 PST
<rdar://problem/86077143>
Comment 4 Said Abou-Hallawa 2021-12-06 14:02:53 PST
Comment on attachment 445397 [details]
Patch

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

> LayoutTests/platform/wincairo/TestExpectations:278
> +fast/images/animated-jpegxl-loop-count.html [ Skip ]

Since the test is skipped globally, where is it un-skipped? I expect it see marked [Pass] here.

I see the comment "# JPEG XL is disabled until WebKitRequirements is released with libjxl" now. But what is the point in adding the test without enabling libjxl? Can't we just have a feature flag or a internal flag to enable it for layout tests only?

> Source/WebCore/platform/image-decoders/jpegxl/JPEGXLImageDecoder.cpp:94
> +        if (!i->isInvalid() && !i->isPartial()) // We don't clear the frame we're currently decoding.

This condition and the comment are confusing. Why do you want to keep the isInvalid() frame? And what does "we're currently decoding" mean? Do we run the decoding on a separate thread?
Comment 5 Yoshiaki Jitsukawa 2021-12-07 04:17:49 PST
Created attachment 446154 [details]
Patch
Comment 6 Yoshiaki Jitsukawa 2021-12-07 04:28:13 PST
Created attachment 446157 [details]
Patch
Comment 7 Yoshiaki Jitsukawa 2021-12-07 04:38:53 PST
(In reply to Said Abou-Hallawa from comment #4)
Thank you for the review!

> Since the test is skipped globally, where is it un-skipped? I expect it see
> marked [Pass] here.
> 
> I see the comment "# JPEG XL is disabled until WebKitRequirements is
> released with libjxl" now. But what is the point in adding the test without
> enabling libjxl? Can't we just have a feature flag or a internal flag to
> enable it for layout tests only?

I've marked the wincairo expectations as [Pass]. Also I changed the comment to simply "JPEG-XL tests" because now we have libjxl in the latest WebKitRequirements.

> 
> > Source/WebCore/platform/image-decoders/jpegxl/JPEGXLImageDecoder.cpp:94
> > +        if (!i->isInvalid() && !i->isPartial()) // We don't clear the frame we're currently decoding.
> 
> This condition and the comment are confusing. Why do you want to keep the
> isInvalid() frame? And what does "we're currently decoding" mean? Do we run
> the decoding on a separate thread?

I fixed it to clear invalid frames in case where it has a valid backing store. 

"we're currently decoding" means that the current frame decoding is interrupted due to input starvation. I clarified the relation between the isPartial() and   "currently decoding".
Comment 8 Don Olmstead 2021-12-07 14:28:14 PST
Comment on attachment 446157 [details]
Patch

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

r=me with nit

> Source/WebCore/platform/image-decoders/jpegxl/JPEGXLImageDecoder.cpp:154
> +        if (query == Query::FrameCount)
> +            return false; // Continue counting frames.
> +        return true; // In this case the decoder has reached the EOF and needs rewind.

Just do

return query != Query::FrameCount

and add any behavior documentation above it.
Comment 9 Yoshiaki Jitsukawa 2021-12-07 15:24:39 PST
Created attachment 446244 [details]
Patch
Comment 10 Yoshiaki Jitsukawa 2021-12-07 15:28:41 PST
(In reply to Don Olmstead from comment #8)
> Just do
> 
> return query != Query::FrameCount
> 
> and add any behavior documentation above it.

Thank you! I addressed the point.
(Also updated the comment in clearFrameBufferCache())
Comment 11 EWS 2021-12-07 16:23:51 PST
Committed r286628 (244941@main): <https://commits.webkit.org/244941@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 446244 [details].