Repository navigation
Fix browser freeze after pane split #1852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6064,6 +6064,10 @@ struct WebViewRepresentable: NSViewRepresentable { | |||||||||||||||||||||||||
| visibleInUI: coordinator.desiredPortalVisibleInUI, | ||||||||||||||||||||||||||
| zPriority: coordinator.desiredPortalZPriority | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| BrowserWindowPortalRegistry.refresh( | ||||||||||||||||||||||||||
| webView: webView, | ||||||||||||||||||||||||||
| reason: "portalHostBind.didMoveToWindow" | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| BrowserWindowPortalRegistry.updatePaneTopChromeHeight( | ||||||||||||||||||||||||||
| for: webView, | ||||||||||||||||||||||||||
| height: coordinator.desiredPortalVisibleInUI ? paneTopChromeHeight : 0 | ||||||||||||||||||||||||||
|
|
@@ -6095,6 +6099,10 @@ struct WebViewRepresentable: NSViewRepresentable { | |||||||||||||||||||||||||
| visibleInUI: coordinator.desiredPortalVisibleInUI, | ||||||||||||||||||||||||||
| zPriority: coordinator.desiredPortalZPriority | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| BrowserWindowPortalRegistry.refresh( | ||||||||||||||||||||||||||
| webView: webView, | ||||||||||||||||||||||||||
| reason: "portalHostBind.geometryChanged" | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
|
Comment on lines
+6102
to
+6105
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The
Suggested change
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||||||||||||||||||||||||||
| BrowserWindowPortalRegistry.updatePaneTopChromeHeight( | ||||||||||||||||||||||||||
| for: webView, | ||||||||||||||||||||||||||
| height: coordinator.desiredPortalVisibleInUI ? paneTopChromeHeight : 0 | ||||||||||||||||||||||||||
|
|
@@ -6132,6 +6140,14 @@ struct WebViewRepresentable: NSViewRepresentable { | |||||||||||||||||||||||||
| visibleInUI: coordinator.desiredPortalVisibleInUI, | ||||||||||||||||||||||||||
| zPriority: coordinator.desiredPortalZPriority | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| // Force a rendering-state reattach after portal host replacement | ||||||||||||||||||||||||||
| // (e.g. after a pane split). Without this, WKWebView can freeze | ||||||||||||||||||||||||||
| // because _exitInWindow/_enterInWindow are never cycled when the | ||||||||||||||||||||||||||
| // web view is reparented to a new container during bind. | ||||||||||||||||||||||||||
| BrowserWindowPortalRegistry.refresh( | ||||||||||||||||||||||||||
| webView: webView, | ||||||||||||||||||||||||||
| reason: "portalHostBind" | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| coordinator.lastPortalHostId = hostId | ||||||||||||||||||||||||||
| coordinator.lastSynchronizedHostGeometryRevision = geometryRevision | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onDidMoveToWindowrefresh fires unconditionally on every window-entry eventUnlike the
onGeometryChangedhandler (which guards withcoordinator.lastPortalHostId != hostId || !isWebView(boundTo:)before callingbind + refresh), this path callsbind()+refresh()on every invocation that passes the generation/ownership/window guards — even when the host hasn't changed.refreshHostedWebViewPresentationschedules three layout +browserPortalReattachRenderingStatepasses (immediate,async, andasyncAfter +30 ms), guarded only bycontainerView.isHidden. If the container is visible at the momentonDidMoveToWindowfires (e.g., after SwiftUI recreates the host view during a workspace transition while the pane is in view), all three passes run unnecessarily.Consider adding an early-exit guard consistent with
onGeometryChanged:This mirrors the guard already present in
onGeometryChangedand avoids the three-pass refresh cycle on ordinary re-presentations where the host–anchor binding is already correct.