Title: [249077] trunk/Source/WebCore
Revision
249077
Author
cdu...@apple.com
Date
2019-08-23 17:24:11 -0700 (Fri, 23 Aug 2019)

Log Message

Crash under TimerBase::setNextFireTime() in the NetworkProcess
https://bugs.webkit.org/show_bug.cgi?id=201097
<rdar://problem/54658339>

Reviewed by Ryosuke Niwa.

NetworkStateNotifier is a WebCore/platform class used by both WebKitLegacy and WebKit2 in the NetworkProcess.
On iOS, the lambda in the implementation of NetworkStateNotifier::startObserving() may get called by the
underlying framework on a non-main thread and we therefore want to go back to the main thread before calling
NetworkStateNotifier::singleton().updateStateSoon(). This is important because updateStateSoon() will schedule
a WebCore::Timer. The issue is that the code was using WebThreadRun() to go back the the main thread. While
this works fine in iOS WK1, it does not do what we want in WebKit2 in the network process. Indeed, before there
is no WebThread in the network process, WebThreadRun() will simply run the block on whatever thread we're one.
This would lead to crashes when trying to schedule the Timer in updateStateSoon(). To address the issue, we now
use callOnMainThread().

* platform/network/ios/NetworkStateNotifierIOS.mm:
(WebCore::NetworkStateNotifier::startObserving):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (249076 => 249077)


--- trunk/Source/WebCore/ChangeLog	2019-08-24 00:20:57 UTC (rev 249076)
+++ trunk/Source/WebCore/ChangeLog	2019-08-24 00:24:11 UTC (rev 249077)
@@ -1,3 +1,24 @@
+2019-08-23  Chris Dumez  <cdu...@apple.com>
+
+        Crash under TimerBase::setNextFireTime() in the NetworkProcess
+        https://bugs.webkit.org/show_bug.cgi?id=201097
+        <rdar://problem/54658339>
+
+        Reviewed by Ryosuke Niwa.
+
+        NetworkStateNotifier is a WebCore/platform class used by both WebKitLegacy and WebKit2 in the NetworkProcess.
+        On iOS, the lambda in the implementation of NetworkStateNotifier::startObserving() may get called by the
+        underlying framework on a non-main thread and we therefore want to go back to the main thread before calling
+        NetworkStateNotifier::singleton().updateStateSoon(). This is important because updateStateSoon() will schedule
+        a WebCore::Timer. The issue is that the code was using WebThreadRun() to go back the the main thread. While
+        this works fine in iOS WK1, it does not do what we want in WebKit2 in the network process. Indeed, before there
+        is no WebThread in the network process, WebThreadRun() will simply run the block on whatever thread we're one.
+        This would lead to crashes when trying to schedule the Timer in updateStateSoon(). To address the issue, we now
+        use callOnMainThread().
+
+        * platform/network/ios/NetworkStateNotifierIOS.mm:
+        (WebCore::NetworkStateNotifier::startObserving):
+
 2019-08-23  Ryosuke Niwa  <rn...@webkit.org>
 
         REGRESSION (r248807): Objects stored in ElementRareData are leaked

Modified: trunk/Source/WebCore/platform/network/ios/NetworkStateNotifierIOS.mm (249076 => 249077)


--- trunk/Source/WebCore/platform/network/ios/NetworkStateNotifierIOS.mm	2019-08-24 00:20:57 UTC (rev 249076)
+++ trunk/Source/WebCore/platform/network/ios/NetworkStateNotifierIOS.mm	2019-08-24 00:24:11 UTC (rev 249077)
@@ -84,7 +84,7 @@
     if (DeprecatedGlobalSettings::shouldOptOutOfNetworkStateObservation())
         return;
     m_observer = adoptNS([[WebNetworkStateObserver alloc] initWithBlock:^ {
-        WebThreadRun(^ {
+        callOnMainThread([] {
             NetworkStateNotifier::singleton().updateStateSoon();
         });
     }]);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to