[Android] System.ObjectDisposedException: ObjectDisposed_StreamClosed #21461
Labels
area-controls-image
Image control
migration-compatibility
Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert
platform/android 🤖
s/needs-repro
Attach a solution or code which reproduces the issue
s/triaged
Issue has been reviewed
t/bug
Something isn't working
Description
Image Stream closes while loading
Steps to Reproduce
Hard one to reproduce, did try to create a repro but couldn't. Seems like it's happening because of
ImageSource.FromResource
,ImageSource.FromStream
, under the hood stream loading func is wrapped with Task.Run, if I instead usenew StreamImageSource { Stream = _ => GetStreamLogic() }
then no crash.not sure, probably
Stream
closes whilePlatformInterop.LoadImageFromStream(imageView, stream, callback);
is still executing here.could it be sth like this https://kevingosse.medium.com/c-using-gc-keepalive-in-async-methods-8d20fd79f0a0?
Link to public reproduction project repository
No response
Version with bug
8.0.10 SR3
Is this a regression from previous behavior?
Yes, this used to work in Xamarin.Forms
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
No response
Did you find any workaround?
in my case, the following workarounds helped:
ImageSource.FromResource
/FromStream
usenew StreamImageSource { Stream = _ => GetStreamLogic() }
StreamImageSourceService
and reimplementLoadDrawableAsync
, for instance, use Xamarin approachRelevant log output
The text was updated successfully, but these errors were encountered: