-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
ImageSource.FromStream Leads to Crash #15397
Comments
The stream is being closed after the image is loaded. When we create the ImageSource from Stream, we dispose of the underlying stream. Backgrounding and recreating the activity causes the existing UI to try and rerender, using the original instances of the ImageSource with its now disposed MemoryStream, causing it to throw. You could most likely do this outside of backgrounding/foregrounding the app if you reusing existing ImageSources within different images in different views. I'm not sure of the right way to tackle this: If you change this code to not try and reload the underlying stream, it won't crash, but there won't be an image. If you don't force the stream to dispose, the image will reload, but now you have a floating Stream. And if the user disposes it themselves, you'll hit the same issue. @mattleibow @jonathanpeppers Any thoughts on this? |
Could this be fixed by: |
will this fix be released with the next release of .net 8 preview ? |
Yeah, it's on the release branch to ship on the next preview: https://github.com/dotnet/maui/commits/release/8.0.1xx-preview5?author=jstedfast |
Hi @DeepWorksStudios. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version. You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
I cant i need to wait for a stable version since otherwise I would need to reinstall everthing for my production environment wich is not feasible. But I run always the latest vs studio preview on my device |
Fixed by #14109 |
Description
If you use an Image and populate it source trough ImageSource.FromStream and you have a sort of android service wich keeps the mainactivity somehow alive than if you start and close the app it leads to an crash
I found this out by diagnosing the callstack and trying to reproduce it with a clean project with only the services and the mainpage with a image in combination with ImageSource fromstream.
i added the log, callstack and a repoduction repo
callStack.txt
exception.txt
debugLog.txt
Steps to Reproduce
Experienced behaviour: App runs smoothly
Observed behaviour: App crashes
Link to public reproduction project repository
Reproduction project
Version with bug
7.0.86
Last version that worked well
Unknown/Other
Affected platforms
Android, I was not able test on other platforms
Affected platform versions
Any Api Level
Did you find any workaround?
Yes via using the HandlerChanged event
i added the solution in the repo aswell in mainpage.cs
Relevant log output
The text was updated successfully, but these errors were encountered: