CompositionTarget.Rendering not always can be unsubscribed. #4621
Labels
appModel-win32
Exclusive to WinUI 3 Win32 Desktop apps
area-C#/WinRT
product-winui3
WinUI 3 issues
team-Markup
Issue for the Markup team
Describe the bug
CompositionTarget.Rendering -= Callback;
is supposed to unassign the method, but sometimes it doesn't.
Steps to reproduce the bug
The WCT uses this pattern in our TokenizingTextBox:
Opening the WCT sample app (the WinUI3 version) and clicking a few times to add an item from the TTB will eventually reproduce this.
We then get exceptions on taskCompletionSource.SetResult(true), since this is trying to complete the task more than once. I worked around this issue by switching to a TrySetResult, and only if successful we call the callback, but there will be performance and memory problems with this, since that no-op method will still be called at every single time this callback is called (every render...).
This method worked fine on UWP/XAML for a while now, but it intermittently fails to unassign the callback (but after the first time, it keeps calling that callback, even given the fact that we unsubscribe as the very first thing inside the callback).
Expected behavior
CompositionTarget.Rendering -= Callback
actually removed the method from the callback list, never being called again unless resubscribed.
Version Info
Reunion 0.5-Prerelease, but this is not a new regression, as this has been seem in previous previews.
NuGet package version:
[WinUI 3 - Project Reunion 0.5 Preview: 0.5.0-prerelease]
Windows app type:
The text was updated successfully, but these errors were encountered: