Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cocoa] Support AVIF images for macOS Ventura and iOS 16 #1717

Conversation

shallawa
Copy link
Contributor

@shallawa shallawa commented Jun 23, 2022

59d774a

[Cocoa] Support AVIF images for macOS Ventura and iOS 16
https://bugs.webkit.org/show_bug.cgi?id=241904
rdar://95742091

Reviewed by Myles C. Maxfield.

Add the mime type and the UTI of the AVIF to the list of the allowed image
formats. The system frameworks will be used to render the AVIF images on macOS
Ventura and iOS 16. Because of sand-boxing limitations, software decoding has
to be used for AVIF images.

* LayoutTests/platform/mac/TestExpectations:
* Source/WTF/wtf/PlatformHave.h:
* Source/WebCore/loader/cache/CachedResourceRequest.cpp:
(WebCore::acceptHeaderValueForImageResource):
* Source/WebCore/platform/MIMETypeRegistry.cpp:
* Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp:
(WebCore::createImageSourceOptions):
* Source/WebCore/platform/graphics/cg/UTIRegistry.cpp:
(WebCore::defaultSupportedImageTypes):

Canonical link: https://commits.webkit.org/251850@main

@shallawa shallawa self-assigned this Jun 23, 2022
@shallawa shallawa added Images For bugs in image handling. WebKit Nightly Build labels Jun 23, 2022
@@ -93,7 +93,7 @@ constexpr ComparableCaseFoldingASCIILiteral supportedImageMIMETypeArray[] = {
#if USE(CG) || ENABLE(APNG)
"image/apng",
#endif
#if USE(AVIF)
#if HAVE(AVIF) || USE(AVIF)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uh oh. Why is there both HAVE(AVIF) and USE(AVIF)? Can we consolidate them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HAVE(AVIF) is used by Apple ports where the system frameworks provide the needed support to render these images.
USE(AVIF) is used by non Apple ports. It is defined in Source/cmake/OptionsWPE.cmake and Source/cmake/OptionsGTK.cmake. They use libavif to handle the AVIF images. If we want to merge HAVE(AVIF) and USE(AVIF) and merge HAVE(WEBP) and USE(WEBP), I think it is better to handle this in a separate patch.

Copy link
Contributor

@litherum litherum Jun 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make sure we have a bug open for the separate patch? (Presumably the separate patch would be for both AVIF and WEBP.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source/WebCore/platform/MIMETypeRegistry.cpp Show resolved Hide resolved
Source/WTF/wtf/PlatformHave.h Show resolved Hide resolved
Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp Outdated Show resolved Hide resolved
@shallawa shallawa force-pushed the eng/Cocoa-Support-AVIF-images-for-macOS-Ventura-and-iOS-16 branch 2 times, most recently from 120c22a to 67b4e14 Compare June 25, 2022 01:27
@shallawa shallawa requested review from pvollan and smfr June 25, 2022 04:13
@@ -76,7 +76,7 @@ static RetainPtr<CFMutableDictionaryRef> createImageSourceOptions()
CFDictionarySetValue(options.get(), kCGImageSourceUseHardwareAcceleration, kCFBooleanFalse);

#if HAVE(IMAGE_RESTRICTED_DECODING) && USE(APPLE_INTERNAL_SDK)
if (ImageDecoderCG::decodingHEICEnabled())
if (ImageDecoderCG::decodingHEICEnabled() || ImageDecoderCG::decodingAVIFEnabled())
CFDictionarySetValue(options.get(), kCGImageSourceEnableRestrictedDecoding, kCFBooleanTrue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not super clear if this line has any repercussions beyond HEIC or AVIF, but okay.

@shallawa shallawa added the merge-queue Applied to send a pull request to merge-queue label Jun 25, 2022
https://bugs.webkit.org/show_bug.cgi?id=241904
rdar://95742091

Reviewed by Myles C. Maxfield.

Add the mime type and the UTI of the AVIF to the list of the allowed image
formats. The system frameworks will be used to render the AVIF images on macOS
Ventura and iOS 16. Because of sand-boxing limitations, software decoding has
to be used for AVIF images.

* LayoutTests/platform/mac/TestExpectations:
* Source/WTF/wtf/PlatformHave.h:
* Source/WebCore/loader/cache/CachedResourceRequest.cpp:
(WebCore::acceptHeaderValueForImageResource):
* Source/WebCore/platform/MIMETypeRegistry.cpp:
* Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp:
(WebCore::createImageSourceOptions):
* Source/WebCore/platform/graphics/cg/UTIRegistry.cpp:
(WebCore::defaultSupportedImageTypes):

Canonical link: https://commits.webkit.org/251850@main
@webkit-early-warning-system webkit-early-warning-system force-pushed the eng/Cocoa-Support-AVIF-images-for-macOS-Ventura-and-iOS-16 branch from 67b4e14 to 59d774a Compare June 25, 2022 08:32
@webkit-commit-queue
Copy link
Collaborator

Committed 251850@main (59d774a): https://commits.webkit.org/251850@main

Reviewed commits have been landed. Closing PR #1717 and removing active labels.

@webkit-early-warning-system webkit-early-warning-system merged commit 59d774a into WebKit:main Jun 25, 2022
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jun 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Images For bugs in image handling.
Projects
None yet
4 participants