Changeset 228564 in webkit


Ignore:
Timestamp:
Feb 16, 2018 11:05:07 AM (6 years ago)
Author:
Chris Dumez
Message:
ASSERTION FAILED: !m_processes[i]
*m_processes[i] == process in MessagePortChannel::entanglePortWithProcess()

https://bugs.webkit.org/show_bug.cgi?id=182054
<rdar://problem/36871207>

Reviewed by Brady Eidson.

Pipe postMessage messages to and from service workers via the UIProcess instead of going
directly to the StorageProcess. This is temporarily needed to avoid races due to the
MessagePort registry currently living in the UIProcess and postMessage messages potentially
sending MessagePort objects.

This change is covered by tests on the bots that currently flakily crash in debug.

  • StorageProcess/ServiceWorker/WebSWServerConnection.h:
  • StorageProcess/StorageProcess.cpp:

(WebKit::StorageProcess::postMessageToServiceWorker):

  • StorageProcess/StorageProcess.h:
  • StorageProcess/StorageProcess.messages.in:
  • UIProcess/WebProcessPool.cpp:

(WebKit::WebProcessPool::postMessageToServiceWorkerClient):
(WebKit::WebProcessPool::postMessageToServiceWorker):

  • UIProcess/WebProcessPool.h:
  • UIProcess/WebProcessPool.messages.in:
  • WebProcess/Storage/WebSWClientConnection.cpp:

(WebKit::WebSWClientConnection::postMessageToServiceWorker):

  • WebProcess/Storage/WebSWContextManagerConnection.cpp:

(WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient):

Location:
trunk/Source/WebKit
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r228557 r228564  
     12018-02-16  Chris Dumez  <cdumez@apple.com>
     2
     3        ASSERTION FAILED: !m_processes[i] || *m_processes[i] == process in MessagePortChannel::entanglePortWithProcess()
     4        https://bugs.webkit.org/show_bug.cgi?id=182054
     5        <rdar://problem/36871207>
     6
     7        Reviewed by Brady Eidson.
     8
     9        Pipe postMessage messages to and from service workers via the UIProcess instead of going
     10        directly to the StorageProcess. This is temporarily needed to avoid races due to the
     11        MessagePort registry currently living in the UIProcess and postMessage messages potentially
     12        sending MessagePort objects.
     13
     14        This change is covered by tests on the bots that currently flakily crash in debug.
     15
     16        * StorageProcess/ServiceWorker/WebSWServerConnection.h:
     17        * StorageProcess/StorageProcess.cpp:
     18        (WebKit::StorageProcess::postMessageToServiceWorker):
     19        * StorageProcess/StorageProcess.h:
     20        * StorageProcess/StorageProcess.messages.in:
     21        * UIProcess/WebProcessPool.cpp:
     22        (WebKit::WebProcessPool::postMessageToServiceWorkerClient):
     23        (WebKit::WebProcessPool::postMessageToServiceWorker):
     24        * UIProcess/WebProcessPool.h:
     25        * UIProcess/WebProcessPool.messages.in:
     26        * WebProcess/Storage/WebSWClientConnection.cpp:
     27        (WebKit::WebSWClientConnection::postMessageToServiceWorker):
     28        * WebProcess/Storage/WebSWContextManagerConnection.cpp:
     29        (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient):
     30
    1312018-02-16  Wenson Hsieh  <wenson_hsieh@apple.com>
    232
  • trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h

    r227989 r228564  
    7070
    7171    void postMessageToServiceWorkerClient(WebCore::DocumentIdentifier destinationContextIdentifier, WebCore::MessageWithMessagePorts&&, WebCore::ServiceWorkerIdentifier sourceServiceWorkerIdentifier, const String& sourceOrigin);
     72    void postMessageToServiceWorker(WebCore::ServiceWorkerIdentifier destination, WebCore::MessageWithMessagePorts&&, const WebCore::ServiceWorkerOrClientIdentifier& source);
    7273
    7374private:
     
    8889
    8990    void startFetch(uint64_t fetchIdentifier, WebCore::ServiceWorkerRegistrationIdentifier, WebCore::ResourceRequest&&, WebCore::FetchOptions&&, IPC::FormDataReference&&, String&& referrer);
    90 
    91     void postMessageToServiceWorker(WebCore::ServiceWorkerIdentifier destination, WebCore::MessageWithMessagePorts&&, const WebCore::ServiceWorkerOrClientIdentifier& source);
    9291
    9392    void matchRegistration(uint64_t registrationMatchRequestIdentifier, const WebCore::SecurityOriginData& topOrigin, const WebCore::URL& clientURL);
  • trunk/Source/WebKit/StorageProcess/StorageProcess.cpp

    r227789 r228564  
    485485}
    486486
     487void StorageProcess::postMessageToServiceWorker(WebCore::ServiceWorkerIdentifier destination, WebCore::MessageWithMessagePorts&& message, const WebCore::ServiceWorkerOrClientIdentifier& source, SWServerConnectionIdentifier connectionIdentifier)
     488{
     489    if (auto* connection = m_swServerConnections.get(connectionIdentifier))
     490        connection->postMessageToServiceWorker(destination, WTFMove(message), source);
     491}
     492
    487493void StorageProcess::registerSWServerConnection(WebSWServerConnection& connection)
    488494{
  • trunk/Source/WebKit/StorageProcess/StorageProcess.h

    r228021 r228564  
    138138
    139139    void postMessageToServiceWorkerClient(const WebCore::ServiceWorkerClientIdentifier& destinationIdentifier, WebCore::MessageWithMessagePorts&&, WebCore::ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin);
     140    void postMessageToServiceWorker(WebCore::ServiceWorkerIdentifier destination, WebCore::MessageWithMessagePorts&&, const WebCore::ServiceWorkerOrClientIdentifier& source, WebCore::SWServerConnectionIdentifier);
     141
    140142    WebSWOriginStore& swOriginStoreForSession(PAL::SessionID);
    141143    bool needsServerToContextConnection() const;
  • trunk/Source/WebKit/StorageProcess/StorageProcess.messages.in

    r227425 r228564  
    4444    DidFinishFetch(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchIdentifier)
    4545    PostMessageToServiceWorkerClient(struct WebCore::ServiceWorkerClientIdentifier destinationIdentifier, struct WebCore::MessageWithMessagePorts message, WebCore::ServiceWorkerIdentifier sourceIdentifier, String sourceOrigin)
     46
     47    PostMessageToServiceWorker(WebCore::ServiceWorkerIdentifier destination, struct WebCore::MessageWithMessagePorts message, WebCore::ServiceWorkerOrClientIdentifier source, WebCore::SWServerConnectionIdentifier connectionIdentifier)
    4648#endif
    4749}
  • trunk/Source/WebKit/UIProcess/WebProcessPool.cpp

    r228307 r228564  
    18431843}
    18441844
     1845#if ENABLE(SERVICE_WORKER)
     1846void WebProcessPool::postMessageToServiceWorkerClient(const ServiceWorkerClientIdentifier& destination, MessageWithMessagePorts&& message, ServiceWorkerIdentifier source, const String& sourceOrigin)
     1847{
     1848    sendToStorageProcessRelaunchingIfNecessary(Messages::StorageProcess::PostMessageToServiceWorkerClient(destination, WTFMove(message), source, sourceOrigin));
     1849}
     1850
     1851void WebProcessPool::postMessageToServiceWorker(ServiceWorkerIdentifier destination, MessageWithMessagePorts&& message, const ServiceWorkerOrClientIdentifier& source, SWServerConnectionIdentifier connectionIdentifier)
     1852{
     1853    sendToStorageProcessRelaunchingIfNecessary(Messages::StorageProcess::PostMessageToServiceWorker(destination, WTFMove(message), source, connectionIdentifier));
     1854}
     1855#endif
     1856
    18451857void WebProcessPool::reinstateNetworkProcessAssertionState(NetworkProcessProxy& newNetworkProcessProxy)
    18461858{
  • trunk/Source/WebKit/UIProcess/WebProcessPool.h

    r228230 r228564  
    426426#endif
    427427
     428#if ENABLE(SERVICE_WORKER)
     429    void postMessageToServiceWorkerClient(const WebCore::ServiceWorkerClientIdentifier& destinationIdentifier, WebCore::MessageWithMessagePorts&&, WebCore::ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin);
     430    void postMessageToServiceWorker(WebCore::ServiceWorkerIdentifier destination, WebCore::MessageWithMessagePorts&&, const WebCore::ServiceWorkerOrClientIdentifier& source, WebCore::SWServerConnectionIdentifier);
     431#endif
     432
    428433    static uint64_t registerProcessPoolCreationListener(Function<void(WebProcessPool&)>&&);
    429434    static void unregisterProcessPoolCreationListener(uint64_t identifier);
  • trunk/Source/WebKit/UIProcess/WebProcessPool.messages.in

    r220857 r228564  
    3737
    3838    ReportWebContentCPUTime(Seconds cpuTime, uint64_t activityState)
     39
     40#if ENABLE(SERVICE_WORKER)
     41    PostMessageToServiceWorkerClient(struct WebCore::ServiceWorkerClientIdentifier destinationIdentifier, struct WebCore::MessageWithMessagePorts message, WebCore::ServiceWorkerIdentifier sourceIdentifier, String sourceOrigin)
     42    PostMessageToServiceWorker(WebCore::ServiceWorkerIdentifier destination, struct WebCore::MessageWithMessagePorts message, WebCore::ServiceWorkerOrClientIdentifier source, WebCore::SWServerConnectionIdentifier connectionIdentifier)
     43#endif
    3944}
  • trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp

    r227789 r228564  
    3535#include "StorageToWebProcessConnectionMessages.h"
    3636#include "WebCoreArgumentCoders.h"
     37#include "WebProcess.h"
     38#include "WebProcessPoolMessages.h"
    3739#include "WebSWOriginTable.h"
    3840#include "WebSWServerConnectionMessages.h"
     
    8688void WebSWClientConnection::postMessageToServiceWorker(ServiceWorkerIdentifier destinationIdentifier, MessageWithMessagePorts&& message, const ServiceWorkerOrClientIdentifier& sourceIdentifier)
    8789{
    88     send(Messages::WebSWServerConnection::PostMessageToServiceWorker(destinationIdentifier, WTFMove(message), sourceIdentifier) );
     90    // FIXME: Temporarily pipe the SW postMessage messages via the UIProcess since this is where the MessagePort registry lives
     91    // and this avoids races.
     92    WebProcess::singleton().send(Messages::WebProcessPool::PostMessageToServiceWorker(destinationIdentifier, WTFMove(message), sourceIdentifier, serverConnectionIdentifier()), 0);
    8993}
    9094
  • trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp

    r228230 r228564  
    4040#include "WebPreferencesStore.h"
    4141#include "WebProcess.h"
     42#include "WebProcessPoolMessages.h"
    4243#include "WebSWServerToContextConnectionMessages.h"
    4344#include "WebServiceWorkerFetchTaskClient.h"
     
    220221void WebSWContextManagerConnection::postMessageToServiceWorkerClient(const ServiceWorkerClientIdentifier& destinationIdentifier, MessageWithMessagePorts&& message, ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin)
    221222{
    222     m_connectionToStorageProcess->send(Messages::StorageProcess::PostMessageToServiceWorkerClient(destinationIdentifier, WTFMove(message), sourceIdentifier, sourceOrigin), 0);
     223    // FIXME: Temporarily pipe the SW postMessage messages via the UIProcess since this is where the MessagePort registry lives
     224    // and this avoids races.
     225    WebProcess::singleton().send(Messages::WebProcessPool::PostMessageToServiceWorkerClient(destinationIdentifier, WTFMove(message), sourceIdentifier, sourceOrigin), 0);
    223226}
    224227
Note: See TracChangeset for help on using the changeset viewer.