Title: [272234] trunk/Source
Revision
272234
Author
[email protected]
Date
2021-02-02 13:54:31 -0800 (Tue, 02 Feb 2021)

Log Message

[macOS] Force loading the HEIF reader symbols before transcoding any HEIF image
https://bugs.webkit.org/show_bug.cgi?id=221191
<rdar://problem/70942158>

Reviewed by Tim Horton.

Source/WebCore:

Transcoding the HEIF images requires loading the HEIF reader symbols which
is not happening in macOS Catalina. A workaround for this bug in WebKit is
to call CGImageSourceGetCount() for the CGImageSource of the HEIF image.

* platform/graphics/cg/ImageUtilitiesCG.cpp:
(WebCore::transcodeImage):

Source/WTF:

Add a HAVE macro for the fix of <rdar://problem/59589723>.

* wtf/PlatformHave.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (272233 => 272234)


--- trunk/Source/WTF/ChangeLog	2021-02-02 21:50:09 UTC (rev 272233)
+++ trunk/Source/WTF/ChangeLog	2021-02-02 21:54:31 UTC (rev 272234)
@@ -1,3 +1,15 @@
+2021-02-02  Said Abou-Hallawa  <[email protected]>
+
+        [macOS] Force loading the HEIF reader symbols before transcoding any HEIF image
+        https://bugs.webkit.org/show_bug.cgi?id=221191
+        <rdar://problem/70942158>
+
+        Reviewed by Tim Horton.
+
+        Add a HAVE macro for the fix of <rdar://problem/59589723>.
+
+        * wtf/PlatformHave.h:
+
 2021-02-02  Alex Christensen  <[email protected]>
 
         Adopt UIEventAttribution instead of _UIEventAttribution

Modified: trunk/Source/WTF/wtf/PlatformHave.h (272233 => 272234)


--- trunk/Source/WTF/wtf/PlatformHave.h	2021-02-02 21:50:09 UTC (rev 272233)
+++ trunk/Source/WTF/wtf/PlatformHave.h	2021-02-02 21:54:31 UTC (rev 272234)
@@ -716,6 +716,7 @@
 #define HAVE_LSDATABASECONTEXT 1
 #define HAVE_PRECONNECT_PING 1
 #define HAVE_WEBP 1
+#define HAVE_IMAGEIO_FIX_FOR_RADAR_59589723 1
 #endif
 
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 110000) \

Modified: trunk/Source/WebCore/ChangeLog (272233 => 272234)


--- trunk/Source/WebCore/ChangeLog	2021-02-02 21:50:09 UTC (rev 272233)
+++ trunk/Source/WebCore/ChangeLog	2021-02-02 21:54:31 UTC (rev 272234)
@@ -1,3 +1,18 @@
+2021-02-02  Said Abou-Hallawa  <[email protected]>
+
+        [macOS] Force loading the HEIF reader symbols before transcoding any HEIF image
+        https://bugs.webkit.org/show_bug.cgi?id=221191
+        <rdar://problem/70942158>
+
+        Reviewed by Tim Horton.
+
+        Transcoding the HEIF images requires loading the HEIF reader symbols which
+        is not happening in macOS Catalina. A workaround for this bug in WebKit is
+        to call CGImageSourceGetCount() for the CGImageSource of the HEIF image.
+
+        * platform/graphics/cg/ImageUtilitiesCG.cpp:
+        (WebCore::transcodeImage):
+
 2021-02-02  Zalan Bujtas  <[email protected]>
 
         [LFC][IFC] Disable inline box content with border images

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageUtilitiesCG.cpp (272233 => 272234)


--- trunk/Source/WebCore/platform/graphics/cg/ImageUtilitiesCG.cpp	2021-02-02 21:50:09 UTC (rev 272233)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageUtilitiesCG.cpp	2021-02-02 21:54:31 UTC (rev 272234)
@@ -51,6 +51,18 @@
     if (sourceUTI == destinationUTI)
         return nullString();
 
+#if !HAVE(IMAGEIO_FIX_FOR_RADAR_59589723)
+    auto sourceMIMEType = MIMETypeFromUTI(sourceUTI);
+    if (sourceMIMEType == "image/heif"_s || sourceMIMEType == "image/heic"_s) {
+        static std::once_flag onceFlag;
+        std::call_once(onceFlag, [&] {
+            // This call will force ImageIO to load the symbols of the HEIF reader. This
+            // bug is already fixed in ImageIO of macOS Big Sur <rdar://problem/59589723>.
+            CGImageSourceGetCount(source.get());
+        });
+    }
+#endif
+
     // It is important to add the appropriate file extension to the temporary file path.
     // The File object depends solely on the extension to know the MIME type of the file.
     auto suffix = makeString('.', destinationExtension);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to