REGRESSION (r238955, r240494): Soft-linking optional Lookup.framework triggers releas...
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Feb 2019 19:58:19 +0000 (19:58 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Feb 2019 19:58:19 +0000 (19:58 +0000)
<https://webkit.org/b/194529>
<rdar://problem/47924449>

Reviewed by Eric Carlson.

Source/WebCore:

* SourcesCocoa.txt:
- Do not include DataDetectorsCoreSoftLink.mm in unified
  sources.
* WebCore.xcodeproj/project.pbxproj:
- Add DataDetectorsCoreSoftLink.mm to the WebCore target now
  that it isn't part of the unifed sources.
* platform/cocoa/DataDetectorsCoreSoftLink.mm:
- Switch from using SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL() to
  SOFT_LINK_PRIVATE_FRAMEWORK_FOR_SOURCE() when linking
  DataDetectorsCore.framework. None of the other macros assume
  this framework is optional, and it was likely made optional
  originally because the framework was new to iOS and thus
  didn't exist on older versions.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
- Change use of SOFT_LINK_CLASS_FOR_SOURCE() macros to
  SOFT_LINK_CLASS() since the latter can only be used with
  SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation).  This broke after
  the fix for <wtf/SoftLinking.h> was applied.

Source/WTF:

* wtf/cocoa/SoftLinking.h:
(SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_IS_OPTIONAL): Rename
SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_ASSERTION() to this
and change `assertion` argument to `isOptional`.  Pass
`isOptional` to framework##Library() method to control assertion
behavior.  Only check RELEASE_ASSERT() if `!isOptional`, else
that code should be optimized out by the compiler.  This fixes
the crash.
(NO_ASSERT): Remove macro since it's no longer used.
(SOFT_LINK_IS_OPTIONAL): Add macro to use for soft-linking
optional classes.
(SOFT_LINK_IS_NOT_OPTIONAL): Add macro to use for soft-linking
non-optional classes.
(SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT): Update to use new
SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_IS_OPTIONAL() macro.
(SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT): Ditto.
(SOFT_LINK_CLASS_FOR_SOURCE): Ditto.
(SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL): Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241309 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/cocoa/SoftLinking.h
Source/WebCore/ChangeLog
Source/WebCore/SourcesCocoa.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/cocoa/DataDetectorsCoreSoftLink.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

index 473a915..7e0e7de 100644 (file)
@@ -1,3 +1,30 @@
+2019-02-12  David Kilzer  <ddkilzer@apple.com>
+
+        REGRESSION (r238955, r240494): Soft-linking optional Lookup.framework triggers release assertion when missing
+        <https://webkit.org/b/194529>
+        <rdar://problem/47924449>
+
+        Reviewed by Eric Carlson.
+
+        * wtf/cocoa/SoftLinking.h:
+        (SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_IS_OPTIONAL): Rename
+        SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_ASSERTION() to this
+        and change `assertion` argument to `isOptional`.  Pass
+        `isOptional` to framework##Library() method to control assertion
+        behavior.  Only check RELEASE_ASSERT() if `!isOptional`, else
+        that code should be optimized out by the compiler.  This fixes
+        the crash.
+        (NO_ASSERT): Remove macro since it's no longer used.
+        (SOFT_LINK_IS_OPTIONAL): Add macro to use for soft-linking
+        optional classes.
+        (SOFT_LINK_IS_NOT_OPTIONAL): Add macro to use for soft-linking
+        non-optional classes.
+        (SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT): Update to use new
+        SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_IS_OPTIONAL() macro.
+        (SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT): Ditto.
+        (SOFT_LINK_CLASS_FOR_SOURCE): Ditto.
+        (SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL): Ditto.
+
 2019-02-12  Andy Estes  <aestes@apple.com>
 
         [iOSMac] Enable Parental Controls Content Filtering
index c028cd3..e008322 100644 (file)
     } \
     }
 
-#define SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_ASSERTION(functionNamespace, framework, className, export, assertion) \
+#define SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_IS_OPTIONAL(functionNamespace, framework, className, export, isOptional) \
     @class className; \
     namespace functionNamespace { \
     static Class init##className(); \
     { \
         static dispatch_once_t once; \
         dispatch_once(&once, ^{ \
-            framework##Library(); \
+            framework##Library(isOptional); \
             class##className = objc_getClass(#className); \
-            assertion(class##className); \
+            if (!isOptional) \
+                RELEASE_ASSERT(class##className); \
             get##className##Class = className##Function; \
         }); \
         return class##className; \
     } \
     }
 
-#define NO_ASSERT(assertion) (void(0))
+#define SOFT_LINK_IS_OPTIONAL true
+#define SOFT_LINK_IS_NOT_OPTIONAL false
 
 #define SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(functionNamespace, framework, className, export) \
-    SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_ASSERTION(functionNamespace, framework, className, export, RELEASE_ASSERT)
+    SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_IS_OPTIONAL(functionNamespace, framework, className, export, SOFT_LINK_IS_NOT_OPTIONAL)
 
 #define SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT(functionNamespace, framework, className, export) \
-    SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_ASSERTION(functionNamespace, framework, className, export, NO_ASSERT)
+    SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_IS_OPTIONAL(functionNamespace, framework, className, export, SOFT_LINK_IS_OPTIONAL)
 
 #define SOFT_LINK_CLASS_FOR_SOURCE(functionNamespace, framework, className) \
-    SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_ASSERTION(functionNamespace, framework, className, , RELEASE_ASSERT)
+    SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_IS_OPTIONAL(functionNamespace, framework, className, , SOFT_LINK_IS_NOT_OPTIONAL)
 
 #define SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL(functionNamespace, framework, className) \
-    SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_ASSERTION(functionNamespace, framework, className, , NO_ASSERT)
+    SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT_AND_IS_OPTIONAL(functionNamespace, framework, className, , SOFT_LINK_IS_OPTIONAL)
 
 #define SOFT_LINK_CONSTANT_FOR_HEADER(functionNamespace, framework, variableName, variableType) \
     namespace functionNamespace { \
index ac86387..ce16291 100644 (file)
@@ -1,3 +1,30 @@
+2019-02-12  David Kilzer  <ddkilzer@apple.com>
+
+        REGRESSION (r238955, r240494): Soft-linking optional Lookup.framework triggers release assertion when missing
+        <https://webkit.org/b/194529>
+        <rdar://problem/47924449>
+
+        Reviewed by Eric Carlson.
+
+        * SourcesCocoa.txt:
+        - Do not include DataDetectorsCoreSoftLink.mm in unified
+          sources.
+        * WebCore.xcodeproj/project.pbxproj:
+        - Add DataDetectorsCoreSoftLink.mm to the WebCore target now
+          that it isn't part of the unifed sources.
+        * platform/cocoa/DataDetectorsCoreSoftLink.mm:
+        - Switch from using SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL() to
+          SOFT_LINK_PRIVATE_FRAMEWORK_FOR_SOURCE() when linking
+          DataDetectorsCore.framework. None of the other macros assume
+          this framework is optional, and it was likely made optional
+          originally because the framework was new to iOS and thus
+          didn't exist on older versions.
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        - Change use of SOFT_LINK_CLASS_FOR_SOURCE() macros to
+          SOFT_LINK_CLASS() since the latter can only be used with
+          SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation).  This broke after
+          the fix for <wtf/SoftLinking.h> was applied.
+
 2019-02-12  Youenn Fablet  <youenn@apple.com>
 
         Make use of is<SubresourceLoader>
index de38abf..91496da 100644 (file)
@@ -189,7 +189,7 @@ platform/cf/SharedBufferCF.cpp
 
 platform/cocoa/ContentFilterUnblockHandlerCocoa.mm @no-unify
 platform/cocoa/CoreVideoSoftLink.cpp
-platform/cocoa/DataDetectorsCoreSoftLink.mm
+platform/cocoa/DataDetectorsCoreSoftLink.mm @no-unify
 platform/cocoa/FileMonitorCocoa.mm
 platform/cocoa/KeyEventCocoa.mm
 platform/cocoa/LocalizedStringsCocoa.mm
index 0273cbb..ac2e224 100644 (file)
                43EDD67F1B485DBF00640E75 /* CombinedFiltersAlphabet.h in Headers */ = {isa = PBXBuildFile; fileRef = 43EDD67D1B485DBF00640E75 /* CombinedFiltersAlphabet.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4415292E0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4415292C0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
                445775E520472F73008DCE5D /* LocalDefaultSystemAppearance.h in Headers */ = {isa = PBXBuildFile; fileRef = 445775E420472F73008DCE5D /* LocalDefaultSystemAppearance.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               4463CF682212FA68001A8577 /* DataDetectorsCoreSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C7941E21C56C29300A4C58E /* DataDetectorsCoreSoftLink.mm */; };
                4471710E205AF945000A116E /* MediaQueryParserContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 4471710C205AF945000A116E /* MediaQueryParserContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
                447958041643B49A001E0A7F /* ParsedContentType.h in Headers */ = {isa = PBXBuildFile; fileRef = 447958031643B47B001E0A7F /* ParsedContentType.h */; settings = {ATTRIBUTES = (Private, ); }; };
                448A29BF0A46D9CB0030759F /* JSHTMLOptionsCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 448A29BD0A46D9CB0030759F /* JSHTMLOptionsCollection.h */; settings = {ATTRIBUTES = (Private, ); }; };
                                46C696CC1E7205FC00597937 /* CPUMonitor.cpp in Sources */,
                                1ABA76CA11D20E50004C201C /* CSSPropertyNames.cpp in Sources */,
                                BE23480C18A9870B00E4B6E8 /* DataCue.cpp in Sources */,
+                               4463CF682212FA68001A8577 /* DataDetectorsCoreSoftLink.mm in Sources */,
                                E58B45BB20AD07DD00991025 /* DataListButtonElement.cpp in Sources */,
                                515BE18F1D54F5FB00DD7C68 /* EmptyGamepadProvider.cpp in Sources */,
                                724ED32C1A3A7E5400F5F13C /* EXTBlendMinMax.cpp in Sources */,
index f40ebcd..893e38c 100644 (file)
@@ -28,7 +28,7 @@
 
 #if PLATFORM(IOS_FAMILY) && ENABLE(DATA_DETECTION)
 
-SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(DataDetectorsCore)
+SOFT_LINK_PRIVATE_FRAMEWORK_FOR_SOURCE(WebCore, DataDetectorsCore)
 
 SOFT_LINK_CLASS_FOR_SOURCE(WebCore, DataDetectorsCore, DDScannerResult)
 SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, DataDetectorsCore, DDScannerCreate, DDScannerRef, (DDScannerType type, DDScannerOptions options, CFErrorRef * errorRef), (type, options, errorRef))
index fd484d7..770f637 100644 (file)
@@ -154,14 +154,14 @@ SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
 
 SOFT_LINK_FRAMEWORK_OPTIONAL(CoreImage)
 
-SOFT_LINK_CLASS_FOR_SOURCE(WebCore, AVFoundation, AVPlayer)
-SOFT_LINK_CLASS_FOR_SOURCE(WebCore, AVFoundation, AVPlayerItem)
-SOFT_LINK_CLASS_FOR_SOURCE(WebCore, AVFoundation, AVPlayerItemVideoOutput)
-SOFT_LINK_CLASS_FOR_SOURCE(WebCore, AVFoundation, AVPlayerLayer)
-SOFT_LINK_CLASS_FOR_SOURCE(WebCore, AVFoundation, AVURLAsset)
-SOFT_LINK_CLASS_FOR_SOURCE(WebCore, AVFoundation, AVAssetImageGenerator)
-SOFT_LINK_CLASS_FOR_SOURCE(WebCore, AVFoundation, AVMetadataItem)
-SOFT_LINK_CLASS_FOR_SOURCE(WebCore, AVFoundation, AVAssetCache)
+SOFT_LINK_CLASS(AVFoundation, AVPlayer)
+SOFT_LINK_CLASS(AVFoundation, AVPlayerItem)
+SOFT_LINK_CLASS(AVFoundation, AVPlayerItemVideoOutput)
+SOFT_LINK_CLASS(AVFoundation, AVPlayerLayer)
+SOFT_LINK_CLASS(AVFoundation, AVURLAsset)
+SOFT_LINK_CLASS(AVFoundation, AVAssetImageGenerator)
+SOFT_LINK_CLASS(AVFoundation, AVMetadataItem)
+SOFT_LINK_CLASS(AVFoundation, AVAssetCache)
 
 SOFT_LINK_CLASS(CoreImage, CIContext)
 SOFT_LINK_CLASS(CoreImage, CIImage)