microsoft / microsoft/microsoft-ui-xaml
Using images from PRI doesn't work
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
### Describe the bug
Using an `` control with the image data coming from the PRI doesn't work.
### Steps to reproduce the bug
1. Create an unpacked WinUI 3 app, add an ``, with one of the files from `Assets` as the `Source`.
(Done here, for your convenience: [WinUIPriImage.zip](https://github.com/user-attachments/files/21047253/WinUIPriImage.zip))
2. Run the app.
The image should show as expected.
3. Delete the "Assets" directory from the output directory.
This will force the image being read from the `.pri`.
4. Run app again.
Notice the image does _not_ show.
### Expected behavior
Images from PRIs load correctly.
### Screenshots
_No response_
### NuGet package version
WinUI 3 - Windows App SDK 1.7.3: 1.7.250606001
### Windows version
Windows 11 (24H2): Build 26100
### Additional context
One potential cause of the issue is in `CMRTResource::Load()`.
In the `ResourceCandidateKind_EmbeddedData` case, a "PALMemory" object is returned, but the actual memory is still owned by the `CMRTResource` instance. But it seems the `CMRTResource` object is destroyed before the image is decoded (ie the "PALMemory" object lives longer than the memory it wraps - oops).
Conversely, the `ResourceCandidateKind_FilePath` case returns a "Memory" object that does it's own file mapping and is not affected by the `CMRTResource` being freed. Hence loading images from physical files works fine.
Contributor guide
Research direction
Start at CMRTResource::Load(), focusing on the ResourceCandidateKind_EmbeddedData path and how its PALMemory result is owned. Reproduce the issue with the provided WinUIPriImage.zip app, including deleting the output Assets directory. Done means the image loads from the .pri when the physical Assets directory is absent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100