WebKit Bugzilla
Attachment 340835 Details for
Bug 185817
: Wasted time dlopening AVFoundation the first time we try to decode an image
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185817-20180521023110.patch (text/plain), 7.34 KB, created by
Tim Horton
on 2018-05-21 02:31:38 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Tim Horton
Created:
2018-05-21 02:31:38 PDT
Size:
7.34 KB
patch
obsolete
>Subversion Revision: 231993 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 65ee6ad9f594df6adf1463d8182b12784c47768b..b6c3cf063ee92e6eb8b2afae692675b96ee47821 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,30 @@ >+2018-05-21 Tim Horton <timothy_horton@apple.com> >+ >+ Wasted time dlopening AVFoundation the first time we try to decode an image >+ https://bugs.webkit.org/show_bug.cgi?id=185817 >+ <rdar://problem/39933573> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No new tests, just a performance improvement. >+ >+ * platform/cocoa/VideoToolboxSoftLink.cpp: >+ * platform/cocoa/VideoToolboxSoftLink.h: >+ It looks like softlinking VTCreateCGImageFromCVPixelBuffer can't actually >+ fail anymore, so adjust the macro. >+ >+ * platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm: >+ (WebCore::ImageDecoderAVFObjC::create): >+ (WebCore::ImageDecoderAVFObjC::supportsMediaType): >+ Avoid loading AVFoundation and VideoToolbox just to determine if they exist. >+ They always do, so just say yes. >+ >+ (WebCore::ImageDecoderAVFObjC::supportsContentType): >+ (WebCore::ImageDecoderAVFObjC::canDecodeType): >+ Avoid loading AVFoundation to determine if it supports decoding a particular >+ MIME type if that is a known image MIME type that CoreGraphics or another >+ decoder can support. >+ > 2018-05-18 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r231982. >diff --git a/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.cpp b/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.cpp >index 23c4978ca7afb0f9fa6a5547772ad9fed65f1435..48ebc16fe18587c12d2bf029f630e0cbd0455be7 100644 >--- a/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.cpp >+++ b/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.cpp >@@ -43,7 +43,7 @@ SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, VideoToolbox, VTImageRotationSessionSetPr > SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, VideoToolbox, VTImageRotationSessionTransferImage, OSStatus, (VTImageRotationSessionRef session, CVPixelBufferRef sourceBuffer, CVPixelBufferRef destinationBuffer), (session, sourceBuffer, destinationBuffer)) > SOFT_LINK_FUNCTION_MAY_FAIL_FOR_SOURCE(WebCore, VideoToolbox, VTIsHardwareDecodeSupported, Boolean, (CMVideoCodecType codecType), (codecType)) > SOFT_LINK_FUNCTION_MAY_FAIL_FOR_SOURCE(WebCore, VideoToolbox, VTGetGVADecoderAvailability, OSStatus, (uint32_t* totalInstanceCountOut, uint32_t* freeInstanceCountOut), (totalInstanceCountOut, freeInstanceCountOut)) >-SOFT_LINK_FUNCTION_MAY_FAIL_FOR_SOURCE(WebCore, VideoToolbox, VTCreateCGImageFromCVPixelBuffer, OSStatus, (CVPixelBufferRef pixelBuffer, CFDictionaryRef options, CGImageRef* imageOut), (pixelBuffer, options, imageOut)) >+SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, VideoToolbox, VTCreateCGImageFromCVPixelBuffer, OSStatus, (CVPixelBufferRef pixelBuffer, CFDictionaryRef options, CGImageRef* imageOut), (pixelBuffer, options, imageOut)) > SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, VideoToolbox, kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder, CFStringRef) > SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, VideoToolbox, kVTDecompressionPropertyKey_PixelBufferPool, CFStringRef) > SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, VideoToolbox, kVTDecompressionPropertyKey_SuggestedQualityOfServiceTiers, CFStringRef) >diff --git a/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.h b/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.h >index 8f46a33ee89d7ccce09e7f67a7e22f0312a83829..c3afd70b6ed7f2db5e43fe0878e00e070310fd37 100644 >--- a/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.h >+++ b/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.h >@@ -54,7 +54,7 @@ SOFT_LINK_FUNCTION_MAY_FAIL_FOR_HEADER(WebCore, VideoToolbox, VTIsHardwareDecode > #define VTIsHardwareDecodeSupported softLink_VideoToolbox_VTIsHardwareDecodeSupported > SOFT_LINK_FUNCTION_MAY_FAIL_FOR_HEADER(WebCore, VideoToolbox, VTGetGVADecoderAvailability, OSStatus, (uint32_t* totalInstanceCountOut, uint32_t* freeInstanceCountOut), (totalInstanceCountOut, freeInstanceCountOut)) > #define VTGetGVADecoderAvailability softLink_VideoToolbox_VTGetGVADecoderAvailability >-SOFT_LINK_FUNCTION_MAY_FAIL_FOR_HEADER(WebCore, VideoToolbox, VTCreateCGImageFromCVPixelBuffer, OSStatus, (CVPixelBufferRef pixelBuffer, CFDictionaryRef options, CGImageRef* imageOut), (pixelBuffer, options, imageOut)) >+SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, VideoToolbox, VTCreateCGImageFromCVPixelBuffer, OSStatus, (CVPixelBufferRef pixelBuffer, CFDictionaryRef options, CGImageRef* imageOut), (pixelBuffer, options, imageOut)) > #define VTCreateCGImageFromCVPixelBuffer softLink_VideoToolbox_VTCreateCGImageFromCVPixelBuffer > SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, VideoToolbox, kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder, CFStringRef) > #define kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder get_VideoToolbox_kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder() >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm >index 6368cb46b2fa6bd8144821a60573f63c94ce0e3c..f99cc4a9f005957e0fb22223168a8cf7dc32df2c 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm >@@ -318,13 +318,6 @@ 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()) >- return nullptr; >- >- if (!canLoad_VideoToolbox_VTCreateCGImageFromCVPixelBuffer()) >- return nullptr; >- > return adoptRef(*new ImageDecoderAVFObjC(data, mimeType, alphaOption, gammaAndColorProfileOption)); > } > >@@ -350,22 +343,25 @@ ImageDecoderAVFObjC::~ImageDecoderAVFObjC() = default; > > bool ImageDecoderAVFObjC::supportsMediaType(MediaType type) > { >- if (type == MediaType::Video) >- return getAVURLAssetClass() && canLoad_VideoToolbox_VTCreateCGImageFromCVPixelBuffer(); >- return false; >+ return type == MediaType::Video; > } > > bool ImageDecoderAVFObjC::supportsContentType(const ContentType& type) > { >- if (getAVURLAssetClass() && canLoad_VideoToolbox_VTCreateCGImageFromCVPixelBuffer()) >- return AVFoundationMIMETypeCache::singleton().types().contains(type.containerType()); >- return false; >+ // We assume that image formats will be decoded by one of the other decoders, >+ // and use that fact to short-circuit here to avoid loading AVFoundation if possible. >+ if (MIMETypeRegistry::isSupportedImageMIMEType(type.containerType())) >+ return false; >+ >+ return AVFoundationMIMETypeCache::singleton().types().contains(type.containerType()); > } > > bool ImageDecoderAVFObjC::canDecodeType(const String& mimeType) > { >- if (!supportsMediaType(MediaType::Video)) >- return nullptr; >+ // We assume that image formats will be decoded by one of the other decoders, >+ // and use that fact to short-circuit here to avoid loading AVFoundation if possible. >+ if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType)) >+ return false; > > return [getAVURLAssetClass() isPlayableExtendedMIMEType:mimeType]; > }
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:
thorton
:
review-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185817
: 340835