Changeset 249350 in webkit


Ignore:
Timestamp:
Aug 30, 2019 3:59:10 PM (5 years ago)
Author:
Chris Dumez
Message:

[PSON] We no longer need to throw away suspended pages in a process before using it for a navigation
https://bugs.webkit.org/show_bug.cgi?id=201344

Reviewed by Antti Koivisto.

We no longer need to throw away suspended pages in a process before using it for a navigation, now that
Bug 201225 has been fixed. WebPage objects (suspended or live) in the process now have distinct
identifiers and can coexist.

  • Shared/API/Cocoa/RemoteObjectRegistry.h:
  • Shared/API/Cocoa/RemoteObjectRegistry.mm:

(WebKit::RemoteObjectRegistry::RemoteObjectRegistry):

  • UIProcess/Cocoa/UIRemoteObjectRegistry.cpp:

(WebKit::UIRemoteObjectRegistry::UIRemoteObjectRegistry):

  • WebProcess/WebPage/Cocoa/WebRemoteObjectRegistry.cpp:

(WebKit::WebRemoteObjectRegistry::WebRemoteObjectRegistry):
(WebKit::WebRemoteObjectRegistry::close):

Location:
trunk/Source/WebKit
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r249346 r249350  
     12019-08-30  Chris Dumez  <cdumez@apple.com>
     2
     3        [PSON] We no longer need to throw away suspended pages in a process before using it for a navigation
     4        https://bugs.webkit.org/show_bug.cgi?id=201344
     5
     6        Reviewed by Antti Koivisto.
     7
     8        We no longer need to throw away suspended pages in a process before using it for a navigation, now that
     9        Bug 201225 has been fixed. WebPage objects (suspended or live) in the process now have distinct
     10        identifiers and can coexist.
     11
     12        * Shared/API/Cocoa/RemoteObjectRegistry.h:
     13        * Shared/API/Cocoa/RemoteObjectRegistry.mm:
     14        (WebKit::RemoteObjectRegistry::RemoteObjectRegistry):
     15        * UIProcess/Cocoa/UIRemoteObjectRegistry.cpp:
     16        (WebKit::UIRemoteObjectRegistry::UIRemoteObjectRegistry):
     17        * WebProcess/WebPage/Cocoa/WebRemoteObjectRegistry.cpp:
     18        (WebKit::WebRemoteObjectRegistry::WebRemoteObjectRegistry):
     19        (WebKit::WebRemoteObjectRegistry::close):
     20
    1212019-08-30  Chris Dumez  <cdumez@apple.com>
    222
  • trunk/Source/WebKit/Shared/API/Cocoa/RemoteObjectRegistry.h

    r249329 r249350  
    5454
    5555protected:
    56     RemoteObjectRegistry(_WKRemoteObjectRegistry *, WebPageProxyIdentifier messageDestinationID);
     56    explicit RemoteObjectRegistry(_WKRemoteObjectRegistry *);
    5757   
    5858private:
    5959    virtual ProcessThrottler::BackgroundActivityToken takeBackgroundActivityToken() { return nullptr; }
    6060    virtual IPC::MessageSender& messageSender() = 0;
     61    virtual uint64_t messageDestinationID() = 0;
    6162
    6263    // IPC::MessageReceiver
     
    7071    WeakObjCPtr<_WKRemoteObjectRegistry> m_remoteObjectRegistry;
    7172    HashMap<uint64_t, ProcessThrottler::BackgroundActivityToken> m_pendingReplies;
    72     WebPageProxyIdentifier m_messageDestinationID;
    7373};
    7474
  • trunk/Source/WebKit/Shared/API/Cocoa/RemoteObjectRegistry.mm

    r249329 r249350  
    3535namespace WebKit {
    3636
    37 RemoteObjectRegistry::RemoteObjectRegistry(_WKRemoteObjectRegistry *remoteObjectRegistry, WebPageProxyIdentifier messageDestinationID)
     37RemoteObjectRegistry::RemoteObjectRegistry(_WKRemoteObjectRegistry *remoteObjectRegistry)
    3838    : m_remoteObjectRegistry(remoteObjectRegistry)
    39     , m_messageDestinationID(messageDestinationID)
    4039{
    4140}
     
    5352    }
    5453
    55     messageSender().send(Messages::RemoteObjectRegistry::InvokeMethod(invocation), m_messageDestinationID);
     54    messageSender().send(Messages::RemoteObjectRegistry::InvokeMethod(invocation), messageDestinationID());
    5655}
    5756
    5857void RemoteObjectRegistry::sendReplyBlock(uint64_t replyID, const UserData& blockInvocation)
    5958{
    60     messageSender().send(Messages::RemoteObjectRegistry::CallReplyBlock(replyID, blockInvocation), m_messageDestinationID);
     59    messageSender().send(Messages::RemoteObjectRegistry::CallReplyBlock(replyID, blockInvocation), messageDestinationID());
    6160}
    6261
    6362void RemoteObjectRegistry::sendUnusedReply(uint64_t replyID)
    6463{
    65     messageSender().send(Messages::RemoteObjectRegistry::ReleaseUnusedReplyBlock(replyID), m_messageDestinationID);
     64    messageSender().send(Messages::RemoteObjectRegistry::ReleaseUnusedReplyBlock(replyID), messageDestinationID());
    6665}
    6766
  • trunk/Source/WebKit/UIProcess/Cocoa/UIRemoteObjectRegistry.cpp

    r249329 r249350  
    3838
    3939UIRemoteObjectRegistry::UIRemoteObjectRegistry(_WKRemoteObjectRegistry *remoteObjectRegistry, WebPageProxy& page)
    40     : RemoteObjectRegistry(remoteObjectRegistry, page.identifier())
     40    : RemoteObjectRegistry(remoteObjectRegistry)
    4141    , m_page(page)
    4242{
     
    5656}
    5757
     58uint64_t UIRemoteObjectRegistry::messageDestinationID()
     59{
     60    return m_page.webPageID().toUInt64();
     61}
     62
    5863} // namespace WebKit
  • trunk/Source/WebKit/UIProcess/Cocoa/UIRemoteObjectRegistry.h

    r249155 r249350  
    4040private:
    4141    IPC::MessageSender& messageSender() final;
     42    uint64_t messageDestinationID() final;
    4243    ProcessThrottler::BackgroundActivityToken takeBackgroundActivityToken() final;
    4344
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r249335 r249350  
    28922892
    28932893        if (shouldProcessSwap) {
    2894             // FIXME: Architecturally we do not currently support multiple WebPage's with the same ID in a given WebProcess.
    2895             // In the case where the destination WebProcess has a SuspendedPageProxy for this WebPage, we should have thrown
    2896             // it away to support WebProcess re-use.
    2897             ASSERT(destinationSuspendedPage || !process().processPool().hasSuspendedPageFor(processForNavigation, *this));
    2898 
    28992894            auto suspendedPage = destinationSuspendedPage ? process().processPool().takeSuspendedPage(*destinationSuspendedPage) : nullptr;
    29002895            if (suspendedPage && suspendedPage->pageIsClosedOrClosing())
  • trunk/Source/WebKit/UIProcess/WebProcessPool.cpp

    r249341 r249350  
    23322332        if (RefPtr<WebProcessProxy> process = WebProcessProxy::processForIdentifier(targetItem->lastProcessIdentifier())) {
    23332333            if (process->state() != WebProcessProxy::State::Terminated) {
    2334                 // FIXME: Architecturally we do not currently support multiple WebPage's with the same ID in a given WebProcess.
    2335                 // In the case where this WebProcess has a SuspendedPageProxy for this WebPage, we can throw it away to support
    2336                 // WebProcess re-use.
    2337                 removeAllSuspendedPagesForPage(page, process.get());
    2338 
    23392334                // Make sure we remove the process from the cache if it is in there since we're about to use it.
    23402335                if (process->isInProcessCache()) {
     
    23742369                LOG(ProcessSwapping, "(ProcessSwapping) Reusing a previously cached process with pid %i to continue navigation to URL %s", process->processIdentifier(), targetURL.string().utf8().data());
    23752370
    2376                 // FIXME: Architecturally we do not currently support multiple WebPage's with the same ID in a given WebProcess.
    2377                 // In the case where this WebProcess has a SuspendedPageProxy for this WebPage, we can throw it away to support
    2378                 // WebProcess re-use.
    2379                 // In the future it would be great to refactor-out this limitation (https://bugs.webkit.org/show_bug.cgi?id=191166).
    2380                 removeAllSuspendedPagesForPage(page, process);
    2381 
    23822371                return completionHandler(makeRef(*process), nullptr, reason);
    23832372            }
     
    23932382        return suspendedPage->process().registrableDomain() == registrableDomain && &suspendedPage->process().websiteDataStore() == &dataStore;
    23942383    });
    2395     if (it == m_suspendedPages.end())
    2396         return nullptr;
    2397 
    2398     Ref<WebProcessProxy> process = (*it)->process();
    2399 
    2400     // FIXME: If the SuspendedPage is for this page, then we need to destroy the suspended page as we do not support having
    2401     // multiple WebPages with the same ID in a given WebProcess currently (https://bugs.webkit.org/show_bug.cgi?id=191166).
    2402     if (&(*it)->page() == &page)
    2403         m_suspendedPages.remove(it);
    2404 
    2405 
    2406     return process;
     2384    return it == m_suspendedPages.end() ? nullptr : &(*it)->process();
    24072385}
    24082386
  • trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebRemoteObjectRegistry.cpp

    r249329 r249350  
    3333
    3434WebRemoteObjectRegistry::WebRemoteObjectRegistry(_WKRemoteObjectRegistry *remoteObjectRegistry, WebPage& page)
    35     : RemoteObjectRegistry(remoteObjectRegistry, page.webPageProxyIdentifier())
     35    : RemoteObjectRegistry(remoteObjectRegistry)
    3636    , m_page(page)
    3737{
    38     WebProcess::singleton().addMessageReceiver(Messages::RemoteObjectRegistry::messageReceiverName(), m_page.webPageProxyIdentifier(), *this);
     38    WebProcess::singleton().addMessageReceiver(Messages::RemoteObjectRegistry::messageReceiverName(), m_page.pageID(), *this);
    3939    page.setRemoteObjectRegistry(this);
    4040}
     
    4848{
    4949    if (m_page.remoteObjectRegistry() == this) {
    50         WebProcess::singleton().removeMessageReceiver(Messages::RemoteObjectRegistry::messageReceiverName(), m_page.webPageProxyIdentifier());
     50        WebProcess::singleton().removeMessageReceiver(Messages::RemoteObjectRegistry::messageReceiverName(), m_page.pageID());
    5151        m_page.setRemoteObjectRegistry(nullptr);
    5252    }
     
    5858}
    5959
     60uint64_t WebRemoteObjectRegistry::messageDestinationID()
     61{
     62    return m_page.webPageProxyIdentifier().toUInt64();
     63}
     64
    6065} // namespace WebKit
  • trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebRemoteObjectRegistry.h

    r249155 r249350  
    4141private:
    4242    IPC::MessageSender& messageSender() final;
     43    uint64_t messageDestinationID() final;
    4344
    4445    WebPage& m_page;
  • trunk/Source/WebKit/WebProcess/WebStorage/StorageNamespaceImpl.cpp

    r249329 r249350  
    4343using namespace WebCore;
    4444
     45static HashMap<StorageNamespaceImpl::Identifier, StorageNamespaceImpl*>& sessionStorageNamespaces()
     46{
     47    static NeverDestroyed<HashMap<StorageNamespaceImpl::Identifier, StorageNamespaceImpl*>> map;
     48    return map;
     49}
     50
    4551Ref<StorageNamespaceImpl> StorageNamespaceImpl::createSessionStorageNamespace(Identifier identifier, PageIdentifier pageID, unsigned quotaInBytes, PAL::SessionID sessionID)
    4652{
     53    // The identifier of a session storage namespace is the WebPageProxyIdentifier. It is possible we have several WebPage objects in a single process for the same
     54    // WebPageProxyIdentifier and these need to share the same namespace instance so we know where to route the IPC to.
     55    if (auto* existingNamespace = sessionStorageNamespaces().get(identifier))
     56        return *existingNamespace;
    4757    return adoptRef(*new StorageNamespaceImpl(StorageType::Session, identifier, pageID, nullptr, quotaInBytes, sessionID));
    4858}
     
    6777{
    6878    ASSERT(storageType == StorageType::Session || !m_sessionPageID);
     79   
     80    if (m_storageType == StorageType::Session) {
     81        ASSERT(!sessionStorageNamespaces().contains(m_storageNamespaceID));
     82        sessionStorageNamespaces().add(m_storageNamespaceID, this);
     83    }
    6984}
    7085
    7186StorageNamespaceImpl::~StorageNamespaceImpl()
    7287{
     88    if (m_storageType == StorageType::Session) {
     89        bool wasRemoved = sessionStorageNamespaces().remove(m_storageNamespaceID);
     90        ASSERT_UNUSED(wasRemoved, wasRemoved);
     91    }
    7392}
    7493
Note: See TracChangeset for help on using the changeset viewer.