⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 249077 in webkit


Ignore:
Timestamp:
Aug 23, 2019, 5:24:11 PM (7 years ago)
Author:
Chris Dumez
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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r249076 r249077  
     12019-08-23  Chris Dumez  <cdumez@apple.com>
     2
     3        Crash under TimerBase::setNextFireTime() in the NetworkProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=201097
     5        <rdar://problem/54658339>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        NetworkStateNotifier is a WebCore/platform class used by both WebKitLegacy and WebKit2 in the NetworkProcess.
     10        On iOS, the lambda in the implementation of NetworkStateNotifier::startObserving() may get called by the
     11        underlying framework on a non-main thread and we therefore want to go back to the main thread before calling
     12        NetworkStateNotifier::singleton().updateStateSoon(). This is important because updateStateSoon() will schedule
     13        a WebCore::Timer. The issue is that the code was using WebThreadRun() to go back the the main thread. While
     14        this works fine in iOS WK1, it does not do what we want in WebKit2 in the network process. Indeed, before there
     15        is no WebThread in the network process, WebThreadRun() will simply run the block on whatever thread we're one.
     16        This would lead to crashes when trying to schedule the Timer in updateStateSoon(). To address the issue, we now
     17        use callOnMainThread().
     18
     19        * platform/network/ios/NetworkStateNotifierIOS.mm:
     20        (WebCore::NetworkStateNotifier::startObserving):
     21
    1222019-08-23  Ryosuke Niwa  <rniwa@webkit.org>
    223
  • trunk/Source/WebCore/platform/network/ios/NetworkStateNotifierIOS.mm

    r240355 r249077  
    8585        return;
    8686    m_observer = adoptNS([[WebNetworkStateObserver alloc] initWithBlock:^ {
    87         WebThreadRun(^ {
     87        callOnMainThread([] {
    8888            NetworkStateNotifier::singleton().updateStateSoon();
    8989        });
Note: See TracChangeset for help on using the changeset viewer.