Skip to content

Commit

Permalink
Allow window.open to open in a new process when using TiledCoreAnimat…
Browse files Browse the repository at this point in the history
…ionDrawingArea

https://bugs.webkit.org/show_bug.cgi?id=260059
rdar://111064288

Reviewed by J Pascoe.

When using TiledCoreAnimationDrawingArea and after a cross-site window.open, we have a WebPage
that has only RemoteFrames, which would use RemoteLayerTreeDrawingArea in most cases except
pre-Sonoma macOS and 2-core CPUs.  This WebPage only exists to hold RemoteFrames to proxy messages
back and forth, so it doesn't need to draw.  We just want it to not crash.

Add a null check and an early return in updateRendering like we do when layerTreeStateIsFrozen returns true.
Covered by the API test SiteIsolation.BasicPostMessageWindowOpen on pre-Sonoma macOS.

* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebKit/UIProcess/mac/WebViewImpl.mm:
(WebKit::WebViewImpl::WebViewImpl):
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::hasRootFrames):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::updateRendering):

Canonical link: https://commits.webkit.org/266823@main
  • Loading branch information
achristensen07 committed Aug 11, 2023
1 parent 6f57d24 commit 93d1a99
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
5 changes: 4 additions & 1 deletion Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5201,9 +5201,12 @@ ProcessSwapOnCrossSiteWindowOpenEnabled:
category: networking
humanReadableName: "Swap Processes on Cross-Site Window Open"
humanReadableDescription: "Swap WebContent Processes on cross-site window.open"
webcoreBinding: none
exposed: [ WebKit ]
defaultValue:
WebCore:
default: false
WebKitLegacy:
default: false
WebKit:
default: false

Expand Down
4 changes: 0 additions & 4 deletions Source/WebKit/UIProcess/mac/WebViewImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1173,10 +1173,6 @@ static bool isInRecoveryOS()
if (m_page->preferences().siteIsolationEnabled())
result = true;

// FIXME: Either make this work with TiledCoreAnimationDrawingArea or only enable it where remote layer trees are used.
if (m_page->preferences().processSwapOnCrossSiteWindowOpenEnabled())
result = true;

if (isInRecoveryOS()) {
// Temporarily disable UI side compositing in Recovery OS <rdar://107964149>.
WTFLogAlways("Disabling UI side compositing in Recovery OS");
Expand Down
10 changes: 10 additions & 0 deletions Source/WebKit/WebProcess/WebPage/WebPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4802,6 +4802,16 @@ void WebPage::updateRendering()
#endif
}

bool WebPage::hasRootFrames()
{
bool result = m_page && !m_page->rootFrames().isEmptyIgnoringNullReferences();
if (!result) {
ASSERT(m_page->settings().processSwapOnCrossSiteWindowOpenEnabled());
ASSERT(!m_page->settings().siteIsolationEnabled());
}
return result;
}

void WebPage::didUpdateRendering()
{
didPaintLayers();
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/WebProcess/WebPage/WebPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ class WebPage : public API::ObjectImpl<API::Object::Type::BundlePage>, public IP

void layoutIfNeeded();
void updateRendering();
bool hasRootFrames();
bool shouldTriggerRenderingUpdate(unsigned rescheduledRenderingUpdateCount) const;
void finalizeRenderingUpdate(OptionSet<WebCore::FinalizeRenderingUpdateFlags>);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@
if (layerTreeStateIsFrozen())
return;

if (UNLIKELY(!m_webPage.hasRootFrames()))
return;

@autoreleasepool {
scaleViewToFitDocumentIfNeeded();

Expand All @@ -365,8 +368,10 @@
}

FloatRect visibleRect = [m_hostingLayer frame];
if (auto exposedRect = m_webPage.localMainFrameView()->viewExposedRect())
visibleRect.intersect(*exposedRect);
if (auto* localMainFrameView = m_webPage.localMainFrameView()) {
if (auto exposedRect = localMainFrameView->viewExposedRect())
visibleRect.intersect(*exposedRect);
}

// Because our view-relative overlay root layer is not attached to the main GraphicsLayer tree, we need to flush it manually.
if (m_viewOverlayRootLayer)
Expand Down

0 comments on commit 93d1a99

Please sign in to comment.