BitmapSource async action lifetime leak
Describe the bug
BitmapSource::OnStreamReadCompleted transfers a Core reference to the async action into CImageSource::m_pAsyncAction. Normal decode completion reaches CompleteAsyncAction, which fires completion, releases the Core reference, and clears the pointer. During destruction, however, DisconnectImageOperation clears the decode callback; the callback can no longer complete the action, and the legacy destructor leaves m_pAsyncAction alive in Started indefinitely.
See System XAML fix connected to: task 62354588: Fix BitmapSource async action lifetime leak
Why is this important?
This can and has resulted in memory leaks when CImageSource is destroyed before the decode callback has completed.
Steps to reproduce the bug
Unit tests reproduces the leak in the System XAML fix PR connected to: task 62354588: Fix BitmapSource async action lifetime leak
Actual behavior
CImageSource::m_pAsyncAction is leaked when destruction occurs before decode action completion.
Expected behavior
CImageSource::m_pAsyncAction should not be leaked when destruction occurs before decode action completion.
Screenshots
No response
NuGet package version
1.8.260317003
Windows version
Windows 11 (25H2): Build 26200
Additional context
No response
Source: microsoft/microsoft-ui-xaml