ASSERTION FAILED: RunLoop::isMain() under IPC::Connection::sendWithAsyncReply()
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Jul 2019 23:58:35 +0000 (23:58 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Jul 2019 23:58:35 +0000 (23:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199734
<rdar://problem/52977439>

Reviewed by Geoffrey Garen.

It appears WKProcessTaskStateObserverDelegate's taskStateDidChange handler can get called
on a background thread so we need to make sure we go back to the main thread before we
go into WebKit and do IPC.

* Shared/Cocoa/ProcessTaskStateObserver.mm:
(-[WKProcessTaskStateObserverDelegate process:taskStateDidChange:]):

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

Source/WebKit/ChangeLog
Source/WebKit/Shared/Cocoa/ProcessTaskStateObserver.mm

index 737f71f..ce571eb 100644 (file)
@@ -1,3 +1,18 @@
+2019-07-11  Chris Dumez  <cdumez@apple.com>
+
+        ASSERTION FAILED: RunLoop::isMain() under IPC::Connection::sendWithAsyncReply()
+        https://bugs.webkit.org/show_bug.cgi?id=199734
+        <rdar://problem/52977439>
+
+        Reviewed by Geoffrey Garen.
+
+        It appears WKProcessTaskStateObserverDelegate's taskStateDidChange handler can get called
+        on a background thread so we need to make sure we go back to the main thread before we
+        go into WebKit and do IPC.
+
+        * Shared/Cocoa/ProcessTaskStateObserver.mm:
+        (-[WKProcessTaskStateObserverDelegate process:taskStateDidChange:]):
+
 2019-07-11  Sihui Liu  <sihui_liu@apple.com>
 
         StorageArea should not be destructed on the main thread
index 77c52ba..93239a2 100644 (file)
@@ -47,8 +47,10 @@ typedef void(^TaskStateChangedCallbackType)(BKSProcessTaskState);
 {
     RELEASE_LOG(ProcessSuspension, "%p -[WKProcessTaskStateObserverDelegate process:taskStateDidChange:], process(%p), newState(%d)", self, process, (int)newState);
 
-    if (self.taskStateChangedCallback)
-        self.taskStateChangedCallback(newState);
+    dispatch_async(dispatch_get_main_queue(), ^{
+        if (self.taskStateChangedCallback)
+            self.taskStateChangedCallback(newState);
+    });
 }
 @end