Title: [262087] trunk/Source
Revision
262087
Author
[email protected]
Date
2020-05-22 16:21:27 -0700 (Fri, 22 May 2020)

Log Message

RELEASE_ASSERT() that InitializeWebKit2() is getting called on the main thread
https://bugs.webkit.org/show_bug.cgi?id=212283

Reviewed by Alex Christensen.

Source/WebKit:

RELEASE_ASSERT() that InitializeWebKit2() is getting called on the main thread, behind
a linked-on-after check. In r217137, we tried to add a dispatch_sync() to the main thread to
work around the issue but it was a hack and it can cause deadlocks. It is best to force
developers to fix their code by crashing.

* Shared/Cocoa/WebKit2InitializeCocoa.mm:
(WebKit::runInitializationCode):
(WebKit::InitializeWebKit2):
* UIProcess/Cocoa/VersionChecks.h:

Source/WTF:

* wtf/spi/darwin/dyldSPI.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (262086 => 262087)


--- trunk/Source/WTF/ChangeLog	2020-05-22 22:52:18 UTC (rev 262086)
+++ trunk/Source/WTF/ChangeLog	2020-05-22 23:21:27 UTC (rev 262087)
@@ -1,3 +1,12 @@
+2020-05-22  Chris Dumez  <[email protected]>
+
+        RELEASE_ASSERT() that InitializeWebKit2() is getting called on the main thread
+        https://bugs.webkit.org/show_bug.cgi?id=212283
+
+        Reviewed by Alex Christensen.
+
+        * wtf/spi/darwin/dyldSPI.h:
+
 2020-05-22  Andy Estes  <[email protected]>
 
         [Apple Pay] Add new ApplePayInstallmentConfiguration members

Modified: trunk/Source/WTF/wtf/spi/darwin/dyldSPI.h (262086 => 262087)


--- trunk/Source/WTF/wtf/spi/darwin/dyldSPI.h	2020-05-22 22:52:18 UTC (rev 262086)
+++ trunk/Source/WTF/wtf/spi/darwin/dyldSPI.h	2020-05-22 23:21:27 UTC (rev 262087)
@@ -77,6 +77,10 @@
 #define DYLD_MACOSX_VERSION_10_15_4 0x000A0F04
 #endif
 
+#ifndef DYLD_MACOSX_VERSION_10_16
+#define DYLD_MACOSX_VERSION_10_16 0x000a1000
+#endif
+
 #else
 
 #define DYLD_IOS_VERSION_3_0 0x00030000
@@ -102,6 +106,7 @@
 #define DYLD_MACOSX_VERSION_10_15 0x000A0F00
 #define DYLD_MACOSX_VERSION_10_15_1 0x000A0F01
 #define DYLD_MACOSX_VERSION_10_15_4 0x000A0F04
+#define DYLD_MACOSX_VERSION_10_16 0x000a1000
 
 #endif
 

Modified: trunk/Source/WebKit/ChangeLog (262086 => 262087)


--- trunk/Source/WebKit/ChangeLog	2020-05-22 22:52:18 UTC (rev 262086)
+++ trunk/Source/WebKit/ChangeLog	2020-05-22 23:21:27 UTC (rev 262087)
@@ -1,3 +1,20 @@
+2020-05-22  Chris Dumez  <[email protected]>
+
+        RELEASE_ASSERT() that InitializeWebKit2() is getting called on the main thread
+        https://bugs.webkit.org/show_bug.cgi?id=212283
+
+        Reviewed by Alex Christensen.
+
+        RELEASE_ASSERT() that InitializeWebKit2() is getting called on the main thread, behind
+        a linked-on-after check. In r217137, we tried to add a dispatch_sync() to the main thread to
+        work around the issue but it was a hack and it can cause deadlocks. It is best to force
+        developers to fix their code by crashing.
+
+        * Shared/Cocoa/WebKit2InitializeCocoa.mm:
+        (WebKit::runInitializationCode):
+        (WebKit::InitializeWebKit2):
+        * UIProcess/Cocoa/VersionChecks.h:
+
 2020-05-22  Alex Christensen  <[email protected]>
 
         Make download resume workaround forgiving of changes in CFNetwork

Modified: trunk/Source/WebKit/Shared/Cocoa/WebKit2InitializeCocoa.mm (262086 => 262087)


--- trunk/Source/WebKit/Shared/Cocoa/WebKit2InitializeCocoa.mm	2020-05-22 22:52:18 UTC (rev 262086)
+++ trunk/Source/WebKit/Shared/Cocoa/WebKit2InitializeCocoa.mm	2020-05-22 23:21:27 UTC (rev 262087)
@@ -27,6 +27,7 @@
 #import "WebKit2Initialize.h"
 
 #import "LogInitialization.h"
+#import "VersionChecks.h"
 #import <_javascript_Core/InitializeThreading.h>
 #import <WebCore/LogInitialization.h>
 #import <mutex>
@@ -44,6 +45,8 @@
 
 static void runInitializationCode(void* = nullptr)
 {
+    RELEASE_ASSERT_WITH_MESSAGE([NSThread isMainThread], "InitializeWebKit2 should be called on the main thread");
+
     AtomString::init();
 #if PLATFORM(IOS_FAMILY)
     InitWebCoreThreadSystemInterface();
@@ -65,7 +68,7 @@
     // Make sure the initialization code is run only once and on the main thread since things like RunLoop::initializeMainRunLoop()
     // are only safe to call on the main thread.
     std::call_once(flag, [] {
-        if ([NSThread isMainThread])
+        if ([NSThread isMainThread] || linkedOnOrAfter(SDKVersion::FirstWithInitializeWebKit2MainThreadAssertion))
             runInitializationCode();
         else
             dispatch_sync_f(dispatch_get_main_queue(), nullptr, runInitializationCode);

Modified: trunk/Source/WebKit/UIProcess/Cocoa/VersionChecks.h (262086 => 262087)


--- trunk/Source/WebKit/UIProcess/Cocoa/VersionChecks.h	2020-05-22 22:52:18 UTC (rev 262086)
+++ trunk/Source/WebKit/UIProcess/Cocoa/VersionChecks.h	2020-05-22 23:21:27 UTC (rev 262087)
@@ -93,6 +93,7 @@
     FirstThatRestrictsBaseURLSchemes = DYLD_IOS_VERSION_13_4,
     FirstWithSessionCleanupByDefault = DYLD_IOS_VERSION_FIRST_WITH_SESSION_CLEANUP_BY_DEFAULT,
     FirstThatSendsNativeMouseEvents = DYLD_IOS_VERSION_13_4,
+    FirstWithInitializeWebKit2MainThreadAssertion = DYLD_IOS_VERSION_14_0,
 #elif PLATFORM(MAC)
     FirstWithNetworkCache = DYLD_MACOSX_VERSION_10_11,
     FirstWithExceptionsForDuplicateCompletionHandlerCalls = DYLD_MACOSX_VERSION_10_13,
@@ -105,6 +106,7 @@
     FirstWhereSiteSpecificQuirksAreEnabledByDefault = DYLD_MACOSX_VERSION_10_15_1,
     FirstThatRestrictsBaseURLSchemes = DYLD_MACOSX_VERSION_10_15_4,
     FirstWithSessionCleanupByDefault = DYLD_MACOS_VERSION_FIRST_WITH_SESSION_CLEANUP_BY_DEFAULT,
+    FirstWithInitializeWebKit2MainThreadAssertion = DYLD_MACOSX_VERSION_10_16,
 #endif
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to