AvaloniaUI/Avalonia

Closing a TopLevel causes Render to happen out of sequence (MediaContext issue)

Opened this issue · 0 comments

Describe the bug

The a toplevel closes i.e. from combobox or popup etc

HandleClosed is called, causing MediaContext SyncCommit, which triggers a full render pass for all TopLevels.

This Render pass is called without a layout pass, so you can be rendering invalid state.

To Reproduce

  1. Checkout the branch repros/text-alignment-issue

  2. select an option from the combobox, and see the textlblock on the page change (but be left aligned) It should be right aligned.

  3. resize the window to trigger a layout pass, and notice the text alignment corrects itself.

  4. place a breakpoint in TopLevel.HandleClosed and repeat
    see that this is called and note the comment
    SyncDisposeCompositionTarget

// TODO: introduce a way to skip any actual rendering for other targets and only do a dispose?

so render gets called, but we only need to dispose.

Expected behavior

The text alignment should not change, render should not be called on the textblock

Media context should "have a way to notify the compositor about dispose and wait for the current frame and dispose to finish"

Avalonia version

11.2.x

OS

No response

Additional context

No response