[Android] MemoryStream.Read ObjectDisposed_StreamClosed
- Dominant language
- C#
- Stars
- 23.3k
- Forks
- 2k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 296
Description
Description
I'm receiving the error bellow on Sentry when loading image from stream like ImageSource.FromStream(() => new MemoryStream(imagedata) in release build of android it produce garbage image
stacktrace:
```
AT SYSTEM.IO.MEMORYSTREAM.READ(BYTE[] , INT32 , INT32 )
AT ANDROID.RUNTIME.INPUTSTREAMADAPTER.READ(BYTE[] BYTES, INT32 OFFSET, INT32 LENGTH)
AT JAVA.IO.INPUTSTREAM.N_READ_ARRAYBII(INTPTR JNIENV, INTPTR NATIVE__THIS, INTPTR NATIVE_B, INT32 OFF, INT32 LEN)
AT ANDROID.RUNTIME.JNINATIVEWRAPPER.WRAP_JNIMARSHAL_PPLII_I(_JNIMARSHAL_PPLII_I CALLBACK, INTPTR JNIENV, INTPTR KLAZZ, INTPTR P0, INT32 P1, INT32 P2)
```
Sorry, there are no other useful information. The app uses Sentry for the crash reporting
Steps to Reproduce
I'm not able to reproduce the crash. I have just a crash report from Sentry.
Link to public reproduction project repository
No response
Version with bug
9.0.90 SR9
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
Android 13, 14, 15 (probably all)
Did you find any workaround?
No
Relevant log output
Contributor guide
Research direction
Start by tracing ImageSource.FromStream on Android into Android.Runtime.InputStreamAdapter.Read and compare the stream lifetime with the Sentry stack trace. Reproduction is not provided, so first establish a reliable release-build case; done means the image loads correctly without the MemoryStream being disposed during the read.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, csharp
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100