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

Fix composition render resources invalidation #12146

Merged

Conversation

MrJul
Copy link
Member

@MrJul MrJul commented Jul 11, 2023

What does the pull request do?

This PR ensures that updating a render resource correctly invalidates all the other render elements using it.

What is the current behavior?

In some situations, resources aren't correctly invalidated: see #11673 for more information.

How was the solution implemented?

There were actually two different problems:

Resources collection in ServerCompositionRenderData

In RenderDataDrawingContext exists a stack of lists of IRenderDataItem to eventually send to server part of the compositor. In Pop(), current items are added to their parent RenderDataPushNode if there's one. However, those child items aren't searched for resources by the ServerCompositionRenderData, which is responsible for setting up the resource tracking. The first commit fixes that by searching for the resources recursively inside RenderDataPushNode items.

I didn't add a test as there seem to be no test infrastructure currently regarding the render resource usages and invalidation, and it isn't an easy part easy to plug into.

InlineDictionary enumeration

InlineDictionary has three backing strategies: single item, array (2 to 6 items) and dictionary (7+ items). In array mode, the enumerator was broken as it stopped at the first hole (null item) in the array, but all the other methods expect or add holes. This affected Remove, which sets the removed item to null. It also affected Add, which was filling the last hole instead of the first, so the enumerator could never return them unless the array was full.

The resource usages are tracked using a RefCountingSmallDictionary, which uses an InlineDictionary.

The enumeration has been fixed, and Add() now takes the first available hole.
Two tests have been added.

Fixed issues

Fixes #11673

@MrJul MrJul requested a review from kekekeks July 11, 2023 17:32
@SKProCH
Copy link
Contributor

SKProCH commented Jul 11, 2023

Can you trigger a nightly nuget release in some way? After that i can test it in my project, to verify, does this solve problems.

@avaloniaui-team
Copy link
Contributor

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

@kekekeks kekekeks enabled auto-merge July 12, 2023 07:26
@SKProCH
Copy link
Contributor

SKProCH commented Jul 12, 2023

Yep, this actually fixed the issue at least in the sample project. Thanks!

@kekekeks kekekeks added this pull request to the merge queue Jul 13, 2023
Merged via the queue into AvaloniaUI:master with commit 124f124 Jul 13, 2023
@MrJul MrJul deleted the fixes/composition-resources-invalidation branch July 13, 2023 11:44
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.

Changing color of SolidColorBrush don't cause a rerender
5 participants