Repository navigation
Conversation
…edraws An `Effect` renders its visual and all descendants into an offscreen layer and re-applies the blur filter over the whole layer. Because the custom window frame put `drop-shadow` on the Grid wrapping the entire window content, any change inside the window (e.g. hovering a row in the commit history) invalidated the whole window and re-blurred it every frame, making row highlight visibly lag behind the mouse. The dirty-rects debug overlay shows the entire window flashing on every mouse move. Move every shadow onto the Border that paints the background as a `BoxShadow` with the same offset, blur and color. A BoxShadow is part of that Border's own drawing, so changes in its children only dirty their own bounds. The hunk action bar uses a scoped style to set BoxShadow on each flat button's PART_Border since a StackPanel has no BoxShadow. See also AvaloniaUI/Avalonia#18358 for the same effect-on-parent issue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kosmakoff
marked this pull request as ready for review
December 4, 2026 19:36
kosmakoff
marked this pull request as draft
December 4, 2026 22:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On my laptop the UI is sluggish: when moving the mouse up and down over the commit history, the row highlight visibly lags behind the cursor. With Avalonia DevTools' dirty rects overlay enabled, the entire window flashes on every mouse move, as if each row highlight triggered a full-window redraw.
I instrumented the app to log every property change and layout pass while hovering the history list. Hovering causes zero layout passes; the only changes are
IsPointerOverflags and each row'sBackgroundRectangle.Fill(a 1388×26 rect). So SourceGit's own code only invalidates the row it changes, and the full-window redraw comes from the rendering side.The cause is the custom window frame template in
Resources/Styles.axaml:Avalonia renders a visual that has an
Effect, together with all its descendants, into an offscreen layer, then applies the filter to the whole layer. A blur depends on neighbouring pixels, so any change inside the layer dirties the whole effect area. Because this effect wraps the entire window content, every row highlight re-rendered the whole window and re-ran the blur over it. On a 4K panel at 2.25× scale that is a lot of pixels per mouse move. The same mechanism is reported upstream in AvaloniaUI/Avalonia#18358 ("High GPU usage of animation in nested visual tree with static effect"). The reporter's workaround there is also to move the shadow off the parent.Evidence (gathered on an Avalonia 12 build, where I could toggle each factor independently):
drop-shadoweffect)* The remaining full-window flashing comes from GL swapchains not keeping the previous frame, which forces Avalonia to repaint the whole window anyway. That part is an Avalonia/backend setting and is not changed in this PR. The expensive part is re-running the blur over the whole window, and that is what this PR removes.
Changes
Every
drop-shadowEffectbecomes aBoxShadowwith the same offset, blur and color, placed on theBorderthat paints the background. ABoxShadowis part of thatBorder's own drawing, so changes in its children only dirty their own bounds and no blur runs over the content.Styles.axaml): the main fix. The shadow moved from theGridwrapping the whole window content toPART_ContentRoot.Styles.axaml).TextDiffView.axaml): aStackPanelhas noBoxShadow, so a scoped style sets it on each flat button'sPART_Border. Stage and Unstage are never visible together, and Discard has an 8px margin, so the per-button shadows don't overlap.No
Effect=attributes remain in any.axamlfile. No code, dependencies or Avalonia version changes; this is still Avalonia 11.3.22.Visual note:
BoxShadowblur is calculated a little differently from thedrop-shadowfilter, so shadow edges may look slightly different. If any look too hard or too soft, the third number (blur) can be tuned.Environment
Related
drop-shadoweffects, so it would carry the same full-window re-blur. This change is independent of the Avalonia version and should merge cleanly before or after it. On Avalonia 12 the Wayland backend also offersWaylandPlatformOptions.UsePartialPresentation(Add opt-in EGL partial presentation AvaloniaUI/Avalonia#22501), which removed the remaining full-window repaint in my testing. That would belong in the migration, not here.CommitGraph.Renderwhen scrolling long histories. It doesn't address this per-frame blur, so the two changes complement each other.🤖 Generated with Claude Code