Skip to content

Commit

Permalink
Cherry-pick 0532f1c. rdar://117840925
Browse files Browse the repository at this point in the history
    RELEASE_ASSERT() under GPUProcessConnection::create(IPC::Connection&)
    https://bugs.webkit.org/show_bug.cgi?id=264612
    rdar://117840925

    Reviewed by Brent Fulgham.

    When a WebProcess requests a connection to the GPUProcess, the UIProcess
    needs to pass preferences for this WebProcess. Preferences are associated
    with WebPages and thus we cannot initiate a connection to the GPUProcess
    before a WebPage has been created.

    I had tried to add an assertion to this effect in
    GPUProcessConnection::create(). However, my assertion was a little
    stricter than needed and could get hit in the wild. It is sufficient for
    a process to have ever had a WebPage (The WebProcessProxy stores the
    preferences locally), we don't need to have a living WebPage at the
    moment when the connection gets requested.

    * Source/WebKit/WebProcess/GPU/GPUProcessConnection.cpp:
    (WebKit::GPUProcessConnection::create):
    * Source/WebKit/WebProcess/WebProcess.cpp:
    (WebKit::WebProcess::createWebPage):
    * Source/WebKit/WebProcess/WebProcess.h:
    (WebKit::WebProcess::hasEverHadAnyWebPages const):
    (WebKit::WebProcess::hasWebPages const): Deleted.

    Canonical link: https://commits.webkit.org/270569@main

Canonical link: https://commits.webkit.org/267815.562@safari-7617.1.17.11-branch
  • Loading branch information
rjepstein committed Nov 10, 2023
1 parent 9d5fbd3 commit d10583e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Source/WebKit/WebProcess/GPU/GPUProcessConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ RefPtr<GPUProcessConnection> GPUProcessConnection::create(IPC::Connection& paren
if (!connectionIdentifiers)
return nullptr;

RELEASE_ASSERT_WITH_MESSAGE(WebProcess::singleton().hasWebPages(), "GPUProcess preferences come from the pages");
RELEASE_ASSERT_WITH_MESSAGE(WebProcess::singleton().hasEverHadAnyWebPages(), "GPUProcess preferences come from the pages");
parentConnection.send(Messages::WebProcessProxy::CreateGPUProcessConnection(WTFMove(connectionIdentifiers->client), getGPUProcessConnectionParameters()), 0, IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply);

auto instance = adoptRef(*new GPUProcessConnection(WTFMove(connectionIdentifiers->server)));
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/WebProcess/WebProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ void WebProcess::createWebPage(PageIdentifier pageID, WebPageCreationParameters&
// It is necessary to check for page existence here since during a window.open() (or targeted
// link) the WebPage gets created both in the synchronous handler and through the normal way.
auto result = m_pageMap.add(pageID, nullptr);
m_hasEverHadAnyWebPages = true;
if (result.isNewEntry) {
ASSERT(!result.iterator->value);
auto page = WebPage::create(pageID, WTFMove(parameters));
Expand Down
3 changes: 2 additions & 1 deletion Source/WebKit/WebProcess/WebProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class WebProcess : public AuxiliaryProcess
void createWebPage(WebCore::PageIdentifier, WebPageCreationParameters&&);
void removeWebPage(WebCore::PageIdentifier);
WebPage* focusedWebPage() const;
bool hasWebPages() const { return !m_pageMap.isEmpty(); }
bool hasEverHadAnyWebPages() const { return m_hasEverHadAnyWebPages; }

InjectedBundle* injectedBundle() const { return m_injectedBundle.get(); }

Expand Down Expand Up @@ -813,6 +813,7 @@ class WebProcess : public AuxiliaryProcess
#endif
bool m_hadMainFrameMainResourcePrivateRelayed { false };
bool m_imageAnimationEnabled { true };
bool m_hasEverHadAnyWebPages { false };

HashSet<WebCore::RegistrableDomain> m_allowedFirstPartiesForCookies;
};
Expand Down

0 comments on commit d10583e

Please sign in to comment.