Long-lived BitmapImage
s with ms-appx://
source get unloaded or corrupted
#10080
Labels
BitmapImage
s with ms-appx://
source get unloaded or corrupted
#10080
Describe the bug
I have a WinUI/WinAppSDK app that remains open & running for days or weeks at a time and have observed a regression in
BitmapImage
as of 1.6.240829007 that affectsBitmapImage
instances loaded from ams-appx://
source (only tested with PNG).These
BitmapImage
s are created once and used repeatedly in the app (via the backingImageSource
property ofImage
instances). Everything starts off fine but after some time the images in the UI that are loaded from thems-appx://
-backedBitmapImage
end up blanking out (as if theBitmapImage
s were null, even though theBitmapImage
is not null, theImage
in question is not null, and theImage.Source
corrects to the correctBitmapImage
instance).Re-setting the
Source
property of theImage
to the sameBitmapImage
value does not help, neither does callingPropertyChanged
for theImage
property of the bound object.In this app, the same UI field is populated either with a dynamically created
BitmapImage
or with one of several fallbackms-appx://
-backedreadonly static BitmapImage
s loaded once at app startup and never written to or modified thereafter. The images that were created from a dynamically createdBitmapImage
continue to display correctly but only images loaded from aBitmapImage
backed by a (png)ms-appx://
url end up being corrupted/broken (though they continue to appear to be loaded just fine when inspecting the state of the software in the debugger, instead of visually).This behavior was observed after upgrading from WindowsAppSDK version 1.5.240627000; I don't believe the previous version exhibited this behavior even after the app was left running for weeks.
For context, the image is a property of a UI element that is bound to a list view's item template, so there is a huge list that has been virtualized and the "profile picture" is either loaded from a per-item value or falls back to a static generic placeholder. So the same code applies to thousands of entries in the list view but after days it is only those that point to the statically loaded
ms-appx://
-mapped BitmapImage that end up no longer appearing in the UI while those that were dynamically constructed and not backed by anms-appx://
url continue to work. There is no code that operates specifically on entries that don't have a custom per-entry image, the same code that touches one touches the other. Thereadonly static BitmapImage
loaded from thems-appx://
is not even referenced anywhere in the code besides being mapped via a Xaml source converter in the same ternary expression as the one that uses the dynamically constructed BitmapImage instead.Steps to reproduce the bug
Assets
folderImage
to your XAML form, possibly as a member of aListView
with 1000s of entries so that some of them are virtualized with multiple of them sharing the sameBitmapImage
source.BitmapImage
with its uri set toms-appx://path/to/image.png
Image
'sSource
property to theBitmapImage
for many of theListView
images, some at the top of the list, some in the middle, and some at the end.Expected behavior
Regardless of whether the
BitmapImage
was sourced from anms-appx://
URL or from a dynamically createdBitmapImage
, it should remain resident in the UI if it hasn't been unset, modified, or disposed.Screenshots
No response
NuGet package version
None
Windows version
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: