Web Inspector: Remote Inspector indicate callback should always happen on the main...
authorpecoraro@apple.com <pecoraro@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Apr 2019 12:42:38 +0000 (12:42 +0000)
committerpecoraro@apple.com <pecoraro@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Apr 2019 12:42:38 +0000 (12:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196513
<rdar://problem/49498284>

Reviewed by Devin Rousso.

Source/JavaScriptCore:

* inspector/remote/cocoa/RemoteInspectorCocoa.mm:
(Inspector::RemoteInspector::receivedIndicateMessage):
When we have a WebThread, don't just run on the WebThread,
run on the MainThread with the WebThreadLock.

Source/WebCore:

* platform/ios/wak/WebCoreThreadSystemInterface.cpp:
(InitWebCoreThreadSystemInterface):

Source/WTF:

* wtf/MainThread.h:
* wtf/cocoa/MainThreadCocoa.mm:
(WTF::dispatchAsyncOnMainThreadWithWebThreadLockIfNeeded):
* wtf/ios/WebCoreThread.cpp:
* wtf/ios/WebCoreThread.h:

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/remote/cocoa/RemoteInspectorCocoa.mm
Source/WTF/ChangeLog
Source/WTF/wtf/MainThread.h
Source/WTF/wtf/cocoa/MainThreadCocoa.mm
Source/WTF/wtf/ios/WebCoreThread.cpp
Source/WTF/wtf/ios/WebCoreThread.h
Source/WebCore/ChangeLog
Source/WebCore/platform/ios/wak/WebCoreThreadSystemInterface.cpp

index 76e22da..6761a59 100644 (file)
@@ -1,3 +1,16 @@
+2019-04-03  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Remote Inspector indicate callback should always happen on the main thread
+        https://bugs.webkit.org/show_bug.cgi?id=196513
+        <rdar://problem/49498284>
+
+        Reviewed by Devin Rousso.
+
+        * inspector/remote/cocoa/RemoteInspectorCocoa.mm:
+        (Inspector::RemoteInspector::receivedIndicateMessage):
+        When we have a WebThread, don't just run on the WebThread,
+        run on the MainThread with the WebThreadLock.
+
 2019-04-02  Michael Saboff  <msaboff@apple.com>
 
         Crash in Options::setOptions() using --configFile option and libgmalloc
index 60567bf..6466aaa 100644 (file)
@@ -592,7 +592,7 @@ void RemoteInspector::receivedIndicateMessage(NSDictionary *userInfo)
     if (!targetIdentifier)
         return;
 
-    callOnWebThreadOrDispatchAsyncOnMainThread(^{
+    dispatchAsyncOnMainThreadWithWebThreadLockIfNeeded(^{
         RemoteControllableTarget* target = nullptr;
         {
             LockHolder lock(m_mutex);
index 210b70c..309b8a0 100644 (file)
@@ -1,3 +1,17 @@
+2019-04-03  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Remote Inspector indicate callback should always happen on the main thread
+        https://bugs.webkit.org/show_bug.cgi?id=196513
+        <rdar://problem/49498284>
+
+        Reviewed by Devin Rousso.
+
+        * wtf/MainThread.h:
+        * wtf/cocoa/MainThreadCocoa.mm:
+        (WTF::dispatchAsyncOnMainThreadWithWebThreadLockIfNeeded):
+        * wtf/ios/WebCoreThread.cpp:
+        * wtf/ios/WebCoreThread.h:
+
 2019-04-02  Keith Rollin  <krollin@apple.com>
 
         Inhibit CFNetwork logging in private sessions
index f67e085..c8ef1b5 100644 (file)
@@ -46,6 +46,7 @@ WTF_EXPORT_PRIVATE void callOnMainThread(Function<void()>&&);
 WTF_EXPORT_PRIVATE void callOnMainThreadAndWait(Function<void()>&&);
 
 #if PLATFORM(COCOA)
+WTF_EXPORT_PRIVATE void dispatchAsyncOnMainThreadWithWebThreadLockIfNeeded(void (^block)());
 WTF_EXPORT_PRIVATE void callOnWebThreadOrDispatchAsyncOnMainThread(void (^block)());
 #endif
 
@@ -108,6 +109,7 @@ using WTF::isWebThread;
 using WTF::mayBeGCThread;
 using WTF::setMainThreadCallbacksPaused;
 #if PLATFORM(COCOA)
+using WTF::dispatchAsyncOnMainThreadWithWebThreadLockIfNeeded;
 using WTF::callOnWebThreadOrDispatchAsyncOnMainThread;
 #endif
 #if USE(WEB_THREAD)
index c686ab7..be7ea45 100644 (file)
@@ -140,6 +140,20 @@ void scheduleDispatchFunctionsOnMainThread()
     [staticMainThreadCaller performSelector:@selector(call) onThread:mainThreadNSThread withObject:nil waitUntilDone:NO];
 }
 
+void dispatchAsyncOnMainThreadWithWebThreadLockIfNeeded(void (^block)())
+{
+#if USE(WEB_THREAD)
+    if (WebCoreWebThreadIsEnabled && WebCoreWebThreadIsEnabled()) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            WebCoreWebThreadLock();
+            block();
+        });
+        return;
+    }
+#endif
+    dispatch_async(dispatch_get_main_queue(), block);
+}
+
 void callOnWebThreadOrDispatchAsyncOnMainThread(void (^block)())
 {
 #if USE(WEB_THREAD)
index a65341a..a6f9015 100644 (file)
@@ -27,6 +27,7 @@
 #include <wtf/ios/WebCoreThread.h>
 
 #if USE(WEB_THREAD)
+WTF_EXPORT_PRIVATE void (*WebCoreWebThreadLock)(void);
 WTF_EXPORT_PRIVATE bool (*WebCoreWebThreadIsLockedOrDisabled)(void);
 WTF_EXPORT_PRIVATE bool (*WebCoreWebThreadIsEnabled)(void);
 WTF_EXPORT_PRIVATE void (*WebCoreWebThreadRun)(void (^block)());
index 2880b5a..594f046 100644 (file)
@@ -29,6 +29,7 @@
 extern "C" {
 #endif
 
+extern void (*WebCoreWebThreadLock)(void);
 extern bool (*WebCoreWebThreadIsLockedOrDisabled)(void);
 extern bool (*WebCoreWebThreadIsEnabled)(void);
 extern void (*WebCoreWebThreadRun)(void (^block)());
index cebbb1b..d692efc 100644 (file)
@@ -1,3 +1,14 @@
+2019-04-03  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Remote Inspector indicate callback should always happen on the main thread
+        https://bugs.webkit.org/show_bug.cgi?id=196513
+        <rdar://problem/49498284>
+
+        Reviewed by Devin Rousso.
+
+        * platform/ios/wak/WebCoreThreadSystemInterface.cpp:
+        (InitWebCoreThreadSystemInterface):
+
 2019-04-02  Simon Fraser  <simon.fraser@apple.com>
 
         REGRESSION (r238266): Exchange 2013 Outlook Web Access displays partially blank page when creating new e-mail
index f11a7d9..5950128 100644 (file)
@@ -44,6 +44,7 @@ void InitWebCoreThreadSystemInterface(void)
     if (didInit)
         return;
 
+    INIT(WebThreadLock);
     INIT(WebThreadIsLockedOrDisabled);
     INIT(WebThreadIsEnabled);
     INIT(WebThreadRun);