Diff
Modified: trunk/LayoutTests/ChangeLog (279029 => 279030)
--- trunk/LayoutTests/ChangeLog 2021-06-18 02:06:58 UTC (rev 279029)
+++ trunk/LayoutTests/ChangeLog 2021-06-18 04:09:24 UTC (rev 279030)
@@ -1,3 +1,20 @@
+2021-06-17 Said Abou-Hallawa <[email protected]>
+
+ [Cocoa] Disable hardware decoding in the WebProcess
+ https://bugs.webkit.org/show_bug.cgi?id=226869
+ <rdar://77548905>
+
+ Reviewed by Per Arne Vollan and Simon Fraser.
+
+ Add a reference test for rendering the HEIF images.
+
+ * TestExpectations:
+ * fast/images/heic-as-background-image-expected.html: Added.
+ * fast/images/heic-as-background-image.html: Added.
+ * fast/images/resources/green-400x400.heic: Added.
+ * platform/ios/TestExpectations:
+ * platform/mac/TestExpectations:
+
2021-06-17 Ada Chan <[email protected]>
Skip WebXR tests on iOS
Modified: trunk/LayoutTests/TestExpectations (279029 => 279030)
--- trunk/LayoutTests/TestExpectations 2021-06-18 02:06:58 UTC (rev 279029)
+++ trunk/LayoutTests/TestExpectations 2021-06-18 04:09:24 UTC (rev 279030)
@@ -1898,6 +1898,7 @@
# HEIF images are only supported on macOS and iOS post Mojave
fast/images/animated-heics-draw.html [ Skip ]
fast/images/animated-heics-verify.html [ Skip ]
+fast/images/heic-as-background-image.html [ Skip ]
# WebP images are only supported on macOS and iOS post Catalina
fast/images/webp-as-image.html [ Skip ]
Added: trunk/LayoutTests/fast/images/heic-as-background-image-expected.html (0 => 279030)
--- trunk/LayoutTests/fast/images/heic-as-background-image-expected.html (rev 0)
+++ trunk/LayoutTests/fast/images/heic-as-background-image-expected.html 2021-06-18 04:09:24 UTC (rev 279030)
@@ -0,0 +1,10 @@
+<style>
+ .green-box {
+ width: 100px;
+ height: 100px;
+ background-color: green;
+ }
+</style>
+<body>
+ <div class="green-box"></div>
+</body>
Added: trunk/LayoutTests/fast/images/heic-as-background-image.html (0 => 279030)
--- trunk/LayoutTests/fast/images/heic-as-background-image.html (rev 0)
+++ trunk/LayoutTests/fast/images/heic-as-background-image.html 2021-06-18 04:09:24 UTC (rev 279030)
@@ -0,0 +1,11 @@
+<!DOCTYPE html><!-- webkit-test-runner [ additionalSupportedImageTypes=public.heic;public.heics ] -->
+<style>
+ .green-box {
+ width: 100px;
+ height: 100px;
+ background: url("resources/green-400x400.heic") 200px 200px;
+ }
+</style>
+<body>
+ <div class="green-box"></div>
+</body>
Added: trunk/LayoutTests/fast/images/resources/green-400x400.heic (0 => 279030)
--- trunk/LayoutTests/fast/images/resources/green-400x400.heic (rev 0)
+++ trunk/LayoutTests/fast/images/resources/green-400x400.heic 2021-06-18 04:09:24 UTC (rev 279030)
@@ -0,0 +1 @@
+������ftypheic��������heicmif1����\xABmeta��������������"hdlr����������������pict����������������������������������$dinf������dref��������������������url ������������pitm����������������8iinf����������������infe������������hvc1��������infe����������Exif��������iref��������������cdsc������������\xCDiprp������\xAEipco������yhvcC`������\xB0����������?\xF0��\xFC\xFD\xF8\xF8����\xA0����@\xFF\xFF`������\xB0����������?, \xA1����#B`������\xB0����������?\xA0\x88E\x9C\xB9$JIq7\xA4\xA2����D\xC0aL\xE9$ID\x91*@������ispe������������\x90����\x90������ irot��������pixi��������������ipma����������������\x81\x83������,iloc��������D����������������W������o������������\xD3������\x84������mdat������������������Exif����MM��*����������������������>��������������F(��������������\x87i��������������N��������������H������������H��������\x92\x86��������������`��������ASCII������Created with
GIMP��������k&\xAD\x9C\xBEzԔ@\xC1 \xFD\xBB\xFFн\xCF\xF4W|ZSQ\xC2Y\xAC\xA0/\x8C/��X\xE81\xA3\xE7\xA7J\x80\xC0\xB0o������Հ\x93��\x81`��������\x98\x87������������\xB4������������0����������Z����������\xA8
\ No newline at end of file
Modified: trunk/LayoutTests/platform/ios/TestExpectations (279029 => 279030)
--- trunk/LayoutTests/platform/ios/TestExpectations 2021-06-18 02:06:58 UTC (rev 279029)
+++ trunk/LayoutTests/platform/ios/TestExpectations 2021-06-18 04:09:24 UTC (rev 279030)
@@ -3033,6 +3033,7 @@
# <rdar://problem/48781098> HEIF and HEICS images are supported only on iOS 13
fast/images/animated-heics-draw.html [ Pass ]
fast/images/animated-heics-verify.html [ Pass ]
+fast/images/heic-as-background-image.html [ Pass ]
# <rdar://problem/40172428> REGRESSION: LayoutTests fast/text/font-collection.html and fast/text/woff2.html are failing
webkit.org/b/212172 fast/text/font-collection.html [ ImageOnlyFailure ]
Modified: trunk/LayoutTests/platform/mac/TestExpectations (279029 => 279030)
--- trunk/LayoutTests/platform/mac/TestExpectations 2021-06-18 02:06:58 UTC (rev 279029)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2021-06-18 04:09:24 UTC (rev 279030)
@@ -1531,6 +1531,7 @@
# <rdar://problem/48781098>
[ Catalina+ ] fast/images/animated-heics-draw.html [ Pass ]
[ Catalina+ ] fast/images/animated-heics-verify.html [ Pass ]
+[ BigSur+ ] fast/images/heic-as-background-image.html [ Pass ]
# <rdar://problem/40172428>
webkit.org/b/212172 [ Catalina ] fast/text/font-collection.html [ ImageOnlyFailure ]
Modified: trunk/Source/WTF/ChangeLog (279029 => 279030)
--- trunk/Source/WTF/ChangeLog 2021-06-18 02:06:58 UTC (rev 279029)
+++ trunk/Source/WTF/ChangeLog 2021-06-18 04:09:24 UTC (rev 279030)
@@ -1,3 +1,17 @@
+2021-06-17 Said Abou-Hallawa <[email protected]>
+
+ [Cocoa] Disable hardware decoding in the WebProcess
+ https://bugs.webkit.org/show_bug.cgi?id=226869
+ <rdar://77548905>
+
+ Reviewed by Per Arne Vollan and Simon Fraser.
+
+ Add have macros for using:
+ 1. kCGImageSourceEnableRestrictedDecoding
+ 2. VTRestrictVideoDecoders()
+
+ * wtf/PlatformHave.h:
+
2021-06-17 Mark Lam <[email protected]>
Rename numberOfPACBits to maxNumberOfAllowedPACBits.
Modified: trunk/Source/WTF/wtf/PlatformHave.h (279029 => 279030)
--- trunk/Source/WTF/wtf/PlatformHave.h 2021-06-18 02:06:58 UTC (rev 279029)
+++ trunk/Source/WTF/wtf/PlatformHave.h 2021-06-18 04:09:24 UTC (rev 279030)
@@ -994,6 +994,13 @@
#define HAVE_VM_FLAGS_PERMANENT 1
#endif
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101600) \
+ || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000) \
+ || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 70000) \
+ || (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 140000)
+#define HAVE_VIDEO_RESTRICTED_DECODING 1
+#endif
+
#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000) \
|| (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 150000) \
|| (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 80000) \
@@ -1000,6 +1007,7 @@
|| (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 150000)
#define HAVE_CFNETWORK_NSURLSESSION_ATTRIBUTED_BUNDLE_IDENTIFIER 1
#define HAVE_AUDIO_OBJECT_PROPERTY_ELEMENT_MAIN 1
+#define HAVE_IMAGE_RESTRICTED_DECODING 1
#endif
#if PLATFORM(IOS) || PLATFORM(MACCATALYST) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 110000)
Modified: trunk/Source/WebCore/ChangeLog (279029 => 279030)
--- trunk/Source/WebCore/ChangeLog 2021-06-18 02:06:58 UTC (rev 279029)
+++ trunk/Source/WebCore/ChangeLog 2021-06-18 04:09:24 UTC (rev 279030)
@@ -1,3 +1,19 @@
+2021-06-17 Said Abou-Hallawa <[email protected]>
+
+ [Cocoa] Disable hardware decoding in the WebProcess
+ https://bugs.webkit.org/show_bug.cgi?id=226869
+ <rdar://77548905>
+
+ Reviewed by Per Arne Vollan and Simon Fraser.
+
+ Pass kCGImageSourceEnableRestrictedDecoding : kCFBooleanTrue when decoding
+ an image frame.
+
+ Test: fast/images/heic-as-background-image.html
+
+ * platform/graphics/cg/ImageDecoderCG.cpp:
+ (WebCore::createImageSourceOptions):
+
2021-06-17 Chris Dumez <[email protected]>
Add support for IDBCursor.request
Modified: trunk/Source/WebCore/PAL/ChangeLog (279029 => 279030)
--- trunk/Source/WebCore/PAL/ChangeLog 2021-06-18 02:06:58 UTC (rev 279029)
+++ trunk/Source/WebCore/PAL/ChangeLog 2021-06-18 04:09:24 UTC (rev 279030)
@@ -1,3 +1,23 @@
+2021-06-17 Said Abou-Hallawa <[email protected]>
+
+ [Cocoa] Disable hardware decoding in the WebProcess
+ https://bugs.webkit.org/show_bug.cgi?id=226869
+ <rdar://77548905>
+
+ Reviewed by Per Arne Vollan and Simon Fraser.
+
+ SoftLink
+ 1. VTRestrictVideoDecoders from VideoToolbox
+ 2. FigPhotoSupportsHEVCHWDecode from MediaToobox
+
+ * PAL.xcodeproj/project.pbxproj:
+ * pal/cf/VideoToolboxSoftLink.cpp:
+ * pal/cf/VideoToolboxSoftLink.h:
+ * pal/cocoa/MediaToolboxSoftLink.cpp:
+ * pal/cocoa/MediaToolboxSoftLink.h:
+ * pal/spi/cg/ImageIOSPI.h:
+ * pal/spi/cocoa/VideoToolboxSPI.h: Added.
+
2021-06-16 Said Abou-Hallawa <[email protected]>
takeSnapshotWithConfiguration() should wait for the next flush before it does callSnapshotRect()
Modified: trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj (279029 => 279030)
--- trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj 2021-06-18 02:06:58 UTC (rev 279029)
+++ trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj 2021-06-18 04:09:24 UTC (rev 279030)
@@ -148,6 +148,7 @@
5C7C787423AC3E770065F47E /* ManagedConfigurationSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C7C787223AC3E770065F47E /* ManagedConfigurationSoftLink.mm */; };
5C7C787623AC3E850065F47E /* ManagedConfigurationSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C7C787523AC3E850065F47E /* ManagedConfigurationSPI.h */; };
63C7EDC721AFAE04006A7B99 /* NSProgressSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 63E369F921AFA83F001C14BC /* NSProgressSPI.h */; };
+ 72E5BE972679A80A00ADBFA9 /* VideoToolboxSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 72E5BE962679A80900ADBFA9 /* VideoToolboxSPI.h */; };
7A36D0F9223AD9AB00B0522E /* CommonCryptoSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A36D0F8223AD9AB00B0522E /* CommonCryptoSPI.h */; };
7A3A6A8020CADB4700317AAE /* NSImageSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A3A6A7F20CADB4600317AAE /* NSImageSPI.h */; };
93B38EBE25821CB600198E63 /* SpeechSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B38EBD25821CB600198E63 /* SpeechSoftLink.h */; };
@@ -366,6 +367,7 @@
5C7C787223AC3E770065F47E /* ManagedConfigurationSoftLink.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ManagedConfigurationSoftLink.mm; sourceTree = "<group>"; };
5C7C787523AC3E850065F47E /* ManagedConfigurationSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ManagedConfigurationSPI.h; sourceTree = "<group>"; };
63E369F921AFA83F001C14BC /* NSProgressSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSProgressSPI.h; sourceTree = "<group>"; };
+ 72E5BE962679A80900ADBFA9 /* VideoToolboxSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoToolboxSPI.h; sourceTree = "<group>"; };
7A36D0F8223AD9AB00B0522E /* CommonCryptoSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonCryptoSPI.h; sourceTree = "<group>"; };
7A3A6A7F20CADB4600317AAE /* NSImageSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSImageSPI.h; sourceTree = "<group>"; };
93B38EBD25821CB600198E63 /* SpeechSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpeechSoftLink.h; sourceTree = "<group>"; };
@@ -561,6 +563,7 @@
0C2DA13C1F3BEB4900DBC317 /* ServersSPI.h */,
93B38EC125821D2200198E63 /* SpeechSPI.h */,
0C2DA12B1F3BEB4900DBC317 /* URLFormattingSPI.h */,
+ 72E5BE962679A80900ADBFA9 /* VideoToolboxSPI.h */,
F46B8C4E26740AD8007A6554 /* VisionKitCoreSPI.h */,
0C2DA13D1F3BEB4900DBC317 /* WebFilterEvaluatorSPI.h */,
);
@@ -995,6 +998,7 @@
0C5AF9221F43A4C7002EAC02 /* UIKitSPI.h in Headers */,
0C2DA1471F3BEB4900DBC317 /* URLFormattingSPI.h in Headers */,
07611DB6243FA5BF00D80704 /* UsageTrackingSoftLink.h in Headers */,
+ 72E5BE972679A80A00ADBFA9 /* VideoToolboxSPI.h in Headers */,
F46B8C4F26740AD8007A6554 /* VisionKitCoreSPI.h in Headers */,
0C2DA1591F3BEB4900DBC317 /* WebFilterEvaluatorSPI.h in Headers */,
A10826F91F576292004772AC /* WebPanel.h in Headers */,
Modified: trunk/Source/WebCore/PAL/pal/cf/VideoToolboxSoftLink.cpp (279029 => 279030)
--- trunk/Source/WebCore/PAL/pal/cf/VideoToolboxSoftLink.cpp 2021-06-18 02:06:58 UTC (rev 279029)
+++ trunk/Source/WebCore/PAL/pal/cf/VideoToolboxSoftLink.cpp 2021-06-18 04:09:24 UTC (rev 279030)
@@ -26,11 +26,10 @@
#if USE(AVFOUNDATION)
-#import <VideoToolbox/VTCompressionSession.h>
-
+#include <pal/spi/cocoa/VideoToolboxSPI.h>
#include <wtf/SoftLinking.h>
-SOFT_LINK_FRAMEWORK_FOR_SOURCE(PAL, VideoToolbox)
+SOFT_LINK_FRAMEWORK_FOR_SOURCE_WITH_EXPORT(PAL, VideoToolbox, PAL_EXPORT)
SOFT_LINK_CONSTANT_FOR_SOURCE(PAL, VideoToolbox, kVTCompressionPropertyKey_ExpectedFrameRate, CFStringRef)
SOFT_LINK_CONSTANT_FOR_SOURCE(PAL, VideoToolbox, kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration, CFStringRef)
@@ -43,4 +42,6 @@
SOFT_LINK_FUNCTION_FOR_SOURCE(PAL, VideoToolbox, VTCompressionSessionEncodeFrame, OSStatus, (VTCompressionSessionRef session, CVImageBufferRef imageBuffer, CMTime presentationTimeStamp, CMTime duration, CFDictionaryRef frameProperties, void* sourceFrameRefcon, VTEncodeInfoFlags* infoFlagsOut), (session, imageBuffer, presentationTimeStamp, duration, frameProperties, sourceFrameRefcon, infoFlagsOut))
SOFT_LINK_FUNCTION_FOR_SOURCE(PAL, VideoToolbox, VTCompressionSessionPrepareToEncodeFrames, OSStatus, (VTCompressionSessionRef session), (session))
+SOFT_LINK_FUNCTION_MAY_FAIL_FOR_SOURCE_WITH_EXPORT(PAL, VideoToolbox, VTRestrictVideoDecoders, OSStatus, (VTVideoDecoderRestrictions restrictionFlags, const CMVideoCodecType* allowedCodecTypeList, CMItemCount allowedCodecTypeCount), (restrictionFlags, allowedCodecTypeList, allowedCodecTypeCount), PAL_EXPORT)
+
#endif // USE(AVFOUNDATION)
Modified: trunk/Source/WebCore/PAL/pal/cf/VideoToolboxSoftLink.h (279029 => 279030)
--- trunk/Source/WebCore/PAL/pal/cf/VideoToolboxSoftLink.h 2021-06-18 02:06:58 UTC (rev 279029)
+++ trunk/Source/WebCore/PAL/pal/cf/VideoToolboxSoftLink.h 2021-06-18 04:09:24 UTC (rev 279030)
@@ -26,6 +26,7 @@
#if USE(AVFOUNDATION)
+#include <pal/spi/cocoa/VideoToolboxSPI.h>
#include <wtf/SoftLinking.h>
SOFT_LINK_FRAMEWORK_FOR_HEADER(PAL, VideoToolbox)
@@ -49,4 +50,6 @@
SOFT_LINK_FUNCTION_FOR_HEADER(PAL, VideoToolbox, VTCompressionSessionPrepareToEncodeFrames, OSStatus, (VTCompressionSessionRef session), (session))
#define VTCompressionSessionPrepareToEncodeFrames softLink_VideoToolbox_VTCompressionSessionPrepareToEncodeFrames
+SOFT_LINK_FUNCTION_MAY_FAIL_FOR_HEADER(PAL, VideoToolbox, VTRestrictVideoDecoders, OSStatus, (VTVideoDecoderRestrictions restrictionFlags, const CMVideoCodecType* allowedCodecTypeList, CMItemCount allowedCodecTypeCount), (restrictionFlags, allowedCodecTypeList, allowedCodecTypeCount))
+
#endif // USE(AVFOUNDATION)
Modified: trunk/Source/WebCore/PAL/pal/cocoa/MediaToolboxSoftLink.cpp (279029 => 279030)
--- trunk/Source/WebCore/PAL/pal/cocoa/MediaToolboxSoftLink.cpp 2021-06-18 02:06:58 UTC (rev 279029)
+++ trunk/Source/WebCore/PAL/pal/cocoa/MediaToolboxSoftLink.cpp 2021-06-18 04:09:24 UTC (rev 279030)
@@ -59,6 +59,7 @@
SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, MediaToolbox, MTPluginSampleCursorGetTypeID, CFTypeID, (), (), PAL_EXPORT)
SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, MediaToolbox, MTPluginTrackReaderGetClassID, CMBaseClassID, (), (), PAL_EXPORT)
SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, MediaToolbox, MTPluginTrackReaderGetTypeID, CFTypeID, (), (), PAL_EXPORT)
+SOFT_LINK_FUNCTION_MAY_FAIL_FOR_SOURCE_WITH_EXPORT(PAL, MediaToolbox, FigPhotoSupportsHEVCHWDecode, Boolean, (void), (), PAL_EXPORT)
#endif // HAVE(MT_PLUGIN_FORMAT_READER)
Modified: trunk/Source/WebCore/PAL/pal/cocoa/MediaToolboxSoftLink.h (279029 => 279030)
--- trunk/Source/WebCore/PAL/pal/cocoa/MediaToolboxSoftLink.h 2021-06-18 02:06:58 UTC (rev 279029)
+++ trunk/Source/WebCore/PAL/pal/cocoa/MediaToolboxSoftLink.h 2021-06-18 04:09:24 UTC (rev 279030)
@@ -69,6 +69,7 @@
#define MTPluginTrackReaderGetClassID PAL::softLink_MediaToolbox_MTPluginTrackReaderGetClassID
SOFT_LINK_FUNCTION_FOR_HEADER(PAL, MediaToolbox, MTPluginTrackReaderGetTypeID, CFTypeID, (), ())
#define MTPluginTrackReaderGetTypeID PAL::softLink_MediaToolbox_MTPluginTrackReaderGetTypeID
+SOFT_LINK_FUNCTION_MAY_FAIL_FOR_HEADER(PAL, MediaToolbox, FigPhotoSupportsHEVCHWDecode, Boolean, (void), ())
#endif // HAVE(MT_PLUGIN_FORMAT_READER)
Modified: trunk/Source/WebCore/PAL/pal/spi/cg/ImageIOSPI.h (279029 => 279030)
--- trunk/Source/WebCore/PAL/pal/spi/cg/ImageIOSPI.h 2021-06-18 02:06:58 UTC (rev 279029)
+++ trunk/Source/WebCore/PAL/pal/spi/cg/ImageIOSPI.h 2021-06-18 04:09:24 UTC (rev 279030)
@@ -36,6 +36,7 @@
IMAGEIO_EXTERN const CFStringRef kCGImageSourceSkipMetadata;
IMAGEIO_EXTERN const CFStringRef kCGImageSourceSubsampleFactor;
IMAGEIO_EXTERN const CFStringRef kCGImageSourceShouldCacheImmediately;
+IMAGEIO_EXTERN const CFStringRef kCGImageSourceEnableRestrictedDecoding;
#endif
WTF_EXTERN_C_BEGIN
Added: trunk/Source/WebCore/PAL/pal/spi/cocoa/VideoToolboxSPI.h (0 => 279030)
--- trunk/Source/WebCore/PAL/pal/spi/cocoa/VideoToolboxSPI.h (rev 0)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/VideoToolboxSPI.h 2021-06-18 04:09:24 UTC (rev 279030)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(AVFOUNDATION)
+
+#include <CoreMedia/CMFormatDescription.h>
+#include <VideoToolbox/VTCompressionSession.h>
+
+enum {
+ kVTRestrictions_RunVideoDecodersInProcess = 1UL << 0,
+ kVTRestrictions_AvoidHardwareDecoders = 1UL << 1,
+ kVTRestrictions_AvoidIOSurfaceBackings = 1UL << 2,
+ kVTRestrictions_AvoidHardwarePixelTransfer = 1UL << 3,
+};
+typedef uint32_t VTVideoDecoderRestrictions;
+
+#endif // USE(AVFOUNDATION)
Modified: trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp (279029 => 279030)
--- trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp 2021-06-18 02:06:58 UTC (rev 279029)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp 2021-06-18 04:09:24 UTC (rev 279030)
@@ -56,6 +56,7 @@
const CFStringRef kCGImageSourceSkipMetadata = CFSTR("kCGImageSourceSkipMetadata");
const CFStringRef kCGImageSourceSubsampleFactor = CFSTR("kCGImageSourceSubsampleFactor");
const CFStringRef kCGImageSourceShouldCacheImmediately = CFSTR("kCGImageSourceShouldCacheImmediately");
+const CFStringRef kCGImageSourceEnableRestrictedDecoding = CFSTR("kCGImageSourceEnableRestrictedDecoding");
#endif
static RetainPtr<CFMutableDictionaryRef> createImageSourceOptions()
@@ -64,6 +65,9 @@
CFDictionarySetValue(options.get(), kCGImageSourceShouldCache, kCFBooleanTrue);
CFDictionarySetValue(options.get(), kCGImageSourceShouldPreferRGB32, kCFBooleanTrue);
CFDictionarySetValue(options.get(), kCGImageSourceSkipMetadata, kCFBooleanTrue);
+#if HAVE(IMAGE_RESTRICTED_DECODING)
+ CFDictionarySetValue(options.get(), kCGImageSourceEnableRestrictedDecoding, kCFBooleanTrue);
+#endif
return options;
}
Modified: trunk/Source/WebKit/ChangeLog (279029 => 279030)
--- trunk/Source/WebKit/ChangeLog 2021-06-18 02:06:58 UTC (rev 279029)
+++ trunk/Source/WebKit/ChangeLog 2021-06-18 04:09:24 UTC (rev 279030)
@@ -1,3 +1,36 @@
+2021-06-17 Said Abou-Hallawa <[email protected]>
+
+ [Cocoa] Disable hardware decoding in the WebProcess
+ https://bugs.webkit.org/show_bug.cgi?id=226869
+ <rdar://77548905>
+
+ Reviewed by Per Arne Vollan and Simon Fraser.
+
+ Restrict video decoders and disable hardware image decoders.
+
+ A temp extension is created for the service "com.apple.trustd.agent" to
+ allow temporarily calling FigPhotoSupportsHEVCHWDecode(). This function
+ needs access this service but we have recently closed access to it.
+
+ FigPhotoSupportsHEVCHWDecode() sets a local static variable by using the
+ service "com.apple.trustd.agent" when it is called for the first time.
+ Our purpose of calling it in this context is to initialize the static
+ variable only. And this is why we do not use its return value.
+
+ This solution is fragile. If MediaToolbox is changed such that it needs
+ 'com.apple.trustd.agent' while decoding an image, the decoding will fail.
+
+ * Shared/WebProcessCreationParameters.cpp:
+ (WebKit::WebProcessCreationParameters::encode const):
+ (WebKit::WebProcessCreationParameters::decode):
+ * Shared/WebProcessCreationParameters.h:
+ * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+ (WebKit::WebProcessPool::platformInitializeWebProcess):
+ * WebProcess/cocoa/WebProcessCocoa.mm:
+ (WebKit::WebProcess::platformInitializeWebProcess):
+ (WebKit::restrictImageAndVideoDecoders):
+ (WebKit::WebProcess::initializeSandbox):
+
2021-06-17 Chris Dumez <[email protected]>
Enable some more release logging in for ephemeral sessions
Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp (279029 => 279030)
--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp 2021-06-18 02:06:58 UTC (rev 279029)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp 2021-06-18 04:09:24 UTC (rev 279030)
@@ -165,6 +165,10 @@
encoder << mobileGestaltExtensionHandle;
encoder << launchServicesExtensionHandle;
+#if PLATFORM(MAC) && HAVE(VIDEO_RESTRICTED_DECODING)
+ encoder << trustdAgentExtensionHandle;
+#endif
+
encoder << diagnosticsExtensionHandles;
#if PLATFORM(IOS_FAMILY)
encoder << dynamicMachExtensionHandles;
@@ -460,6 +464,14 @@
return false;
parameters.launchServicesExtensionHandle = WTFMove(*launchServicesExtensionHandle);
+#if PLATFORM(MAC) && HAVE(VIDEO_RESTRICTED_DECODING)
+ std::optional<std::optional<SandboxExtension::Handle>> trustdAgentExtensionHandle;
+ decoder >> trustdAgentExtensionHandle;
+ if (!trustdAgentExtensionHandle)
+ return false;
+ parameters.trustdAgentExtensionHandle = WTFMove(*trustdAgentExtensionHandle);
+#endif
+
std::optional<SandboxExtension::HandleArray> diagnosticsExtensionHandles;
decoder >> diagnosticsExtensionHandles;
if (!diagnosticsExtensionHandles)
Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.h (279029 => 279030)
--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.h 2021-06-18 02:06:58 UTC (rev 279029)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.h 2021-06-18 04:09:24 UTC (rev 279030)
@@ -206,6 +206,9 @@
std::optional<SandboxExtension::Handle> containerManagerExtensionHandle;
std::optional<SandboxExtension::Handle> mobileGestaltExtensionHandle;
std::optional<SandboxExtension::Handle> launchServicesExtensionHandle;
+#if PLATFORM(MAC) && HAVE(VIDEO_RESTRICTED_DECODING)
+ std::optional<SandboxExtension::Handle> trustdAgentExtensionHandle;
+#endif
SandboxExtension::HandleArray diagnosticsExtensionHandles;
#if PLATFORM(IOS_FAMILY)
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (279029 => 279030)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2021-06-18 02:06:58 UTC (rev 279029)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2021-06-18 04:09:24 UTC (rev 279030)
@@ -454,6 +454,12 @@
parameters.launchServicesExtensionHandle = WTFMove(launchServicesExtensionHandle);
#endif
+#if PLATFORM(MAC) && HAVE(VIDEO_RESTRICTED_DECODING)
+ SandboxExtension::Handle trustdAgentExtensionHandle;
+ SandboxExtension::createHandleForMachLookup("com.apple.trustd.agent"_s, std::nullopt, trustdAgentExtensionHandle);
+ parameters.trustdAgentExtensionHandle = WTFMove(trustdAgentExtensionHandle);
+#endif
+
#if PLATFORM(IOS_FAMILY) && ENABLE(CFPREFS_DIRECT_MODE)
if ([UIApplication sharedApplication]) {
auto state = [[UIApplication sharedApplication] applicationState];
Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (279029 => 279030)
--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2021-06-18 02:06:58 UTC (rev 279029)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2021-06-18 04:09:24 UTC (rev 279030)
@@ -92,6 +92,7 @@
#import <pal/spi/cocoa/LaunchServicesSPI.h>
#import <pal/spi/cocoa/NSAccessibilitySPI.h>
#import <pal/spi/cocoa/QuartzCoreSPI.h>
+#import <pal/spi/cocoa/VideoToolboxSPI.h>
#import <pal/spi/cocoa/pthreadSPI.h>
#import <pal/spi/mac/NSApplicationSPI.h>
#import <stdio.h>
@@ -157,6 +158,7 @@
#import <WebCore/MediaAccessibilitySoftLink.h>
#import <pal/cf/AudioToolboxSoftLink.h>
+#import <pal/cf/VideoToolboxSoftLink.h>
#import <pal/cocoa/AVFoundationSoftLink.h>
#import <pal/cocoa/MediaToolboxSoftLink.h>
@@ -370,6 +372,21 @@
launchServicesExtension->revoke();
#endif
+#if PLATFORM(MAC) && HAVE(VIDEO_RESTRICTED_DECODING)
+ // Call FigPhotoSupportsHEVCHWDecode() while holding the trustd extension.
+ if (parameters.trustdAgentExtensionHandle) {
+ if (auto extension = SandboxExtension::create(WTFMove(*parameters.trustdAgentExtensionHandle))) {
+ bool ok = extension->consume();
+ // The purpose of calling this function is to initialize a static variable which needs
+ // the service com.apple.trustd.gent. And this is why we do not use its return value.
+ if (PAL::isMediaToolboxFrameworkAvailable() && PAL::canLoad_MediaToolbox_FigPhotoSupportsHEVCHWDecode())
+ PAL::softLinkMediaToolboxFigPhotoSupportsHEVCHWDecode();
+ ok = extension->revoke();
+ ASSERT_UNUSED(ok, ok);
+ }
+ }
+#endif
+
#if PLATFORM(MAC)
// App nap must be manually enabled when not running the NSApplication run loop.
__CFRunLoopSetOptionsReason(__CFRunLoopOptionsEnableAppNap, CFSTR("Finished checkin as application - enable app nap"));
@@ -724,6 +741,29 @@
#endif
}
+#if HAVE(VIDEO_RESTRICTED_DECODING)
+static inline void restrictImageAndVideoDecoders()
+{
+ if (!(PAL::isVideoToolboxFrameworkAvailable() && PAL::canLoad_VideoToolbox_VTRestrictVideoDecoders()))
+ return;
+
+ CMVideoCodecType allowedCodecTypeList[] = {
+ kCMVideoCodecType_H263,
+ kCMVideoCodecType_H264,
+ kCMVideoCodecType_MPEG4Video,
+ kCMVideoCodecType_HEVC,
+ kCMVideoCodecType_HEVCWithAlpha
+ };
+
+ PAL::softLinkVideoToolboxVTRestrictVideoDecoders(
+ kVTRestrictions_RunVideoDecodersInProcess |
+ kVTRestrictions_AvoidHardwareDecoders |
+ kVTRestrictions_AvoidHardwarePixelTransfer |
+ kVTRestrictions_AvoidIOSurfaceBackings,
+ allowedCodecTypeList, sizeof(allowedCodecTypeList) / sizeof(allowedCodecTypeList[0]));
+}
+#endif
+
void WebProcess::initializeSandbox(const AuxiliaryProcessInitializationParameters& parameters, SandboxInitializationParameters& sandboxParameters)
{
#if PLATFORM(MAC) || PLATFORM(MACCATALYST)
@@ -740,6 +780,10 @@
AuxiliaryProcess::initializeSandbox(parameters, sandboxParameters);
#endif
+
+#if HAVE(VIDEO_RESTRICTED_DECODING)
+ restrictImageAndVideoDecoders();
+#endif
}
#if PLATFORM(MAC)