Unable to run system Safari with trunk WebKit
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Apr 2019 20:44:34 +0000 (20:44 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Apr 2019 20:44:34 +0000 (20:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196777
<rdar://problem/49784574>

Reviewed by Alex Christensen.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]):
Add a linkedOnAfter check so that throwing exceptions when related web views use a different
data store only happens for apps rebuilt using recent SDK.

* UIProcess/Cocoa/VersionChecks.h:
* UIProcess/Cocoa/VersionChecks.mm:
(WebKit::linkedOnOrAfter):
- By default, linkedOnOrAfter assumed Safari / MobileSafari is always linked-on-after. To satisfy my
  use cases, I introduced a new AssumeSafariIsAlwaysLinkedOnAfter parameter so that this behavior can
  be controlled by the caller.
- In the header, DYLD_IOS_VERSION_* / DYLD_MACOS_VERSION_* constants are 0 when building with the
  non-internal SDK. As a result, the check instead linkedOnOrAfter() would cause us to always return
  true, which was wrong. I therefore updated the check inside linkedOnOrAfter() to special-case the
  0 value for sdkVersion.

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/Cocoa/VersionChecks.h
Source/WebKit/UIProcess/Cocoa/VersionChecks.mm

index 3920df8..5a7bd6f 100644 (file)
@@ -1,5 +1,29 @@
 2019-04-10  Chris Dumez  <cdumez@apple.com>
 
+        Unable to run system Safari with trunk WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=196777
+        <rdar://problem/49784574>
+
+        Reviewed by Alex Christensen.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _initializeWithConfiguration:]):
+        Add a linkedOnAfter check so that throwing exceptions when related web views use a different
+        data store only happens for apps rebuilt using recent SDK.
+
+        * UIProcess/Cocoa/VersionChecks.h:
+        * UIProcess/Cocoa/VersionChecks.mm:
+        (WebKit::linkedOnOrAfter):
+        - By default, linkedOnOrAfter assumed Safari / MobileSafari is always linked-on-after. To satisfy my
+          use cases, I introduced a new AssumeSafariIsAlwaysLinkedOnAfter parameter so that this behavior can
+          be controlled by the caller.
+        - In the header, DYLD_IOS_VERSION_* / DYLD_MACOS_VERSION_* constants are 0 when building with the
+          non-internal SDK. As a result, the check instead linkedOnOrAfter() would cause us to always return
+          true, which was wrong. I therefore updated the check inside linkedOnOrAfter() to special-case the
+          0 value for sdkVersion.
+
+2019-04-10  Chris Dumez  <cdumez@apple.com>
+
         Regression(r240562) Audio sometimes keeps playing in previous process after a process-swap
         https://bugs.webkit.org/show_bug.cgi?id=196774
         <rdar://problem/49460572>
index c9e098d..6bda245 100644 (file)
@@ -552,7 +552,7 @@ static void validate(WKWebViewConfiguration *configuration)
         WKProcessPool *relatedWebViewProcessPool = [relatedWebView->_configuration processPool];
         if (processPool && processPool != relatedWebViewProcessPool)
             [NSException raise:NSInvalidArgumentException format:@"Related web view %@ has process pool %@ but configuration specifies a different process pool %@", relatedWebView, relatedWebViewProcessPool, configuration.processPool];
-        if ([relatedWebView->_configuration websiteDataStore] != [_configuration websiteDataStore])
+        if ([relatedWebView->_configuration websiteDataStore] != [_configuration websiteDataStore] && linkedOnOrAfter(WebKit::SDKVersion::FirstWithExceptionsForRelatedWebViewsUsingDifferentDataStores, WebKit::AssumeSafariIsAlwaysLinkedOnAfter::No))
             [NSException raise:NSInvalidArgumentException format:@"Related web view %@ has data store %@ but configuration specifies a different data store %@", relatedWebView, [relatedWebView->_configuration websiteDataStore], [_configuration websiteDataStore]];
 
         [_configuration setProcessPool:relatedWebViewProcessPool];
index f4d4281..9003b14 100644 (file)
 #define DYLD_MACOS_VERSION_FIRST_WHERE_DOWNLOAD_ATTRIBUTE_DOES_NOT_OVERRIDE_NAVIGATION_DELEGATE 0
 #endif
 
+#ifndef DYLD_IOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES
+#define DYLD_IOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES 0
+#endif
+#ifndef DYLD_MACOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES
+#define DYLD_MACOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES 0
+#endif
+
 #ifndef DYLD_IOS_VERSION_FIRST_WITH_DEVICE_ORIENTATION_AND_MOTION_PERMISSION_API
 #define DYLD_IOS_VERSION_FIRST_WITH_DEVICE_ORIENTATION_AND_MOTION_PERMISSION_API 0
 #endif
@@ -63,6 +70,7 @@ enum class SDKVersion : uint32_t {
     FirstWhereDownloadAttributeDoesNotOverrideNavigationDelegate = DYLD_IOS_VERSION_FIRST_WHERE_DOWNLOAD_ATTRIBUTE_DOES_NOT_OVERRIDE_NAVIGATION_DELEGATE,
     FirstWithDeviceOrientationAndMotionPermissionAPI = DYLD_IOS_VERSION_FIRST_WITH_DEVICE_ORIENTATION_AND_MOTION_PERMISSION_API,
     FirstThatDecidesPolicyBeforeLoadingQuickLookPreview = DYLD_IOS_VERSION_FIRST_THAT_DECIDES_POLICY_BEFORE_LOADING_QUICK_LOOK_PREVIEW,
+    FirstWithExceptionsForRelatedWebViewsUsingDifferentDataStores = DYLD_IOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES,
 #elif PLATFORM(MAC)
     FirstWithNetworkCache = DYLD_MACOSX_VERSION_10_11,
     FirstWithExceptionsForDuplicateCompletionHandlerCalls = DYLD_MACOSX_VERSION_10_13,
@@ -71,9 +79,11 @@ enum class SDKVersion : uint32_t {
     FirstWithMainThreadReleaseAssertionInWebPageProxy = DYLD_MACOSX_VERSION_10_14,
     FirstWithSnapshotAfterScreenUpdates = DYLD_MACOS_VERSION_FIRST_WITH_SNAPSHOT_AFTER_SCREEN_UPDATES,
     FirstWhereDownloadAttributeDoesNotOverrideNavigationDelegate = DYLD_MACOS_VERSION_FIRST_WHERE_DOWNLOAD_ATTRIBUTE_DOES_NOT_OVERRIDE_NAVIGATION_DELEGATE,
+    FirstWithExceptionsForRelatedWebViewsUsingDifferentDataStores = DYLD_MACOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES,
 #endif
 };
 
-bool linkedOnOrAfter(SDKVersion);
+enum class AssumeSafariIsAlwaysLinkedOnAfter : bool { No, Yes };
+bool linkedOnOrAfter(SDKVersion, AssumeSafariIsAlwaysLinkedOnAfter = AssumeSafariIsAlwaysLinkedOnAfter::Yes);
 
 }
index 48e6bd8..0dd6537 100644 (file)
@@ -34,12 +34,12 @@ namespace WebKit {
 
 static NSString * const WebKitLinkedOnOrAfterEverythingKey = @"WebKitLinkedOnOrAfterEverything";
 
-bool linkedOnOrAfter(SDKVersion sdkVersion)
+bool linkedOnOrAfter(SDKVersion sdkVersion, AssumeSafariIsAlwaysLinkedOnAfter assumeSafariIsAlwaysLinkedOnAfter)
 {
-     static bool linkedOnOrAfterEverything;
-     static std::once_flag once;
-     std::call_once(once, [] {
-        bool isSafari = false;
+    static bool linkedOnOrAfterEverything = false;
+    static bool isSafari = false;
+    static std::once_flag once;
+    std::call_once(once, [] {
 #if PLATFORM(IOS_FAMILY)
         if (WebCore::IOSApplication::isMobileSafari())
             isSafari = true;
@@ -48,11 +48,18 @@ bool linkedOnOrAfter(SDKVersion sdkVersion)
             isSafari = true;
 #endif
 
-        if (isSafari || [[NSUserDefaults standardUserDefaults] boolForKey:WebKitLinkedOnOrAfterEverythingKey])
+        if ([[NSUserDefaults standardUserDefaults] boolForKey:WebKitLinkedOnOrAfterEverythingKey])
             linkedOnOrAfterEverything = true;
     });
 
-    return linkedOnOrAfterEverything ? true : dyld_get_program_sdk_version() >= static_cast<uint32_t>(sdkVersion);
+    if (UNLIKELY(linkedOnOrAfterEverything))
+        return true;
+
+    if (isSafari && assumeSafariIsAlwaysLinkedOnAfter == AssumeSafariIsAlwaysLinkedOnAfter::Yes)
+        return true;
+
+    auto sdkVersionAsInteger = static_cast<uint32_t>(sdkVersion);
+    return sdkVersionAsInteger && dyld_get_program_sdk_version() >= sdkVersionAsInteger;
 }
 
 }