Skip to content

Commit 55757f1

Browse files
ApptahClaude Opus 4.6 (1M context)
andauthored
Fix browser freeze after pane split by reattaching WKWebView rendering state (manaflow-ai#1852)
When a pane split occurs, SwiftUI recreates host views and the portal system rebinds the WKWebView to a new container. However, the bind path never called BrowserWindowPortalRegistry.refresh(), so WebKit's internal rendering state (_exitInWindow/_enterInWindow) was never cycled. This left the WKWebView frozen in the original pane after a split. Add refresh() calls after every portal bind that changes the host, in three code paths: the main update path (shouldBindNow), onDidMoveToWindow, and onGeometryChanged. The refresh is a no-op when no reattach is needed (browserPortalNeedsRenderingStateReattach == false), so normal rendering is unaffected. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7bf2fe0 commit 55757f1

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Sources/Panels/BrowserPanelView.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6098,6 +6098,10 @@ struct WebViewRepresentable: NSViewRepresentable {
60986098
visibleInUI: coordinator.desiredPortalVisibleInUI,
60996099
zPriority: coordinator.desiredPortalZPriority
61006100
)
6101+
BrowserWindowPortalRegistry.refresh(
6102+
webView: webView,
6103+
reason: "portalHostBind.didMoveToWindow"
6104+
)
61016105
BrowserWindowPortalRegistry.updatePaneTopChromeHeight(
61026106
for: webView,
61036107
height: coordinator.desiredPortalVisibleInUI ? paneTopChromeHeight : 0
@@ -6129,6 +6133,10 @@ struct WebViewRepresentable: NSViewRepresentable {
61296133
visibleInUI: coordinator.desiredPortalVisibleInUI,
61306134
zPriority: coordinator.desiredPortalZPriority
61316135
)
6136+
BrowserWindowPortalRegistry.refresh(
6137+
webView: webView,
6138+
reason: "portalHostBind.geometryChanged"
6139+
)
61326140
BrowserWindowPortalRegistry.updatePaneTopChromeHeight(
61336141
for: webView,
61346142
height: coordinator.desiredPortalVisibleInUI ? paneTopChromeHeight : 0
@@ -6166,6 +6174,14 @@ struct WebViewRepresentable: NSViewRepresentable {
61666174
visibleInUI: coordinator.desiredPortalVisibleInUI,
61676175
zPriority: coordinator.desiredPortalZPriority
61686176
)
6177+
// Force a rendering-state reattach after portal host replacement
6178+
// (e.g. after a pane split). Without this, WKWebView can freeze
6179+
// because _exitInWindow/_enterInWindow are never cycled when the
6180+
// web view is reparented to a new container during bind.
6181+
BrowserWindowPortalRegistry.refresh(
6182+
webView: webView,
6183+
reason: "portalHostBind"
6184+
)
61696185
coordinator.lastPortalHostId = hostId
61706186
coordinator.lastSynchronizedHostGeometryRevision = geometryRevision
61716187
}

0 commit comments

Comments
 (0)