Skip to content

Lay out webview view after claim to avoid flash in wrong area#310204

Open
yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
yogeshwaran-c:fix/webview-view-sidebar-flash-in-panel-243038
Open

Lay out webview view after claim to avoid flash in wrong area#310204
yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
yogeshwaran-c:fix/webview-view-sidebar-flash-in-panel-243038

Conversation

@yogeshwaran-c
Copy link
Copy Markdown
Contributor

Fixes #243038

What

When a sidebar (or auxiliary bar) webview view is toggled while the panel alignment is set to justify, the webview briefly flashes in the panel area before settling back into its correct location.

Why

OverlayWebview is absolutely positioned and reuses its DOM element across shows/hides. WebviewViewPane.updateTreeVisibility() calls claim() to make the overlay container visible, but it does not trigger an immediate layout pass. The container therefore becomes visible at whatever coordinates doLayoutWebviewOverElement set the last time the overlay was laid out. When the workbench layout has changed in the interim (e.g. the panel was opened in justify alignment, which shifts the bounding rect of the side bar), those stale coordinates can land in the panel area for a single frame, producing the observed flash. The next layout call (driven by layoutBody / the resize observer) then snaps the overlay back into the correct place.

Fix

After claim(), explicitly call layoutWebview() so that the overlay is repositioned over the current view pane container before the next paint. This is guarded on _container being set, so it is a no-op until renderBody has run. The existing layoutBody-driven layout path still runs as before; this just ensures the very first paint after a claim uses up-to-date coordinates rather than the stale ones from the previous show.

Risk

Very small. The change adds one extra synchronous layoutWebviewOverElement call on visibility transitions, which already happens on every resize. No behavior change when _container is unset (initial construction), and release() continues to hide the overlay as before.

When a webview view becomes visible, the overlay was claimed (which makes
the underlying container visible) without an immediate layout pass. Because
the overlay is absolutely positioned and reuses its DOM element across
shows/hides, the container could become visible briefly at the coordinates
left over from the previous layout. With panel alignment set to justify,
this manifests as a one-frame flash of the webview in the panel area when
toggling a sidebar webview view.

Trigger an explicit layoutWebview() right after claiming so that the
overlay is repositioned over the current view pane before the next paint.

Fixes microsoft#243038
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Open a view with webview in sidebar, it will blink in panel

2 participants