Title: [295213] trunk/Source
Revision
295213
Author
pvol...@apple.com
Date
2022-06-03 08:55:01 -0700 (Fri, 03 Jun 2022)

Log Message

Call function to restrict image decoders for all clients
https://bugs.webkit.org/show_bug.cgi?id=240958
<rdar://93794556>

Reviewed by Geoffrey Garen.

Call function to enable HEIC decoding for all clients on iOS. The main motivation behind this patch
is to avoid using IOKit when decoding HEIC or JPEGs with aux HEIC. Calling enableDecodingHEIC() will
make sure IOKit is not being used, as well as enabling HEIC decoding. We previously only did this for
Mail, but decoding of HEIC images should be possible for all clients. We are not enabling this for
all clients on macOS, since macOS is not blocking IOKit in the WebContent process. This patch also
renames the function, since the former name was not accurate.

* Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp:
(WebCore::createImageSourceOptions):
(WebCore::ImageDecoderCG::enableDecodeHEIC):
(WebCore::ImageDecoderCG::decodeHEICEnabled):
(WebCore::ImageDecoderCG::enableRestrictedDecoding): Deleted.
(WebCore::ImageDecoderCG::restrictedDecodingEnabled): Deleted.
* Source/WebCore/platform/graphics/cg/ImageDecoderCG.h:
* Source/WebKit/Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode const):
(WebKit::WebProcessCreationParameters::decode):
* Source/WebKit/Shared/WebProcessCreationParameters.h:
* Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeWebProcess):
* Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp (295212 => 295213)


--- trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp	2022-06-03 15:47:55 UTC (rev 295212)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp	2022-06-03 15:55:01 UTC (rev 295213)
@@ -76,7 +76,7 @@
         CFDictionarySetValue(options.get(), kCGImageSourceUseHardwareAcceleration, kCFBooleanFalse);
 
 #if HAVE(IMAGE_RESTRICTED_DECODING) && USE(APPLE_INTERNAL_SDK)
-    if (ImageDecoderCG::restrictedDecodingEnabled())
+    if (ImageDecoderCG::decodingHEICEnabled())
         CFDictionarySetValue(options.get(), kCGImageSourceEnableRestrictedDecoding, kCFBooleanTrue);
 #endif
 
@@ -268,7 +268,7 @@
 }
 #endif
 
-bool ImageDecoderCG::s_enableRestrictedDecoding = false;
+bool ImageDecoderCG::s_enableDecodingHEIC = false;
 bool ImageDecoderCG::s_hardwareAcceleratedDecodingDisabled = false;
 
 ImageDecoderCG::ImageDecoderCG(FragmentedSharedBuffer& data, AlphaOption, GammaAndColorProfileOption)
@@ -611,14 +611,14 @@
     return MIMETypeRegistry::isSupportedImageMIMEType(mimeType);
 }
 
-void ImageDecoderCG::enableRestrictedDecoding()
+void ImageDecoderCG::enableDecodingHEIC()
 {
-    s_enableRestrictedDecoding = true;
+    s_enableDecodingHEIC = true;
 }
 
-bool ImageDecoderCG::restrictedDecodingEnabled()
+bool ImageDecoderCG::decodingHEICEnabled()
 {
-    return s_enableRestrictedDecoding;
+    return s_enableDecodingHEIC;
 }
 
 void ImageDecoderCG::disableHardwareAcceleratedDecoding()

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h (295212 => 295213)


--- trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h	2022-06-03 15:47:55 UTC (rev 295212)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h	2022-06-03 15:55:01 UTC (rev 295213)
@@ -70,8 +70,8 @@
     bool isAllDataReceived() const final { return m_isAllDataReceived; }
     void clearFrameBufferCache(size_t) final { }
 
-    WEBCORE_EXPORT static void enableRestrictedDecoding();
-    static bool restrictedDecodingEnabled();
+    WEBCORE_EXPORT static void enableDecodingHEIC();
+    static bool decodingHEICEnabled();
 
     WEBCORE_EXPORT static void disableHardwareAcceleratedDecoding();
     static bool hardwareAcceleratedDecodingDisabled();
@@ -80,7 +80,7 @@
     bool m_isAllDataReceived { false };
     mutable EncodedDataStatus m_encodedDataStatus { EncodedDataStatus::Unknown };
     RetainPtr<CGImageSourceRef> m_nativeDecoder;
-    static bool s_enableRestrictedDecoding;
+    static bool s_enableDecodingHEIC;
     static bool s_hardwareAcceleratedDecodingDisabled;
 };
 

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp (295212 => 295213)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2022-06-03 15:47:55 UTC (rev 295212)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2022-06-03 15:55:01 UTC (rev 295213)
@@ -163,7 +163,7 @@
 #if PLATFORM(MAC)
     encoder << trustdExtensionHandle;
 #endif
-    encoder << restrictImageAndVideoDecoders;
+    encoder << enableDecodingHEIC;
 #endif
 
 #if PLATFORM(IOS_FAMILY)
@@ -450,11 +450,11 @@
         return false;
     parameters.trustdExtensionHandle = WTFMove(*trustdExtensionHandle);
 #endif
-    std::optional<bool> restrictImageAndVideoDecoders;
-    decoder >> restrictImageAndVideoDecoders;
-    if (!restrictImageAndVideoDecoders)
+    std::optional<bool> enableDecodingHEIC;
+    decoder >> enableDecodingHEIC;
+    if (!enableDecodingHEIC)
         return false;
-    parameters.restrictImageAndVideoDecoders = *restrictImageAndVideoDecoders;
+    parameters.enableDecodingHEIC = *enableDecodingHEIC;
 #endif
 
 #if PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.h (295212 => 295213)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2022-06-03 15:47:55 UTC (rev 295212)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2022-06-03 15:55:01 UTC (rev 295213)
@@ -204,7 +204,7 @@
 #if PLATFORM(MAC)
     SandboxExtension::Handle trustdExtensionHandle;
 #endif
-    bool restrictImageAndVideoDecoders { false };
+    bool enableDecodingHEIC { false };
 #endif
 
 #if PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (295212 => 295213)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2022-06-03 15:47:55 UTC (rev 295212)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2022-06-03 15:55:01 UTC (rev 295213)
@@ -396,10 +396,10 @@
     if (MacApplication::isAppleMail() || CocoaApplication::isWebkitTestRunner()) {
         if (auto trustdExtensionHandle = SandboxExtension::createHandleForMachLookup("com.apple.trustd.agent"_s, std::nullopt))
             parameters.trustdExtensionHandle = WTFMove(*trustdExtensionHandle);
-        parameters.restrictImageAndVideoDecoders = true;
+        parameters.enableDecodingHEIC = true;
     }
 #else
-    parameters.restrictImageAndVideoDecoders = IOSApplication::isMobileMail() || IOSApplication::isMailCompositionService() || CocoaApplication::isWebkitTestRunner();
+    parameters.enableDecodingHEIC = true;
 #endif // PLATFORM(MAC)
 #endif // HAVE(VIDEO_RESTRICTED_DECODING)
 

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (295212 => 295213)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2022-06-03 15:47:55 UTC (rev 295212)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2022-06-03 15:55:01 UTC (rev 295213)
@@ -256,9 +256,9 @@
     SandboxExtension::consumePermanently(parameters.trustdExtensionHandle);
 #endif // PLATFORM(MAC)
 #if USE(APPLE_INTERNAL_SDK)
-    if (parameters.restrictImageAndVideoDecoders) {
-        ImageDecoderCG::enableRestrictedDecoding();
-        restrictImageAndVideoDecoders();
+    if (parameters.enableDecodingHEIC) {
+        ImageDecoderCG::enableDecodingHEIC();
+        enableDecodingHEIC();
     }
 #endif
 #endif // HAVE(VIDEO_RESTRICTED_DECODING)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to