Skip to content
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

Added guards for compositor reentrancy and exposed batch lifetime events #12968

Merged
merged 2 commits into from
Sep 22, 2023

Conversation

kekekeks
Copy link
Member

@kekekeks kekekeks commented Sep 21, 2023

We have reports about a problem caused by reentrancy in our rendering code.

Those are hard to diagnose, since reported exception is thrown way after said reentrancy happened.

This PR:

  1. Adds reentrancy guard for the compositor
  2. Disables dispatcher processing if compositor is forced to produce a frame on the UI thread
  3. Fixes a potential (but unlikely) cause for possible reentrancy
  4. Exposes extra information about composition batch lifetime
  5. Adds Dispatcher.AwaitOnPriority

Those won't necessary fix the issue, but at least we'll get a proper stack trace.

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0039744-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

/// <summary>
/// Returns a task awaitable that would invoke continuation on specified dispatcher priority
/// </summary>
public DispatcherPriorityAwaitable AwaitWithPriority(Task task, DispatcherPriority priority) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, can this be used like JoinableTaskFactory.SwitchToMainThreadAsync in VS? Like this example?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it can be used from background threads too.

@maxkatz6 maxkatz6 added this pull request to the merge queue Sep 22, 2023
Merged via the queue into master with commit 96d2ea4 Sep 22, 2023
7 checks passed
@maxkatz6 maxkatz6 deleted the fixes/compositor-reentrancy branch September 22, 2023 00:47
@grokys grokys added the backport-candidate-11.0.x Consider this PR for backporting to 11.0 branch label Oct 2, 2023
grokys pushed a commit that referenced this pull request Oct 2, 2023
…nts (#12968)

* Added guards for compositor reentrancy and exposed batch lifetime events

* Use manual continue with since our tests are using some borked sync context
grokys pushed a commit that referenced this pull request Oct 2, 2023
…nts (#12968)

* Added guards for compositor reentrancy and exposed batch lifetime events

* Use manual continue with since our tests are using some borked sync context
@grokys grokys added backported-11.0.x and removed backport-candidate-11.0.x Consider this PR for backporting to 11.0 branch labels Oct 14, 2023
stepangovorko pushed a commit to JetBrains/Avalonia that referenced this pull request Oct 23, 2023
…nts (AvaloniaUI#12968)

* Added guards for compositor reentrancy and exposed batch lifetime events

* Use manual continue with since our tests are using some borked sync context

(cherry picked from commit 96d2ea4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants