-
Notifications
You must be signed in to change notification settings - Fork 698
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
Loading image fails #9342
Comments
I can't repro in your sample app. Note from the
You may want to turn on mixed mode debugging if not already on to observe native exceptions |
I have mixed mode debugging enabled and no exceptions are thrown. Instead, a blank screen appears and the application continues to respond and display another image. Sometimes it fails to display two consecutive images. In my case, the error manifests itself after about a minute and a half of intensive clicking. After that, it happens more often - every fifth image load, for example. |
I am addressing the problem concurrently on Stack Overflow, and I received an interesting answer suggesting the use of RelayCommand. According to initial findings, it seems that the error does not occur afterward. Is it possible that the RelayCommand handler runs on a different thread than the PointerPressed handler, as it appears in my code? The issue with threads is also indicated by the fact that the error occurs randomly. |
No. There are two major differences in the implementations:
You could rule out 1 as the problem by simply using a bool to return at the start of the event handler if it is already running: private static async Task<BitmapImage> GetImageSourceFromAssets(string path)
{
if(isRunning) return;
isRunning = true;
...
isRunning = false;
} |
I tried to modify the application according to all the advice - avoiding loading from the stream, using ObservableProperty, using RelayCommand, and the error still persists. However, only in my virtualized DEV environment and on one of the customer's two computers. I have come to the conclusion that the issue lies in the environment, not in the application itself. Thank you for your support. |
Describe the bug
I'm developing an application in WinUI 3, and I'm experiencing random failures when loading an image from disk into the Image element. There is a binding between the Source property of the Image element and the ViewModel.
Steps to reproduce the bug
If I repeatedly set the MainImageSource property, the image randomly fails to display, and a white screen remains.
I have created a proof of concept where the described behavior can be reproduced. Clicking within the application loads another image. If I click repeatedly (sometimes even longer than a minute, patience is required), the image fails to load. In the debugger, the loading looks okay, and the Live Property Explorer shows everything as if it were loaded correctly.
If the above-mentioned code is part of a more complex application (with multiple pages and navigation between them), the error occurs earlier.
The error occurs in my development environment with Windows 10, as well as at the customer's site with Windows 11.
Expected behavior
I have tried other methods of loading the image, changing the binding, caching the BitmapImage, and none of them helped.
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: