WebKit Bugzilla
Attachment 341142 Details for
Bug 185839
: Avoid loading AVFoundation to check supported MIME types if possible
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for landing
bug-185839-20180523160100.patch (text/plain), 33.74 KB, created by
Eric Carlson
on 2018-05-23 16:01:01 PDT
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Eric Carlson
Created:
2018-05-23 16:01:01 PDT
Size:
33.74 KB
patch
obsolete
>Subversion Revision: 232123 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 9f565cb33660bcc23520d305551e72c0ce471697..e14c0a09eed6d35bdfede9690bb354620c334b4f 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,13 @@ >+2018-05-23 Eric Carlson <eric.carlson@apple.com> >+ >+ Avoid loading AVFoundation to check supported MIME types if possible >+ https://bugs.webkit.org/show_bug.cgi?id=185839 >+ <rdar://problem/40182010> >+ >+ Reviewed by Jer Noble. >+ >+ * wtf/cocoa/SoftLinking.h: Add SOFT_LINK_FRAMEWORK_OPTIONAL_PREFLIGHT. >+ > 2018-05-23 Michael Saboff <msaboff@apple.com> > > Date.parse() doesn't properly handle input outside of ES Spec limits >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 894ae700af9d610da747ec7560936e244b7e4c75..2d702e7e2ad04742afd0071c66cf5723fb30ebe4 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,59 @@ >+2018-05-23 Eric Carlson <eric.carlson@apple.com> >+ >+ Avoid loading AVFoundation to check supported MIME types if possible >+ https://bugs.webkit.org/show_bug.cgi?id=185839 >+ <rdar://problem/40182010> >+ >+ Reviewed by Jer Noble. >+ >+ Avoid loading AVFoundation to call +[AVURLAssetClass audiovisualMIMETypes] as long as possible, >+ and when they are loaded send the list to the UI process so it can pass it to all extant >+ and all new web processes so they can won't have call it at all. >+ >+ * WebCore.xcodeproj/project.pbxproj: >+ * platform/graphics/ImageDecoder.cpp: >+ (WebCore::ImageDecoder::create): Don't call ImageDecoderAVFObjC::canDecodeType if >+ ImageDecoderCG can decode the type so we don't have to load AVFoundation. >+ (WebCore::ImageDecoder::supportsMediaType): Return as soon as a decoder class says >+ it supports a media type to avoid calling more than one. Call ImageDecoderAVFObjC last. >+ >+ * platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.h: >+ (WebCore::AVFoundationMIMETypeCache::setCacheMIMETypesCallback): >+ * platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.mm: >+ (WebCore::AVFoundationMIMETypeCache::singleton): Simplify. >+ (WebCore::AVFoundationMIMETypeCache::setSupportedTypes): Cache the supplied list of types >+ so we won't have to load AVFoundation when asked for types later. >+ (WebCore::AVFoundationMIMETypeCache::types): >+ (WebCore::AVFoundationMIMETypeCache::supportsContentType): New convenience routine. >+ (WebCore::AVFoundationMIMETypeCache::canDecodeType): Ditto. >+ (WebCore::AVFoundationMIMETypeCache::isAvailable const): New, check to see if AVFoundation.framework >+ is available without actually loading it. >+ (WebCore::AVFoundationMIMETypeCache::loadMIMETypes): Load types if possible. >+ (WebCore::AVFoundationMIMETypeCache::AVFoundationMIMETypeCache): Deleted. >+ (WebCore::AVFoundationMIMETypeCache::loadTypes): Deleted. >+ >+ * platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm: >+ (WebCore::ImageDecoderAVFObjC::create): Use AVFoundationMIMETypeCache::isAvailable instead >+ of loading the frameworks. >+ (WebCore::ImageDecoderAVFObjC::supportsMediaType): Ditto. >+ (WebCore::ImageDecoderAVFObjC::supportsContentType): Use AVFoundationMIMETypeCache::supportsContentType. >+ (WebCore::ImageDecoderAVFObjC::canDecodeType): Use AVFoundationMIMETypeCache::canDecodeType. >+ >+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::registerMediaEngine): ASSERT if the >+ AVFoundationMIMETypeCache is empty, it shouldn't be possible to get here in that state. >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::supportsType): Use AVFoundationMIMETypeCache::supportsContentType. >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::supportsKeySystem): Use AVFoundationMIMETypeCache::canDecodeType. >+ >+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine): ASSERT if the >+ AVFoundationMIMETypeCache is empty, it shouldn't be possible to get here in that state. >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsType): Use AVFoundationMIMETypeCache::canDecodeType. >+ >+ * platform/graphics/cg/ImageDecoderCG.cpp: >+ (WebCore::ImageDecoderCG::canDecodeType): New. >+ * platform/graphics/cg/ImageDecoderCG.h: >+ > 2018-05-23 Chris Dumez <cdumez@apple.com> > > RenderLayer::scrollRectToVisible() should not propagate a subframe's scroll to its cross-origin parent >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 28edc121fb15a8f0eb2d55a69bcdbd5d0cc360e3..f17b7749415826afa2d0ff9c60ca85cea19cffd8 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,40 @@ >+2018-05-23 Eric Carlson <eric.carlson@apple.com> >+ >+ Avoid loading AVFoundation to check supported MIME types if possible >+ https://bugs.webkit.org/show_bug.cgi?id=185839 >+ <rdar://problem/40182010> >+ >+ Reviewed by Jer Noble. >+ >+ * Shared/WebProcessCreationParameters.cpp: >+ (WebKit::WebProcessCreationParameters::encode const): Encode mediaMIMETypes. >+ (WebKit::WebProcessCreationParameters::decode): Decode mediaMIMETypes. >+ * Shared/WebProcessCreationParameters.h: >+ >+ * UIProcess/Cocoa/WebProcessProxyCocoa.mm: >+ (WebKit::mediaTypeCache): Static Vector of media MIME types. >+ (WebKit::WebProcessProxy::cacheMediaMIMETypes): Cache the type list and pass it to every other >+ process proxy. >+ (WebKit::WebProcessProxy::cacheMediaMIMETypesInternal): Cache the type list and pass it to the >+ web process. >+ (WebKit::WebProcessProxy::mediaMIMETypes): Return the cached type list. >+ >+ * UIProcess/WebProcessPool.cpp: >+ (WebKit::WebProcessPool::initializeNewWebProcess): Set parameters.mediaMIMETypes. >+ >+ * UIProcess/WebProcessProxy.h: >+ * UIProcess/WebProcessProxy.messages.in: Add CacheMediaMIMETypes. >+ >+ * WebProcess/WebProcess.h: >+ * WebProcess/WebProcess.messages.in: Add SetMediaMIMETypes. >+ >+ * WebProcess/cocoa/WebProcessCocoa.mm: >+ (WebKit::WebProcess::platformInitializeWebProcess): Cache the MIME types if the list isn't >+ empty, else register with AVFoundationMIMETypeCache to be notified when it loads types. >+ AVFoundationMIMETypeCache to >+ (WebKit::WebProcess::platformTerminate): Unregister with AVFoundationMIMETypeCache. >+ (WebKit::WebProcess::setMediaMIMETypes): Pass list of types to AVFoundationMIMETypeCache. >+ > 2018-05-23 Youenn Fablet <youenn@apple.com> > > NetworkLoadChecker should check cached redirections >diff --git a/Source/WTF/wtf/cocoa/SoftLinking.h b/Source/WTF/wtf/cocoa/SoftLinking.h >index f2285769a8ca7b9f3871cea72b6bff82bf9373c1..7a6cdcf4f12fa8d9434c281d7fb10a74c58ef903 100644 >--- a/Source/WTF/wtf/cocoa/SoftLinking.h >+++ b/Source/WTF/wtf/cocoa/SoftLinking.h >@@ -63,6 +63,13 @@ > return frameworkLibrary; \ > } > >+#define SOFT_LINK_FRAMEWORK_OPTIONAL_PREFLIGHT(framework) \ >+ static bool framework##LibraryIsAvailable() \ >+ { \ >+ static bool frameworkLibraryIsAvailable = dlopen_preflight("/System/Library/Frameworks/" #framework ".framework/" #framework); \ >+ return frameworkLibraryIsAvailable; \ >+ } >+ > #define SOFT_LINK_FRAMEWORK_OPTIONAL(framework) \ > static void* framework##Library() \ > { \ >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 17d28949f5daf1c8ae92137fc31b0aaeac188af9..2fb724ccb3f2bfa566267bbbdf93fb8ab4b0907c 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -219,6 +219,7 @@ > 07EE76EC1BE96DB000F89133 /* MockRealtimeVideoSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 07EE76EA1BE96DB000F89133 /* MockRealtimeVideoSource.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 07EE76EF1BEA619800F89133 /* MockRealtimeVideoSourceMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 07EE76ED1BEA619800F89133 /* MockRealtimeVideoSourceMac.h */; }; > 07F04A942006B1E300AE2A0A /* ApplicationStateChangeListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 07F04A92200684BC00AE2A0A /* ApplicationStateChangeListener.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ 07F4E93320B3587F002E3803 /* AVFoundationMIMETypeCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 07C8AD121D073D630087C5CE /* AVFoundationMIMETypeCache.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 07F876841AD580F900905849 /* MediaPlaybackTargetContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 07F876831AD4A94500905849 /* MediaPlaybackTargetContext.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 07F944161864D046005D31CB /* PlatformMediaSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = CDAE8C081746B95700532D78 /* PlatformMediaSessionManager.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 07FE99DD18807A7D00256648 /* MediaElementSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 07FE99DB18807A7D00256648 /* MediaElementSession.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -27120,6 +27121,7 @@ > CDC675271EAEA9D400727C84 /* AVAudioSessionCaptureDevice.h in Headers */, > CDC675231EAEA9B700727C84 /* AVAudioSessionCaptureDeviceManager.h in Headers */, > 070363E2181A1CDC00C074A5 /* AVCaptureDeviceManager.h in Headers */, >+ 07F4E93320B3587F002E3803 /* AVFoundationMIMETypeCache.h in Headers */, > 070363E4181A1CDC00C074A5 /* AVMediaCaptureSource.h in Headers */, > CD336F6217F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h in Headers */, > 070363E6181A1CDC00C074A5 /* AVVideoCaptureSource.h in Headers */, >diff --git a/Source/WebCore/platform/graphics/ImageDecoder.cpp b/Source/WebCore/platform/graphics/ImageDecoder.cpp >index 2d9ce16da7008f7d0d0864d2ad1fcc1a146dfeb8..c54b3888744b458018b7c46dc1d96332fc3e853c 100644 >--- a/Source/WebCore/platform/graphics/ImageDecoder.cpp >+++ b/Source/WebCore/platform/graphics/ImageDecoder.cpp >@@ -42,11 +42,11 @@ namespace WebCore { > > RefPtr<ImageDecoder> ImageDecoder::create(SharedBuffer& data, const String& mimeType, AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) > { >+ UNUSED_PARAM(mimeType); >+ > #if HAVE(AVASSETREADER) >- if (ImageDecoderAVFObjC::canDecodeType(mimeType)) >+ if (!ImageDecoderCG::canDecodeType(mimeType) && ImageDecoderAVFObjC::canDecodeType(mimeType)) > return ImageDecoderAVFObjC::create(data, mimeType, alphaOption, gammaAndColorProfileOption); >-#else >- UNUSED_PARAM(mimeType); > #endif > > #if USE(CG) >@@ -60,24 +60,23 @@ RefPtr<ImageDecoder> ImageDecoder::create(SharedBuffer& data, const String& mime > > bool ImageDecoder::supportsMediaType(MediaType type) > { >- bool supports = false; >-#if HAVE(AVASSETREADER) >- if (ImageDecoderAVFObjC::supportsMediaType(type)) >- supports = true; >-#endif >- > #if USE(CG) > if (ImageDecoderCG::supportsMediaType(type)) >- supports = true; >+ return true; > #elif USE(DIRECT2D) > if (ImageDecoderDirect2D::supportsMediaType(type)) >- supports = true; >+ return true; > #else > if (ScalableImageDecoder::supportsMediaType(type)) >- supports = true; >+ return true; >+#endif >+ >+#if HAVE(AVASSETREADER) >+ if (ImageDecoderAVFObjC::supportsMediaType(type)) >+ return true; > #endif > >- return supports; >+ return false; > } > > } >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.h b/Source/WebCore/platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.h >index 2888a29601fd16a12ff23af0009963acb77a105a..6732da0c441524d881115b09ea43609b6f2109bd 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.h >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.h >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2016 Apple Inc. All rights reserved. >+ * Copyright (C) 2016-2018 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -23,10 +23,9 @@ > * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > */ > >-#ifndef AVFoundationMIMETypeCache_h >-#define AVFoundationMIMETypeCache_h >+#pragma once > >-#if ENABLE(VIDEO) && USE(AVFOUNDATION) >+#if PLATFORM(COCOA) > > #include <wtf/Forward.h> > #include <wtf/HashSet.h> >@@ -34,24 +33,34 @@ > > namespace WebCore { > >+class ContentType; >+ > class AVFoundationMIMETypeCache { > public: >- static AVFoundationMIMETypeCache& singleton(); >+ WEBCORE_EXPORT static AVFoundationMIMETypeCache& singleton(); > >- AVFoundationMIMETypeCache(); >+ bool supportsContentType(const ContentType&); >+ bool canDecodeType(const String&); > >- void loadTypes(); > const HashSet<String, ASCIICaseInsensitiveHash>& types(); >+ bool isEmpty(); >+ bool isAvailable() const; >+ >+ using CacheMIMETypesCallback = std::function<void(const Vector<String>&)>; >+ void setCacheMIMETypesCallback(CacheMIMETypesCallback&& callback) { m_cacheTypeCallback = WTFMove(callback); } >+ >+ WEBCORE_EXPORT void setSupportedTypes(const Vector<String>&); > > private: >- enum MIMETypeLoadStatus { NotLoaded, Loading, Loaded }; >+ friend NeverDestroyed<AVFoundationMIMETypeCache>; >+ AVFoundationMIMETypeCache() = default; > >- MIMETypeLoadStatus m_status { NotLoaded }; >- dispatch_queue_t m_loaderQueue; >- Lock m_lock; >- HashSet<String, ASCIICaseInsensitiveHash> m_cache; >+ void loadMIMETypes(); >+ >+ std::optional<HashSet<String, ASCIICaseInsensitiveHash>> m_cache; >+ CacheMIMETypesCallback m_cacheTypeCallback; > }; > > } >-#endif >+ > #endif >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.mm b/Source/WebCore/platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.mm >index fce787144df5cf8265fcb2f1f121e30bdb25f288..1b710c896a1c1bb6b1874c6a33bc8b03b7e69d78 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.mm >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2016 Apple Inc. All rights reserved. >+ * Copyright (C) 2016-2018 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -26,70 +26,95 @@ > #import "config.h" > #import "AVFoundationMIMETypeCache.h" > >-#if ENABLE(VIDEO) && USE(AVFOUNDATION) >+#if PLATFORM(COCOA) > >+#import "ContentType.h" > #import <AVFoundation/AVAsset.h> > #import <wtf/HashSet.h> >-#import <wtf/Locker.h> >-#import <wtf/NeverDestroyed.h> > > #import <pal/cf/CoreMediaSoftLink.h> > >+#if ENABLE(VIDEO) && USE(AVFOUNDATION) >+SOFT_LINK_FRAMEWORK_OPTIONAL_PREFLIGHT(AVFoundation) > SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation) > SOFT_LINK_CLASS(AVFoundation, AVURLAsset) >+#endif > > namespace WebCore { > >-using namespace PAL; >- >-AVFoundationMIMETypeCache::AVFoundationMIMETypeCache() >+AVFoundationMIMETypeCache& AVFoundationMIMETypeCache::singleton() > { >- m_loaderQueue = dispatch_queue_create("WebCoreAudioVisualMIMETypes loader queue", DISPATCH_QUEUE_SERIAL); >+ static NeverDestroyed<AVFoundationMIMETypeCache> cache; >+ return cache.get(); > } > >-void AVFoundationMIMETypeCache::loadTypes() >+void AVFoundationMIMETypeCache::setSupportedTypes(const Vector<String>& types) > { >- { >- Locker<Lock> lock(m_lock); >+ if (m_cache) >+ return; > >- if (m_status != NotLoaded) >- return; >+ m_cache = HashSet<String, ASCIICaseInsensitiveHash>(); >+ for (auto& type : types) >+ m_cache->add(type); >+} > >- if (!AVFoundationLibrary()) { >- m_status = Loaded; >- return; >- } >+const HashSet<String, ASCIICaseInsensitiveHash>& AVFoundationMIMETypeCache::types() >+{ >+ if (!m_cache) >+ loadMIMETypes(); > >- m_status = Loading; >- } >+ return *m_cache; >+} > >- dispatch_async(m_loaderQueue, [this] { >- for (NSString *type in [getAVURLAssetClass() audiovisualMIMETypes]) >- m_cache.add(type); >- m_lock.lock(); >- m_status = Loaded; >- m_lock.unlock(); >- }); >+bool AVFoundationMIMETypeCache::supportsContentType(const ContentType& contentType) >+{ >+ if (contentType.isEmpty()) >+ return false; >+ >+ return types().contains(contentType.containerType()); > } > >-const HashSet<String, ASCIICaseInsensitiveHash>& AVFoundationMIMETypeCache::types() >+bool AVFoundationMIMETypeCache::canDecodeType(const String& mimeType) > { >- m_lock.lock(); >- MIMETypeLoadStatus status = m_status; >- m_lock.unlock(); >+ if (mimeType.isEmpty()) >+ return false; > >- if (status != Loaded) { >- loadTypes(); >- dispatch_sync(m_loaderQueue, ^{ }); >- } >+ if (!isAvailable() || !types().contains(ContentType { mimeType }.containerType())) >+ return false; > >- return m_cache; >+#if ENABLE(VIDEO) && USE(AVFOUNDATION) >+ return [getAVURLAssetClass() isPlayableExtendedMIMEType:mimeType]; >+#endif >+ >+ return false; > } > >-AVFoundationMIMETypeCache& AVFoundationMIMETypeCache::singleton() >+bool AVFoundationMIMETypeCache::isAvailable() const > { >- static NeverDestroyed<AVFoundationMIMETypeCache> cache; >- return cache.get(); >+#if ENABLE(VIDEO) && USE(AVFOUNDATION) >+ return AVFoundationLibraryIsAvailable(); >+#else >+ return false; >+#endif >+} >+ >+void AVFoundationMIMETypeCache::loadMIMETypes() >+{ >+ m_cache = HashSet<String, ASCIICaseInsensitiveHash>(); >+ >+#if ENABLE(VIDEO) && USE(AVFOUNDATION) >+ static std::once_flag onceFlag; >+ std::call_once(onceFlag, [this] { >+ if (!AVFoundationLibrary()) >+ return; >+ >+ for (NSString* type in [getAVURLAssetClass() audiovisualMIMETypes]) >+ m_cache->add(type); >+ >+ if (m_cacheTypeCallback) >+ m_cacheTypeCallback(copyToVector(*m_cache)); >+ }); >+#endif > } > > } >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm >index 6368cb46b2fa6bd8144821a60573f63c94ce0e3c..53bb05040bb79131da8f795ac76aea4570634e2b 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm >@@ -319,7 +319,7 @@ ImageDecoderAVFObjCSample* toSample(Iterator iter) > RefPtr<ImageDecoderAVFObjC> ImageDecoderAVFObjC::create(SharedBuffer& data, const String& mimeType, AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) > { > // AVFoundation may not be available at runtime. >- if (!getAVURLAssetClass()) >+ if (!AVFoundationMIMETypeCache::singleton().isAvailable()) > return nullptr; > > if (!canLoad_VideoToolbox_VTCreateCGImageFromCVPixelBuffer()) >@@ -350,24 +350,17 @@ ImageDecoderAVFObjC::~ImageDecoderAVFObjC() = default; > > bool ImageDecoderAVFObjC::supportsMediaType(MediaType type) > { >- if (type == MediaType::Video) >- return getAVURLAssetClass() && canLoad_VideoToolbox_VTCreateCGImageFromCVPixelBuffer(); >- return false; >+ return type == MediaType::Video && AVFoundationMIMETypeCache::singleton().isAvailable(); > } > > bool ImageDecoderAVFObjC::supportsContentType(const ContentType& type) > { >- if (getAVURLAssetClass() && canLoad_VideoToolbox_VTCreateCGImageFromCVPixelBuffer()) >- return AVFoundationMIMETypeCache::singleton().types().contains(type.containerType()); >- return false; >+ return AVFoundationMIMETypeCache::singleton().supportsContentType(type); > } > > bool ImageDecoderAVFObjC::canDecodeType(const String& mimeType) > { >- if (!supportsMediaType(MediaType::Video)) >- return nullptr; >- >- return [getAVURLAssetClass() isPlayableExtendedMIMEType:mimeType]; >+ return AVFoundationMIMETypeCache::singleton().canDecodeType(mimeType); > } > > AVAssetTrack *ImageDecoderAVFObjC::firstEnabledTrack() >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm >index 57fd3cfaf26d0647049c0624c6404378ebfa960c..5b2225138920edc33267ee83343420bd6688a01e 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm >@@ -397,7 +397,7 @@ void MediaPlayerPrivateAVFoundationObjC::registerMediaEngine(MediaEngineRegistra > > registrar([](MediaPlayer* player) { return std::make_unique<MediaPlayerPrivateAVFoundationObjC>(player); }, > getSupportedTypes, supportsType, originsInMediaCache, clearMediaCache, clearMediaCacheForOrigins, supportsKeySystem); >- AVFoundationMIMETypeCache::singleton().loadTypes(); >+ ASSERT(AVFoundationMIMETypeCache::singleton().isAvailable()); > } > > static AVAssetCacheType *assetCacheForPath(const String& path) >@@ -1681,7 +1681,7 @@ MediaPlayer::SupportsType MediaPlayerPrivateAVFoundationObjC::supportsType(const > if (isUnsupportedMIMEType(containerType)) > return MediaPlayer::IsNotSupported; > >- if (!staticMIMETypeList().contains(containerType) && !AVFoundationMIMETypeCache::singleton().types().contains(containerType)) >+ if (!staticMIMETypeList().contains(containerType) && !AVFoundationMIMETypeCache::singleton().canDecodeType(containerType)) > return MediaPlayer::IsNotSupported; > > // The spec says: >@@ -1710,7 +1710,7 @@ bool MediaPlayerPrivateAVFoundationObjC::supportsKeySystem(const String& keySyst > if (!mimeType.isEmpty() && isUnsupportedMIMEType(mimeType)) > return false; > >- if (!mimeType.isEmpty() && !staticMIMETypeList().contains(mimeType) && !AVFoundationMIMETypeCache::singleton().types().contains(mimeType)) >+ if (!mimeType.isEmpty() && !staticMIMETypeList().contains(mimeType) && !AVFoundationMIMETypeCache::singleton().canDecodeType(mimeType)) > return false; > > return true; >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm >index 5979722ac5bffe386f5480aafa1a66d0c2c442bc..b9d725d0706f00fe892a9674d4d2ff47d6a47283 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm >@@ -191,7 +191,7 @@ void MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine(MediaEngineRegist > > registrar([](MediaPlayer* player) { return std::make_unique<MediaPlayerPrivateMediaSourceAVFObjC>(player); }, > getSupportedTypes, supportsType, 0, 0, 0, 0); >- AVFoundationMIMETypeCache::singleton().loadTypes(); >+ ASSERT(AVFoundationMIMETypeCache::singleton().isAvailable()); > } > > bool MediaPlayerPrivateMediaSourceAVFObjC::isAvailable() >@@ -219,7 +219,7 @@ MediaPlayer::SupportsType MediaPlayerPrivateMediaSourceAVFObjC::supportsType(con > return MediaPlayer::IsNotSupported; > #endif > >- if (parameters.type.isEmpty() || !AVFoundationMIMETypeCache::singleton().types().contains(parameters.type.containerType())) >+ if (parameters.type.isEmpty() || !AVFoundationMIMETypeCache::singleton().canDecodeType(parameters.type.containerType())) > return MediaPlayer::IsNotSupported; > > // The spec says: >diff --git a/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp b/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp >index ed33e7f2a56370211f32e750694e33e1a75d1feb..6c757c48475df99e80b87d3f58205439ec0b45a0 100644 >--- a/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp >+++ b/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp >@@ -33,6 +33,7 @@ > #include "IntPoint.h" > #include "IntSize.h" > #include "Logging.h" >+#include "MIMETypeRegistry.h" > #include "SharedBuffer.h" > #include "UTIRegistry.h" > #include <pal/spi/cg/ImageIOSPI.h> >@@ -480,6 +481,11 @@ void ImageDecoderCG::setData(SharedBuffer& data, bool allDataReceived) > #endif > } > >+bool ImageDecoderCG::canDecodeType(const String& mimeType) >+{ >+ return MIMETypeRegistry::isSupportedImageMIMEType(mimeType); >+} >+ > } > > #endif // USE(CG) >diff --git a/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h b/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h >index 3e0132e38e1938e550d8cc0121d3f5c84cbb2135..eac32d55c42d1b2ea8b7529a1d1cdd10efa2c6d6 100644 >--- a/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h >+++ b/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h >@@ -40,7 +40,8 @@ public: > } > > static bool supportsMediaType(MediaType type) { return type == MediaType::Image; } >- >+ static bool canDecodeType(const String&); >+ > size_t bytesDecodedToDetermineProperties() const final; > > EncodedDataStatus encodedDataStatus() const final; >diff --git a/Source/WebKit/Shared/WebProcessCreationParameters.cpp b/Source/WebKit/Shared/WebProcessCreationParameters.cpp >index 9a1659706ee6ee0b3a6166417f60ff89774017aa..801e610d5e02a84156febbbdd69f6c6f779bee0f 100644 >--- a/Source/WebKit/Shared/WebProcessCreationParameters.cpp >+++ b/Source/WebKit/Shared/WebProcessCreationParameters.cpp >@@ -154,6 +154,10 @@ void WebProcessCreationParameters::encode(IPC::Encoder& encoder) const > #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED > encoder << shouldLogUserInteraction; > #endif >+ >+#if PLATFORM(COCOA) >+ encoder << mediaMIMETypes; >+#endif > } > > bool WebProcessCreationParameters::decode(IPC::Decoder& decoder, WebProcessCreationParameters& parameters) >@@ -401,6 +405,11 @@ bool WebProcessCreationParameters::decode(IPC::Decoder& decoder, WebProcessCreat > return false; > #endif > >+#if PLATFORM(COCOA) >+ if (!decoder.decode(parameters.mediaMIMETypes)) >+ return false; >+#endif >+ > return true; > } > >diff --git a/Source/WebKit/Shared/WebProcessCreationParameters.h b/Source/WebKit/Shared/WebProcessCreationParameters.h >index 81d347e2f207aaf9ef5e558546d1f71f55a7c80c..e250237e48d112554e38f542125ec238eeca0c97 100644 >--- a/Source/WebKit/Shared/WebProcessCreationParameters.h >+++ b/Source/WebKit/Shared/WebProcessCreationParameters.h >@@ -185,6 +185,10 @@ struct WebProcessCreationParameters { > WebCore::SoupNetworkProxySettings proxySettings; > #endif > >+#if PLATFORM(COCOA) >+ Vector<String> mediaMIMETypes; >+#endif >+ > #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED > bool shouldLogUserInteraction { false }; > #endif >diff --git a/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm b/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm >index cdfb215d0c7d0e39705f9eb335ebdace2bfbc30c..9de5f20033a71295a3765e5466481f60670a986d 100644 >--- a/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm >+++ b/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm >@@ -31,6 +31,8 @@ > #import "WKBrowsingContextControllerInternal.h" > #import "WKBrowsingContextHandleInternal.h" > #import "WKTypeRefWrapper.h" >+#import "WebProcessMessages.h" >+#import "WebProcessPool.h" > #import <sys/sysctl.h> > #import <wtf/NeverDestroyed.h> > >@@ -137,4 +139,37 @@ bool WebProcessProxy::platformIsBeingDebugged() const > return info.kp_proc.p_flag & P_TRACED; > } > >+static Vector<String>& mediaTypeCache() >+{ >+ ASSERT(RunLoop::isMain()); >+ static NeverDestroyed<Vector<String>> typeCache; >+ return typeCache; >+} >+ >+void WebProcessProxy::cacheMediaMIMETypes(const Vector<String>& types) >+{ >+ if (!mediaTypeCache().isEmpty()) >+ return; >+ >+ mediaTypeCache() = types; >+ for (auto& process : processPool().processes()) { >+ if (process != this) >+ cacheMediaMIMETypesInternal(types); >+ } >+} >+ >+void WebProcessProxy::cacheMediaMIMETypesInternal(const Vector<String>& types) >+{ >+ if (!mediaTypeCache().isEmpty()) >+ return; >+ >+ mediaTypeCache() = types; >+ send(Messages::WebProcess::SetMediaMIMETypes(types), 0); >+} >+ >+Vector<String> WebProcessProxy::mediaMIMETypes() >+{ >+ return mediaTypeCache(); >+} >+ > } >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index c8b19f8858e7c699cefb46a83bc7f8b86030ec1e..82e4e046241ee209f5d789c63d0eb783b4feb71c 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -1313,6 +1313,10 @@ public: > > WebCore::IntRect syncRootViewToScreen(const WebCore::IntRect& viewRect); > >+#if PLATFORM(COCOA) >+ Vector<String> mediaMIMETypes(); >+#endif >+ > private: > WebPageProxy(PageClient&, WebProcessProxy&, uint64_t pageID, Ref<API::PageConfiguration>&&); > void platformInitialize(); >diff --git a/Source/WebKit/UIProcess/WebProcessPool.cpp b/Source/WebKit/UIProcess/WebProcessPool.cpp >index c561bcb5014301cccba8920bf69ebbb4e8f5243a..be7e135ad633d3b1cf29b25d3886ee79956dd784 100644 >--- a/Source/WebKit/UIProcess/WebProcessPool.cpp >+++ b/Source/WebKit/UIProcess/WebProcessPool.cpp >@@ -939,6 +939,10 @@ void WebProcessPool::initializeNewWebProcess(WebProcessProxy& process, WebsiteDa > > parameters.presentingApplicationPID = m_configuration->presentingApplicationPID(); > >+#if PLATFORM(COCOA) >+ parameters.mediaMIMETypes = process.mediaMIMETypes(); >+#endif >+ > // Add any platform specific parameters > platformInitializeWebProcess(parameters); > >diff --git a/Source/WebKit/UIProcess/WebProcessProxy.h b/Source/WebKit/UIProcess/WebProcessProxy.h >index 323df12867ab565ff70e82d7b66b9aaf5c5ab8d4..dcfecef25ce4dc3cc77b2b5d568514bd3a3eedd3 100644 >--- a/Source/WebKit/UIProcess/WebProcessProxy.h >+++ b/Source/WebKit/UIProcess/WebProcessProxy.h >@@ -221,6 +221,11 @@ public: > bool isInPrewarmedPool() const { return m_isInPrewarmedPool; } > void setIsInPrewarmedPool(bool isInPrewarmedPool) { m_isInPrewarmedPool = isInPrewarmedPool; } > >+#if PLATFORM(COCOA) >+ Vector<String> mediaMIMETypes(); >+ void cacheMediaMIMETypes(const Vector<String>&); >+#endif >+ > protected: > static uint64_t generatePageID(); > WebProcessProxy(WebProcessPool&, WebsiteDataStore&, IsInPrewarmedPool); >@@ -233,6 +238,10 @@ protected: > // ProcessLauncher::Client > void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) override; > >+#if PLATFORM(COCOA) >+ void cacheMediaMIMETypesInternal(const Vector<String>&); >+#endif >+ > private: > // Called when the web process has crashed or we know that it will terminate soon. > // Will potentially cause the WebProcessProxy object to be freed. >diff --git a/Source/WebKit/UIProcess/WebProcessProxy.messages.in b/Source/WebKit/UIProcess/WebProcessProxy.messages.in >index edb05a706534b151b05eb3e63263e392783e658d..9e539f58bbb85829929da3a232e831346fd777c2 100644 >--- a/Source/WebKit/UIProcess/WebProcessProxy.messages.in >+++ b/Source/WebKit/UIProcess/WebProcessProxy.messages.in >@@ -66,4 +66,8 @@ messages -> WebProcessProxy LegacyReceiver { > CheckRemotePortForActivity(struct WebCore::MessagePortIdentifier port, uint64_t callbackIdentifier) > DidDeliverMessagePortMessages(uint64_t messageBatchIdentifier) > DidCheckProcessLocalPortForActivity(uint64_t callbackIdentifier, bool isLocallyReachable) >+ >+#if PLATFORM(COCOA) >+ CacheMediaMIMETypes(Vector<String> types) >+#endif > } >diff --git a/Source/WebKit/WebProcess/WebProcess.h b/Source/WebKit/WebProcess/WebProcess.h >index 9928225fb2d6d898037cf76e97fe611faee86fdc..6738e29ecfa1dc1b0f9c578bc7b6566a8aad910c 100644 >--- a/Source/WebKit/WebProcess/WebProcess.h >+++ b/Source/WebKit/WebProcess/WebProcess.h >@@ -240,6 +240,10 @@ public: > void accessibilityProcessSuspendedNotification(bool); > #endif > >+#if PLATFORM(COCOA) >+ void setMediaMIMETypes(const Vector<String>); >+#endif >+ > private: > WebProcess(); > ~WebProcess(); >diff --git a/Source/WebKit/WebProcess/WebProcess.messages.in b/Source/WebKit/WebProcess/WebProcess.messages.in >index fa4c0662238aa82fcbb5b84b0fbf3afc08238a00..493116f0e2b27abdfa691e9b37e177389efd7617 100644 >--- a/Source/WebKit/WebProcess/WebProcess.messages.in >+++ b/Source/WebKit/WebProcess/WebProcess.messages.in >@@ -135,4 +135,8 @@ messages -> WebProcess LegacyReceiver { > ScrollerStylePreferenceChanged(bool useOvelayScrollbars) > #endif > #endif >+ >+#if PLATFORM(COCOA) >+ SetMediaMIMETypes(Vector<String> types) >+#endif > } >diff --git a/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm b/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm >index 2431b901f47d89a58d7dd347e4f786b5c7a722e8..f5fad3c510a055941997b184ebcd3af732a6c253 100644 >--- a/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm >+++ b/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm >@@ -48,6 +48,7 @@ > #import "WebsiteDataStoreParameters.h" > #import <JavaScriptCore/ConfigFile.h> > #import <JavaScriptCore/Options.h> >+#import <WebCore/AVFoundationMIMETypeCache.h> > #import <WebCore/AXObjectCache.h> > #import <WebCore/CPUMonitor.h> > #import <WebCore/FileSystem.h> >@@ -181,6 +182,14 @@ void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&& par > // Priority decay on iOS 9 is impacting page load time so we fix the priority of the WebProcess' main thread (rdar://problem/22003112). > pthread_set_fixedpriority_self(); > #endif >+ >+ if (!parameters.mediaMIMETypes.isEmpty()) >+ setMediaMIMETypes(parameters.mediaMIMETypes); >+ else { >+ AVFoundationMIMETypeCache::singleton().setCacheMIMETypesCallback([this](const Vector<String>& types) { >+ parentProcessConnection()->send(Messages::WebProcessProxy::CacheMediaMIMETypes(types), 0); >+ }); >+ } > } > > void WebProcess::initializeProcessName(const ChildProcessInitializationParameters& parameters) >@@ -334,6 +343,7 @@ void WebProcess::stopRunLoop() > > void WebProcess::platformTerminate() > { >+ AVFoundationMIMETypeCache::singleton().setCacheMIMETypesCallback(nullptr); > } > > RetainPtr<CFDataRef> WebProcess::sourceApplicationAuditData() const >@@ -577,4 +587,9 @@ void WebProcess::scrollerStylePreferenceChanged(bool useOverlayScrollbars) > } > #endif > >+void WebProcess::setMediaMIMETypes(const Vector<String> types) >+{ >+ AVFoundationMIMETypeCache::singleton().setSupportedTypes(types); >+} >+ > } // namespace WebKit
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
ews-watchlist
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185839
:
340895
|
340907
|
340908
|
340915
|
340919
|
341124
|
341126
|
341132
|
341133
|
341138
|
341139
| 341142 |
341152