Bug 236428 - Support AVIF images natively
Summary: Support AVIF images natively
Status: RESOLVED CONFIGURATION CHANGED
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: 246598 246925
Blocks:
  Show dependency treegraph
 
Reported: 2022-02-09 20:53 PST by Said Abou-Hallawa
Modified: 2022-10-31 00:11 PDT (History)
24 users (show)

See Also:


Attachments
Patch (11.81 MB, patch)
2022-02-09 21:06 PST, Said Abou-Hallawa
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (11.81 MB, patch)
2022-02-16 16:16 PST, Said Abou-Hallawa
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (11.81 MB, patch)
2022-02-16 22:07 PST, Said Abou-Hallawa
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (11.81 MB, patch)
2022-02-16 23:49 PST, Said Abou-Hallawa
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (11.81 MB, patch)
2022-02-17 15:04 PST, Said Abou-Hallawa
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (11.69 MB, patch)
2022-02-21 04:30 PST, Said Abou-Hallawa
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (11.69 MB, patch)
2022-02-21 13:14 PST, Said Abou-Hallawa
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (11.69 MB, patch)
2022-02-21 22:06 PST, Said Abou-Hallawa
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (11.69 MB, patch)
2022-02-21 22:41 PST, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (11.69 MB, patch)
2022-02-22 02:52 PST, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (11.65 MB, patch)
2022-02-22 19:46 PST, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (251.81 KB, patch)
2022-02-22 20:06 PST, Said Abou-Hallawa
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (11.65 MB, patch)
2022-02-22 23:10 PST, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (Frameworks source excluded) (250.26 KB, patch)
2022-02-22 23:21 PST, 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 2022-02-09 20:53:21 PST
This will import libavif, dav1d and nasm projects to WebKit.
Comment 1 Said Abou-Hallawa 2022-02-09 21:06:41 PST
Created attachment 451491 [details]
Patch
Comment 2 Said Abou-Hallawa 2022-02-16 16:16:36 PST
Created attachment 452268 [details]
Patch
Comment 3 Radar WebKit Bug Importer 2022-02-16 20:54:25 PST
<rdar://problem/89065897>
Comment 4 Said Abou-Hallawa 2022-02-16 22:07:36 PST
Created attachment 452317 [details]
Patch
Comment 5 Said Abou-Hallawa 2022-02-16 23:49:55 PST
Created attachment 452328 [details]
Patch
Comment 6 Said Abou-Hallawa 2022-02-17 15:04:11 PST
Created attachment 452437 [details]
Patch
Comment 7 Aakash Jain 2022-02-18 04:19:02 PST
Cancelled https://ews-build.webkit.org/#/builders/70/builds/624 to speed up mac-wk2 queue, it already run layout-tests and the failure seemed pre-existing.
Comment 8 Said Abou-Hallawa 2022-02-21 04:30:26 PST
Created attachment 452722 [details]
Patch
Comment 9 Said Abou-Hallawa 2022-02-21 13:14:17 PST
Created attachment 452762 [details]
Patch
Comment 10 Said Abou-Hallawa 2022-02-21 22:06:58 PST
Created attachment 452823 [details]
Patch
Comment 11 Said Abou-Hallawa 2022-02-21 22:41:06 PST
Created attachment 452826 [details]
Patch
Comment 12 Said Abou-Hallawa 2022-02-22 02:52:18 PST
Created attachment 452847 [details]
Patch
Comment 13 Tim Horton 2022-02-22 10:28:49 PST
I would elide the massive and useless list of changed symbols.

`WK_LIBAVIF_LDFLAGS` seems sorted wrong.

It seems important to note in the changelog that you've disabled this on Apple Silicon. That will confuse people for sure.

`NASM_HEADER_SEARCH_PATHS` and `HEADER_SEARCH_PATHS` should probably be defined in an xcconfig, not the xcodeproj (also, all of the other properties set in the xcodeproj, there are a bunch). Search for `XCBuildConfiguration` in the patch. Should be nearly empty, getting everything from xcconfigs.

There's a bunch of seemingly-generated code. Is it right that we're checking that in, or should  we be generating it? (I have no idea).
Comment 14 Said Abou-Hallawa 2022-02-22 19:46:38 PST
Created attachment 452932 [details]
Patch
Comment 15 Said Abou-Hallawa 2022-02-22 20:06:57 PST
Created attachment 452934 [details]
Patch

Excluding frameworks
Comment 16 Tim Horton 2022-02-22 20:27:24 PST
Comment on attachment 452934 [details]
Patch

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

> Source/ThirdParty/ChangeLog:25
> +        -- nasm is used to compile the assembly sources in dava1d.

spelling: "dava1d"

> Source/ThirdParty/libavif/Configurations/dav1d.xcconfig:59
> +EXCLUDED_SOURCE_FILE_NAMES[sdk=iphoneos*] = $(EXCLUDED_SOURCE_FILE_NAMES_x86);
> +EXCLUDED_SOURCE_FILE_NAMES[sdk=iphonesimulator*] = $(EXCLUDED_SOURCE_FILE_NAMES_arm);
> +EXCLUDED_SOURCE_FILE_NAMES[sdk=iphonesimulator*][arch=arm64*] = $(EXCLUDED_SOURCE_FILE_NAMES_x86);
> +EXCLUDED_SOURCE_FILE_NAMES[sdk=macosx*] = $(EXCLUDED_SOURCE_FILE_NAMES_arm);
> +EXCLUDED_SOURCE_FILE_NAMES[sdk=macosx*][arch=arm64*] = $(EXCLUDED_SOURCE_FILE_NAMES_x86);

Does this all have to be so complicated? Is it not just an architecture conditional in the end?

> Source/ThirdParty/libavif/Configurations/libavif.xcconfig:55
> +EXCLUDED_SOURCE_FILE_NAMES[sdk=iphonesimulator*] = codec_aom.c codec_libgav1.c codec_rav1e.c codec_svt.c;
> +EXCLUDED_SOURCE_FILE_NAMES[sdk=iphoneos*] = codec_aom.c codec_libgav1.c codec_rav1e.c codec_svt.c;
> +EXCLUDED_SOURCE_FILE_NAMES[sdk=macos*] = codec_aom.c codec_libgav1.c codec_rav1e.c codec_svt.c;

Are these intentionally included only in the watchOS and tvOS builds? If you meant to exclude them everywhere, why not list them only once? Or better, remove them from the project?

> Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml:110
> +  humanReadableName: "Avif image decoding"
> +  humanReadableDescription: "Enable Avif image decoding and rendering"

As far as I can tell both of these should be all-capital "AVIF"

> Source/WebCore/loader/cache/CachedImage.cpp:512
> +        else
> +#endif
> +            // Have the image update its data from its internal buffer. Decoding the image data
> +            // will be delayed until info (like size or specific image frames) are queried which
> +            // usually happens when the observers are repainted.
> +            encodedDataStatus = updateImageData(false);

Multi-line statement after an else with no braces separated by a preprocessor directive is a recipe for a future mistake; can you reorganize this to avoid that? (I'd go with adding some braces, but there are many options)
Comment 17 Said Abou-Hallawa 2022-02-22 23:10:47 PST
Created attachment 452940 [details]
Patch
Comment 18 Said Abou-Hallawa 2022-02-22 23:21:28 PST
Created attachment 452941 [details]
Patch (Frameworks source excluded)
Comment 19 Said Abou-Hallawa 2022-02-22 23:23:21 PST
Comment on attachment 452934 [details]
Patch

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

>> Source/ThirdParty/ChangeLog:25
>> +        -- nasm is used to compile the assembly sources in dava1d.
> 
> spelling: "dava1d"

Fixed

>> Source/ThirdParty/libavif/Configurations/dav1d.xcconfig:59
>> +EXCLUDED_SOURCE_FILE_NAMES[sdk=macosx*][arch=arm64*] = $(EXCLUDED_SOURCE_FILE_NAMES_x86);
> 
> Does this all have to be so complicated? Is it not just an architecture conditional in the end?

This setting was simplified.

>> Source/ThirdParty/libavif/Configurations/libavif.xcconfig:55
>> +EXCLUDED_SOURCE_FILE_NAMES[sdk=macos*] = codec_aom.c codec_libgav1.c codec_rav1e.c codec_svt.c;
> 
> Are these intentionally included only in the watchOS and tvOS builds? If you meant to exclude them everywhere, why not list them only once? Or better, remove them from the project?

This setting was removed and the files were removed.

>> Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml:110
>> +  humanReadableDescription: "Enable Avif image decoding and rendering"
> 
> As far as I can tell both of these should be all-capital "AVIF"

Fixed.

>> Source/WebCore/loader/cache/CachedImage.cpp:512
>> +            encodedDataStatus = updateImageData(false);
> 
> Multi-line statement after an else with no braces separated by a preprocessor directive is a recipe for a future mistake; can you reorganize this to avoid that? (I'd go with adding some braces, but there are many options)

Fixed.
Comment 20 Adam Silverstein 2022-05-17 12:14:12 PDT
Hi Said,

Excited to see this ticket opened to add AVIF support to WebKit! 

I am a WordPress media component maintainer and I've been working with the core Performance team to help add modern image format support. 

AVIF looks like a promising improvement for WordPress and the web at scale and having support in WebKit would potentially unblock adding support for AVIF directly in WordPress core.

I noticed you haven't updated this ticket recently, is this something you are still planning to work on?
Comment 21 Myles C. Maxfield 2022-08-18 11:39:54 PDT
AVIF images are supported in the betas of macOS Ventura and iOS 16.

This Bugzilla bug is about supporting AVIF images in previous versions of macOS (before Ventura).