Diff
Modified: trunk/Source/WebCore/ChangeLog (270938 => 270939)
--- trunk/Source/WebCore/ChangeLog 2020-12-17 19:10:53 UTC (rev 270938)
+++ trunk/Source/WebCore/ChangeLog 2020-12-17 20:14:24 UTC (rev 270939)
@@ -1,3 +1,39 @@
+2020-12-17 Eric Carlson <[email protected]>
+
+ [Cocoa] WebM format reader doesn't work with a url in a <source> element
+ https://bugs.webkit.org/show_bug.cgi?id=219961
+ <rdar://problem/72399014>
+
+ Reviewed by Andy Estes.
+
+ Work around a bug that makes the format reader fail to load when the AVURLAssetOutOfBandMIMETypeKey
+ is included in the AVURLAsset options dictionary. Also include some cleanup:
+ - Move the code to check for WebM MIME types from MediaPlayerPrivateAVFoundationObjC
+ to AVAssetMIMETypeCache.
+ - Don't use RuntimeEnabledFeatures in MediaPlayerPrivateAVFoundationObjC.
+ - Register the WebM format reader when creating an AVURLAsset for a WebM url instead
+ of when checking the MIME type.
+ - Cleanup WebM "codecs" parameter parsing.
+
+ * platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.h:
+ * platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm:
+ (WebCore::AVAssetMIMETypeCache::canDecodeExtendedType):
+ (WebCore::AVAssetMIMETypeCache::staticContainerTypeList):
+ (WebCore::AVAssetMIMETypeCache::setWebMFormatReaderEnabled):
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::registerFormatReaderIfNecessary):
+ (WebCore::shouldAdvertiseOutOfBandMIMEType):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::supportsTypeAndCodecs):
+ (WebCore::ensureFormatReaderIsRegistered): Deleted.
+ (WebCore::isFormatReaderAvailable): Deleted.
+ * platform/graphics/cocoa/SourceBufferParserWebM.cpp:
+ (WebCore::SourceBufferParserWebM::setWebMFormatReaderEnabled):
+ (WebCore::SourceBufferParserWebM::webmMIMETypes):
+ (WebCore::SourceBufferParserWebM::isWebMFormatReaderAvailable):
+ (WebCore::SourceBufferParserWebM::isContentTypeSupported):
+ * platform/graphics/cocoa/SourceBufferParserWebM.h:
+
2020-12-17 Chris Dumez <[email protected]>
[GPUProcess] Replace WebAudio rendering timer with a cross-process semaphore
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.h (270938 => 270939)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.h 2020-12-17 19:10:53 UTC (rev 270938)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.h 2020-12-17 20:14:24 UTC (rev 270939)
@@ -45,6 +45,8 @@
bool isUnsupportedContainerType(const String&) final;
void addSupportedTypes(const Vector<String>&);
+
+ void setWebMFormatReaderEnabled(bool);
private:
friend NeverDestroyed<AVAssetMIMETypeCache>;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm (270938 => 270939)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm 2020-12-17 19:10:53 UTC (rev 270938)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm 2020-12-17 20:14:24 UTC (rev 270939)
@@ -29,6 +29,7 @@
#if PLATFORM(COCOA)
#import "ContentType.h"
+#import "SourceBufferParserWebM.h"
#import <pal/cf/CoreMediaSoftLink.h>
#import <pal/cocoa/AVFoundationSoftLink.h>
@@ -63,9 +64,16 @@
{
#if ENABLE(VIDEO) && USE(AVFOUNDATION)
ASSERT(isAvailable());
- return [PAL::getAVURLAssetClass() isPlayableExtendedMIMEType:type.raw()];
+ if ([PAL::getAVURLAssetClass() isPlayableExtendedMIMEType:type.raw()])
+ return true;
+
+#if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER)
+ if (SourceBufferParserWebM::isContentTypeSupported(type) == MediaPlayerEnums::SupportsType::IsSupported)
+ return true;
#endif
+#endif // ENABLE(VIDEO) && USE(AVFOUNDATION)
+
return false;
}
@@ -148,11 +156,28 @@
for (NSString* type in [PAL::getAVURLAssetClass() audiovisualMIMETypes])
cache.add(type);
+#if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER)
+ if (SourceBufferParserWebM::isWebMFormatReaderAvailable()) {
+ auto webmTypes = SourceBufferParserWebM::webmMIMETypes();
+ cache.add(webmTypes.begin(), webmTypes.end());
+ }
+#endif
+
if (m_cacheTypeCallback)
m_cacheTypeCallback(copyToVector(cache));
#endif
}
+void AVAssetMIMETypeCache::setWebMFormatReaderEnabled(bool enabled)
+{
+#if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER)
+ SourceBufferParserWebM::setWebMFormatReaderEnabled(enabled);
+#else
+ UNUSED_PARAM(enabled);
+#endif
}
+
+}
+
#endif
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (270938 => 270939)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2020-12-17 19:10:53 UTC (rev 270938)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2020-12-17 20:14:24 UTC (rev 270939)
@@ -56,7 +56,6 @@
#import "PixelBufferConformerCV.h"
#import "PlatformTimeRanges.h"
#import "RuntimeApplicationChecks.h"
-#import "RuntimeEnabledFeatures.h"
#import "SecurityOrigin.h"
#import "SerializedPlatformDataCueMac.h"
#import "SharedBuffer.h"
@@ -100,7 +99,6 @@
#import <wtf/OSObjectPtr.h>
#import <wtf/URL.h>
#import <wtf/cocoa/VectorCocoa.h>
-#import <wtf/spi/darwin/OSVariantSPI.h>
#import <wtf/text/CString.h>
#import <wtf/threads/BinarySemaphore.h>
@@ -270,6 +268,20 @@
return globalQueue;
}
+static void registerFormatReaderIfNecessary()
+{
+#if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER)
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ // Like we do for other media formats, allow the format reader to run in the WebContent or GPU process
+ // (which is already appropriately sandboxed) rather than in a separate MediaToolbox XPC service.
+ RELEASE_ASSERT(isInGPUProcess() || isInWebProcess());
+ MTRegisterPluginFormatReaderBundleDirectory((__bridge CFURLRef)NSBundle.mainBundle.builtInPlugInsURL);
+ MTPluginFormatReaderDisableSandboxing();
+ });
+#endif
+}
+
class MediaPlayerPrivateAVFoundationObjC::Factory final : public MediaPlayerFactory {
private:
MediaPlayerEnums::MediaEngineIdentifier identifier() const final { return MediaPlayerEnums::MediaEngineIdentifier::AVFoundation; };
@@ -792,6 +804,19 @@
}
+static bool willUseWebMFormatReaderForType(const String& type)
+{
+#if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER)
+ if (!SourceBufferParserWebM::isWebMFormatReaderAvailable())
+ return false;
+
+ return equalIgnoringASCIICase(type, "video/webm") || equalIgnoringASCIICase(type, "audio/webm");
+#else
+ UNUSED_PARAM(type);
+ return false;
+#endif
+}
+
void MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL(const URL& url, RetainPtr<NSMutableDictionary> options)
{
ALWAYS_LOG(LOGIDENTIFIER);
@@ -833,7 +858,11 @@
#endif
auto type = player()->contentMIMEType();
- if (PAL::canLoad_AVFoundation_AVURLAssetOutOfBandMIMETypeKey() && !type.isEmpty() && !player()->contentMIMETypeWasInferredFromExtension()) {
+
+ // Don't advertise WebM MIME types or the format reader won't be loaded until rdar://72405127 is fixed.
+ auto willUseWebMFormatReader = willUseWebMFormatReaderForType(type);
+
+ if (PAL::canLoad_AVFoundation_AVURLAssetOutOfBandMIMETypeKey() && !type.isEmpty() && !player()->contentMIMETypeWasInferredFromExtension() && !willUseWebMFormatReader) {
auto codecs = player()->contentTypeCodecs();
if (!codecs.isEmpty()) {
NSString *typeString = [NSString stringWithFormat:@"%@; codecs=\"%@\"", (NSString *)type, (NSString *)codecs];
@@ -876,6 +905,9 @@
[options setObject:@NO forKey:AVURLAssetUsesNoPersistentCacheKey];
}
+ if (willUseWebMFormatReader)
+ registerFormatReaderIfNecessary();
+
NSURL *cocoaURL = canonicalURL(url);
m_avAsset = adoptNS([PAL::allocAVURLAssetInstance() initWithURL:cocoaURL options:options.get()]);
@@ -1667,39 +1699,6 @@
}
#endif
-#if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER)
-static void ensureFormatReaderIsRegistered()
-{
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- // Like we do for other media formats, allow the format reader to run in the WebContent or GPU process
- // (which is already appropriately sandboxed) rather than in a separate MediaToolbox XPC service.
- RELEASE_ASSERT(isInGPUProcess() || isInWebProcess());
- MTRegisterPluginFormatReaderBundleDirectory((__bridge CFURLRef)NSBundle.mainBundle.builtInPlugInsURL);
- MTPluginFormatReaderDisableSandboxing();
- });
-}
-#endif
-
-#if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER)
-static bool isFormatReaderAvailable()
-{
- if (!RuntimeEnabledFeatures::sharedFeatures().webMFormatReaderEnabled())
- return false;
-
-#if !USE(APPLE_INTERNAL_SDK)
- // FIXME (rdar://72320419): If WebKit was built with ad-hoc code-signing,
- // CoreMedia will only load the format reader plug-in when a user default
- // is set on Apple internal OSs. That means we cannot currently support WebM
- // in public SDK builds on customer OSs.
- if (!os_variant_allows_internal_security_policies("com.apple.WebKit"))
- return false;
-#endif
-
- return true;
-}
-#endif
-
MediaPlayer::SupportsType MediaPlayerPrivateAVFoundationObjC::supportsTypeAndCodecs(const MediaEngineSupportParameters& parameters)
{
#if ENABLE(MEDIA_SOURCE)
@@ -1711,19 +1710,6 @@
return MediaPlayer::SupportsType::IsNotSupported;
#endif
-#if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER)
- if (isFormatReaderAvailable()) {
- auto supported = SourceBufferParserWebM::isContentTypeSupported(parameters.type);
- if (supported != MediaPlayer::SupportsType::IsNotSupported) {
- ensureFormatReaderIsRegistered();
- if (supported == MediaPlayer::SupportsType::MayBeSupported)
- return supported;
- if (contentTypeMeetsHardwareDecodeRequirements(parameters.type, parameters.contentTypesRequiringHardwareSupport))
- return MediaPlayer::SupportsType::IsSupported;
- }
- }
-#endif
-
auto supported = AVAssetMIMETypeCache::singleton().canDecodeType(parameters.type.raw());
if (supported != MediaPlayer::SupportsType::IsSupported)
return supported;
Modified: trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp (270938 => 270939)
--- trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp 2020-12-17 19:10:53 UTC (rev 270938)
+++ trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp 2020-12-17 20:14:24 UTC (rev 270939)
@@ -48,6 +48,7 @@
#include <wtf/StdList.h>
#include <wtf/cf/TypeCastsCF.h>
#include <wtf/darwin/WeakLinking.h>
+#include <wtf/spi/darwin/OSVariantSPI.h>
#include "CoreVideoSoftLink.h"
#include "VideoToolboxSoftLink.h"
@@ -443,6 +444,59 @@
webm::TrackEntry m_track;
};
+bool SourceBufferParserWebM::m_formatReaderEnabled;
+
+void SourceBufferParserWebM::setWebMFormatReaderEnabled(bool enabled)
+{
+#if HAVE(MT_PLUGIN_FORMAT_READER)
+ m_formatReaderEnabled = enabled;
+#else
+ UNUSED_PARAM(enabled);
+#endif
+}
+
+const HashSet<String, ASCIICaseInsensitiveHash>& SourceBufferParserWebM::webmMIMETypes()
+{
+ static auto types = makeNeverDestroyed([] {
+
+ HashSet<String, ASCIICaseInsensitiveHash> types;
+
+#if ENABLE(VP9)
+ types.add("video/webm");
+#endif
+#if ENABLE(VORBIS) || ENABLE(OPUS)
+ types.add("audio/webm");
+#endif
+
+ return types;
+ }());
+
+ return types;
+}
+
+static bool canLoadFormatReader()
+{
+#if !HAVE(MT_PLUGIN_FORMAT_READER)
+ return false;
+#endif
+
+#if USE(APPLE_INTERNAL_SDK)
+ return true;
+#else
+ // FIXME (rdar://72320419): If WebKit was built with ad-hoc code-signing,
+ // CoreMedia will only load the format reader plug-in when a user default
+ // is set on Apple internal OSs. That means we cannot currently support WebM
+ // in public SDK builds on customer OSs.
+ static bool allowsInternalSecurityPolicies = os_variant_allows_internal_security_policies("com.apple.WebKit");
+ return allowsInternalSecurityPolicies;
+#endif // !USE(APPLE_INTERNAL_SDK)
+}
+
+bool SourceBufferParserWebM::isWebMFormatReaderAvailable()
+{
+ return m_formatReaderEnabled && canLoadFormatReader() && isWebmParserAvailable();
+}
+
MediaPlayerEnums::SupportsType SourceBufferParserWebM::isContentTypeSupported(const ContentType& type)
{
#if ENABLE(VP9) || ENABLE(VORBIS) || ENABLE(OPUS)
@@ -449,8 +503,9 @@
if (!isWebmParserAvailable())
return MediaPlayerEnums::SupportsType::IsNotSupported;
- bool isAudioContainerType = WTF::equalIgnoringASCIICase(type.containerType(), "audio/webm");
- bool isVideoContainerType = WTF::equalIgnoringASCIICase(type.containerType(), "video/webm");
+ auto containerType = type.containerType();
+ bool isAudioContainerType = WTF::equalIgnoringASCIICase(containerType, "audio/webm");
+ bool isVideoContainerType = WTF::equalIgnoringASCIICase(containerType, "video/webm");
if (!isAudioContainerType && !isVideoContainerType)
return MediaPlayerEnums::SupportsType::IsNotSupported;
@@ -473,22 +528,18 @@
if (!isAnyCodecAvailable)
return MediaPlayerEnums::SupportsType::IsNotSupported;
- String codecsParameter = type.parameter(ContentType::codecsParameter());
- if (!codecsParameter)
+ auto codecs = type.codecs();
+ if (codecs.isEmpty())
return MediaPlayerEnums::SupportsType::MayBeSupported;
- auto splitResults = StringView(codecsParameter).split(',');
- if (splitResults.begin() == splitResults.end())
- return MediaPlayerEnums::SupportsType::MayBeSupported;
-
- for (auto split : splitResults) {
+ for (auto& codec : codecs) {
#if ENABLE(VP9)
- if (split.startsWith("vp09") || split.startsWith("vp08") || equal(split, "vp8") || equal(split, "vp9")) {
+ if (codec.startsWith("vp09") || codec.startsWith("vp08") || equal(codec, "vp8") || equal(codec, "vp9")) {
if (!isVP9DecoderAvailable())
return MediaPlayerEnums::SupportsType::IsNotSupported;
- auto codecParameters = parseVPCodecParameters(split);
+ auto codecParameters = parseVPCodecParameters(codec);
if (!codecParameters)
return MediaPlayerEnums::SupportsType::IsNotSupported;
@@ -500,7 +551,7 @@
#endif // ENABLE(VP9)
#if ENABLE(VORBIS)
- if (split == "vorbis") {
+ if (codec == "vorbis") {
if (!isVorbisDecoderAvailable())
return MediaPlayerEnums::SupportsType::IsNotSupported;
@@ -509,7 +560,7 @@
#endif // ENABLE(VORBIS)
#if ENABLE(OPUS)
- if (split == "opus") {
+ if (codec == "opus") {
if (!isOpusDecoderAvailable())
return MediaPlayerEnums::SupportsType::IsNotSupported;
Modified: trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.h (270938 => 270939)
--- trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.h 2020-12-17 19:10:53 UTC (rev 270938)
+++ trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.h 2020-12-17 20:14:24 UTC (rev 270939)
@@ -60,7 +60,10 @@
public:
class StreamingVectorReader;
+ static bool isWebMFormatReaderAvailable();
+ static void setWebMFormatReaderEnabled(bool);
static MediaPlayerEnums::SupportsType isContentTypeSupported(const ContentType&);
+ static const HashSet<String, ASCIICaseInsensitiveHash>& webmMIMETypes();
static RefPtr<SourceBufferParserWebM> create(const ContentType&);
SourceBufferParserWebM();
@@ -268,6 +271,8 @@
RefPtr<const WTF::Logger> m_logger;
const void* m_logIdentifier { nullptr };
+
+ static bool m_formatReaderEnabled;
};
}
Modified: trunk/Source/WebKit/ChangeLog (270938 => 270939)
--- trunk/Source/WebKit/ChangeLog 2020-12-17 19:10:53 UTC (rev 270938)
+++ trunk/Source/WebKit/ChangeLog 2020-12-17 20:14:24 UTC (rev 270939)
@@ -1,3 +1,16 @@
+2020-12-17 Eric Carlson <[email protected]>
+
+ [Cocoa] WebM format reader doesn't work with a url in a <source> element
+ https://bugs.webkit.org/show_bug.cgi?id=219961
+ <rdar://problem/72399014>
+
+ Reviewed by Andy Estes.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::updatePreferences):
+ * WebProcess/cocoa/WebProcessCocoa.mm:
+ (WebKit::WebProcess::platformInitializeWebProcess):
+
2020-12-17 Chris Dumez <[email protected]>
[GPUProcess] Replace WebAudio rendering timer with a cross-process semaphore
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (270938 => 270939)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2020-12-17 19:10:53 UTC (rev 270938)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2020-12-17 20:14:24 UTC (rev 270939)
@@ -341,6 +341,10 @@
#endif
#endif
+#if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER)
+#include <WebCore/AVAssetMIMETypeCache.h>
+#endif
+
namespace WebKit {
using namespace JSC;
using namespace WebCore;
@@ -3843,6 +3847,10 @@
settings.setWebAuthenticationEnabled(true);
}
#endif
+
+#if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER)
+ AVAssetMIMETypeCache::singleton().setWebMFormatReaderEnabled(RuntimeEnabledFeatures::sharedFeatures().webMFormatReaderEnabled());
+#endif
}
#if ENABLE(DATA_DETECTION)
Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (270938 => 270939)
--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2020-12-17 19:10:53 UTC (rev 270938)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2020-12-17 20:14:24 UTC (rev 270939)
@@ -69,6 +69,7 @@
#import <WebCore/PerformanceLogging.h>
#import <WebCore/PictureInPictureSupport.h>
#import <WebCore/RuntimeApplicationChecks.h>
+#import <WebCore/RuntimeEnabledFeatures.h>
#import <WebCore/SWContextManager.h>
#import <WebCore/SystemBattery.h>
#import <WebCore/SystemSoundManager.h>
@@ -328,6 +329,10 @@
pthread_set_fixedpriority_self();
#endif
+#if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER)
+ AVAssetMIMETypeCache::singleton().setWebMFormatReaderEnabled(RuntimeEnabledFeatures::sharedFeatures().webMFormatReaderEnabled());
+#endif
+
if (!parameters.mediaMIMETypes.isEmpty())
setMediaMIMETypes(parameters.mediaMIMETypes);
else {