Skip to content
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

Closed
DeepWorksStudios opened this issue Jun 1, 2023 · 7 comments · Fixed by #14109
Closed

ImageSource.FromStream Leads to Crash #15397

DeepWorksStudios opened this issue Jun 1, 2023 · 7 comments · Fixed by #14109
Labels
area-controls-image Image control fixed-in-7.0.96 Look for this fix in 7.0.96 SR8! fixed-in-7.0.100 fixed-in-7.0.101 fixed-in-8.0.0-preview.5.8529 Look for this fix in 8.0.0-preview.5.8529! platform/android 🤖 t/bug Something isn't working

Comments

@DeepWorksStudios
Copy link

DeepWorksStudios commented Jun 1, 2023

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

  1. Create Maui Project
  2. Create A Service wich is sticky and wont get terminated on app close and keeps the root activity alive
  3. Create on the main page the image and the code that loads an imagefrom memorystream
  4. Start the app
  5. Wait untill Foreground service starts
  6. Close App (Really Closing via dismissing the frame)
  7. Open the app again

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

Start debugging Android application ...
Forwarding debugger port 8879
Detecting existing process
> am start -a "android.intent.action.MAIN" -c "android.intent.category.LAUNCHER" -n "com.companyname.reproductionprojectbug_imagesourcefromstream/crc64ec1f2e46cb2b668f.MainActivity"
> Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.companyname.reproductionprojectbug_imagesourcefromstream/crc64ec1f2e46cb2b668f.MainActivity }
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/ReproductionProjectBug_ImageSourceFromStream.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Mono.Android.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Runtime.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Java.Interop.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Runtime.InteropServices.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Collections.dll [External]
Resolved pending breakpoint for 'Android.Runtime.JNIEnv.RegisterJniNatives(System.IntPtr, System.Int32, System.IntPtr, System.IntPtr, System.Int32)' to /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:127 [0x00000].
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Threading.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Threading.Thread.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Diagnostics.StackTrace.dll [External]
Loaded assembly: data-0xa7b0c020 [External]
Loaded assembly: data-0xa7b24040 [External]
Loaded assembly: data-0xa2bd1e60 [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/netstandard.dll [External]
[ourcefromstrea] Late-enabling -Xcheck:jni
[ourcefromstrea] Using CollectorTypeCC GC.
[ProcessState] Binder ioctl to enable oneway spam detection failed: Invalid argument
[CompatibilityChangeReporter] Compat change id reported: 171979766; UID 10183; state: ENABLED
[ziparchive] Unable to open '/data/app/~~8tlV5wnEuvt8eMkwzyK8TQ==/com.companyname.reproductionprojectbug_imagesourcefromstream-VggzvcV1Dx5h9-zSuNjjSw==/base.dm': No such file or directory
[ziparchive] Unable to open '/data/app/~~8tlV5wnEuvt8eMkwzyK8TQ==/com.companyname.reproductionprojectbug_imagesourcefromstream-VggzvcV1Dx5h9-zSuNjjSw==/base.dm': No such file or directory
[nativeloader] Configuring classloader-namespace for other apk /data/app/~~8tlV5wnEuvt8eMkwzyK8TQ==/com.companyname.reproductionprojectbug_imagesourcefromstream-VggzvcV1Dx5h9-zSuNjjSw==/base.apk. target_sdk_version=33, uses_libraries=, library_path=/data/app/~~8tlV5wnEuvt8eMkwzyK8TQ==/com.companyname.reproductionprojectbug_imagesourcefromstream-VggzvcV1Dx5h9-zSuNjjSw==/lib/arm:/data/app/~~8tlV5wnEuvt8eMkwzyK8TQ==/com.companyname.reproductionprojectbug_imagesourcefromstream-VggzvcV1Dx5h9-zSuNjjSw==/base.apk!/lib/armeabi-v7a, permitted_path=/data:/mnt/expand:/data/user/0/com.companyname.reproductionprojectbug_imagesourcefromstream
[GraphicsEnvironment] ANGLE Developer option for 'com.companyname.reproductionprojectbug_imagesourcefromstream' set to: 'default'
[GraphicsEnvironment] Neither updatable production driver nor prerelease driver is supported.
[NetworkSecurityConfig] No Network Security Config specified, using platform default
[NetworkSecurityConfig] No Network Security Config specified, using platform default
[debug-app-helper] Checking if libmonodroid was unpacked to /data/app/~~8tlV5wnEuvt8eMkwzyK8TQ==/com.companyname.reproductionprojectbug_imagesourcefromstream-VggzvcV1Dx5h9-zSuNjjSw==/lib/arm/libmonodroid.so
[debug-app-helper] Native libs extracted to /data/app/~~8tlV5wnEuvt8eMkwzyK8TQ==/com.companyname.reproductionprojectbug_imagesourcefromstream-VggzvcV1Dx5h9-zSuNjjSw==/lib/arm, assuming application/android:extractNativeLibs == true
[debug-app-helper] Setting up for DSO lookup in app data directories
[debug-app-helper] Added filesystem DSO lookup location: /data/app/~~8tlV5wnEuvt8eMkwzyK8TQ==/com.companyname.reproductionprojectbug_imagesourcefromstream-VggzvcV1Dx5h9-zSuNjjSw==/lib/arm
[debug-app-helper] Using runtime path: /data/app/~~8tlV5wnEuvt8eMkwzyK8TQ==/com.companyname.reproductionprojectbug_imagesourcefromstream-VggzvcV1Dx5h9-zSuNjjSw==/lib/arm
[debug-app-helper] checking directory: `/data/user/0/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/lib`
[debug-app-helper] directory does not exist: `/data/user/0/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/lib`
[debug-app-helper] Checking whether Mono runtime exists at: /data/user/0/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/libmonosgen-2.0.so
[debug-app-helper] Checking whether Mono runtime exists at: /data/app/~~8tlV5wnEuvt8eMkwzyK8TQ==/com.companyname.reproductionprojectbug_imagesourcefromstream-VggzvcV1Dx5h9-zSuNjjSw==/lib/arm/libmonosgen-2.0.so
[debug-app-helper] Mono runtime found at: /data/app/~~8tlV5wnEuvt8eMkwzyK8TQ==/com.companyname.reproductionprojectbug_imagesourcefromstream-VggzvcV1Dx5h9-zSuNjjSw==/lib/arm/libmonosgen-2.0.so
[ourcefromstrea] Attempt to remove non-JNI local reference, dumping thread
[DOTNET] JNI_OnLoad: JNI_OnLoad in pal_jni.c
[DOTNET] GetOptionalClassGRef: optional class com/android/org/conscrypt/OpenSSLEngineImpl was not found
[monodroid] Creating public update directory: `/data/user/0/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__`
[ourcefromstrea] Attempt to remove non-JNI local reference, dumping thread
[monodroid-debug] Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8879,server=y,embedding=1
[monodroid-assembly] open_from_bundles: failed to load assembly ReproductionProjectBug_ImageSourceFromStream.dll
[monodroid-gc] GREF GC Threshold: 46080
[monodroid-assembly] open_from_bundles: failed to load assembly Mono.Android.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Runtime.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Java.Interop.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Runtime.InteropServices.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Collections.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Threading.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Threading.Thread.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Diagnostics.StackTrace.dll
[ourcefromstrea] Attempt to remove non-JNI local reference, dumping thread
[monodroid-assembly] open_from_bundles: failed to load assembly netstandard.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Linq.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Linq.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.VisualStudio.DesignTools.TapContract.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.VisualStudio.DesignTools.TapContract.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.HotReload.Contracts.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.HotReload.Contracts.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Collections.Concurrent.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Collections.Concurrent.dll [External]
Resolved pending breakpoint for 'Xamarin.HotReload.HotReloadAgent.BreakpointSendToIde(System.String)' to D:\a\_work\1\s\HotReload\Source\Xamarin.HotReload.Agent\HotReloadAgent.cs:423 [0x00000].
[monodroid-assembly] open_from_bundles: failed to load assembly System.Text.Json.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Text.Json.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly System.Text.Encodings.Web.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Text.Encodings.Web.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly System.ComponentModel.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.ComponentModel.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.Maui.Controls.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.HotReload.Contracts.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.HotReload.Contracts.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Microsoft.Maui.Controls.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.VisualStudio.DesignTools.TapContract.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.VisualStudio.DesignTools.TapContract.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.ObjectModel.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.Maui.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.ObjectModel.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Microsoft.Maui.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.Maui.Graphics.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.Maui.Essentials.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.Extensions.Logging.Abstractions.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Microsoft.Maui.Graphics.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Microsoft.Maui.Essentials.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Microsoft.Extensions.Logging.Abstractions.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly System.ComponentModel.TypeConverter.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.ComponentModel.TypeConverter.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly System.Private.Uri.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Private.Uri.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly System.Runtime.Loader.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Runtime.Loader.dll [External]
Resolved pending breakpoint for 'Xamarin.HotReload.HotReloadAgent.BreakpointCheckpoint()' to D:\a\_work\1\s\HotReload\Source\Xamarin.HotReload.Agent\HotReloadAgent.cs:418 [0x00000].
[monodroid-assembly] open_from_bundles: failed to load assembly System.Memory.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Memory.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly System.Reflection.Emit.Lightweight.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Reflection.Emit.ILGeneration.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Reflection.Primitives.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Reflection.Emit.Lightweight.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Reflection.Emit.ILGeneration.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Reflection.Primitives.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.Core.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.AndroidX.Core.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.Extensions.DependencyInjection.Abstractions.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Microsoft.Extensions.DependencyInjection.Abstractions.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly System.Console.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Console.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.Maui.Controls.Xaml.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.Extensions.Configuration.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.Extensions.Configuration.Abstractions.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.Extensions.Logging.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.Extensions.Logging.Debug.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Microsoft.Maui.Controls.Xaml.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Microsoft.Extensions.Configuration.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Microsoft.Extensions.Configuration.Abstractions.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Microsoft.Extensions.Logging.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Microsoft.Extensions.Logging.Debug.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.AppCompat.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.Google.Android.Material.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.SwipeRefreshLayout.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.AndroidX.AppCompat.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.Google.Android.Material.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.AndroidX.SwipeRefreshLayout.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.Fragment.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.Activity.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.Lifecycle.ViewModel.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.Lifecycle.Common.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.SavedState.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.AndroidX.Fragment.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.AndroidX.Activity.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.AndroidX.Lifecycle.ViewModel.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.AndroidX.Lifecycle.Common.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.AndroidX.SavedState.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.DrawerLayout.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.CustomView.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.Navigation.Runtime.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.AndroidX.DrawerLayout.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.AndroidX.CustomView.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.AndroidX.Navigation.Runtime.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly System.Net.Primitives.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Net.Primitives.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.Extensions.Options.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Microsoft.Extensions.Options.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.Extensions.DependencyInjection.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Microsoft.Extensions.DependencyInjection.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly System.Diagnostics.Tracing.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Diagnostics.Tracing.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly System.Xml.ReaderWriter.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Private.Xml.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Xml.ReaderWriter.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Private.Xml.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly System.Text.Encoding.Extensions.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Text.Encoding.Extensions.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly en-GB/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly en-GB/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly en/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly en/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Numerics.Vectors.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Numerics.Vectors.dll [External]
[ourcefromstrea] Explicit concurrent copying GC freed 72420(3360KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 2063KB/4111KB, paused 83us,43us total 17.862ms
[monodroid-assembly] open_from_bundles: failed to load assembly System.Text.RegularExpressions.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Text.RegularExpressions.dll [External]
Thread started:  #2
Thread started:  #3
Thread started:  #4
[monodroid-assembly] open_from_bundles: failed to load assembly System.Runtime.Serialization.Json.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Private.DataContractSerialization.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Runtime.Serialization.Xml.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Runtime.Serialization.Primitives.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Runtime.Serialization.Json.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Private.DataContractSerialization.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Runtime.Serialization.Xml.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Runtime.Serialization.Primitives.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly en-GB/System.Private.DataContractSerialization.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly en-GB/System.Private.DataContractSerialization.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly en/System.Private.DataContractSerialization.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly en/System.Private.DataContractSerialization.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.RecyclerView.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.CardView.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.AndroidX.RecyclerView.dll [External]
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.AndroidX.CardView.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.Loader.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.AndroidX.Loader.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.Maui.Controls.Compatibility.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Microsoft.Maui.Controls.Compatibility.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.Window.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.AndroidX.Window.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.CoordinatorLayout.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.AndroidX.CoordinatorLayout.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.Lifecycle.LiveData.Core.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.AndroidX.Lifecycle.LiveData.Core.dll [External]
[ourcefromstrea] Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (unsupported, reflection, allowed)
[ourcefromstrea] Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (unsupported, reflection, allowed)
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.ViewPager2.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.AndroidX.ViewPager2.dll [External]
[CompatibilityChangeReporter] Compat change id reported: 171228096; UID 10183; state: ENABLED
[TabLayout] MODE_SCROLLABLE + GRAVITY_FILL is not supported, GRAVITY_START will be used instead
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.Lifecycle.Runtime.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.AndroidX.Lifecycle.Runtime.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.ViewPager.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Xamarin.AndroidX.ViewPager.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly System.Net.Http.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Net.Http.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly System.Security.Cryptography.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Security.Cryptography.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly System.Diagnostics.DiagnosticSource.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Diagnostics.DiagnosticSource.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly System.Collections.NonGeneric.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Collections.NonGeneric.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly System.Net.Requests.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Net.Requests.dll [External]
Thread started: .NET Timer #5
Thread started: <Thread Pool> #6
Thread started: .NET ThreadPool Gate #7
Thread started: <Thread Pool> #8
[SurfaceFactory] [static] sSurfaceFactory = com.mediatek.view.impl.SurfaceFactoryImpl@bd3c12f
[ViewRootImpl[MainActivity]] hardware acceleration = true, sRendererEnabled = true, forceHwAccelerated = false
[BufferQueueConsumer] [](id:18ab00000000,api:0,p:-1,c:6315) connect: controlledByApp=false
[BLASTBufferQueue] [ViewRootImpl[MainActivity]#0] constructor()
[hw-ProcessState] Binder ioctl to enable oneway spam detection failed: Invalid argument
[BufferQueueProducer] [ViewRootImpl[MainActivity]#0(BLAST Consumer)0](id:18ab00000000,api:1,p:6315,c:6315) connect: api=1 producerControlledByApp=true
[ion] ioctl c0044901 failed with code -1: Invalid argument
Thread started: <Thread Pool> #9
[OpenGLRenderer] fbcNotifyFrameComplete error: undefined symbol: fbcNotifyFrameComplete
[OpenGLRenderer] fbcNotifyNoRender error: undefined symbol: fbcNotifyNoRender
[monodroid-assembly] open_from_bundles: failed to load assembly System.IO.Compression.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.IO.Compression.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.Extensions.Primitives.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/Microsoft.Extensions.Primitives.dll [External]
[monodroid-assembly] Shared library 'liblog' not loaded, p/invoke '__android_log_print' may fail
[DOTNET] Foreground task is running...
Thread started:  #10
[DOTNET] Foreground task is running...
[monodroid-assembly] open_from_bundles: failed to load assembly System.Runtime.Intrinsics.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Runtime.Intrinsics.dll [External]
[DOTNET] Foreground task is running...
[DOTNET] Foreground task is running...
[monodroid-assembly] open_from_bundles: failed to load assembly System.Xml.XmlSerializer.dll
Loaded assembly: /data/data/com.companyname.reproductionprojectbug_imagesourcefromstream/files/.__override__/System.Xml.XmlSerializer.dll [External]
Thread started: <Thread Pool> #11
Thread started: <Thread Pool> #12
[DOTNET] Foreground task is running...
[DOTNET] Foreground task is running...
[DOTNET] Foreground task is running...
[BufferQueueProducer] [ViewRootImpl[MainActivity]#0(BLAST Consumer)0](id:18ab00000000,api:1,p:6315,c:6315) disconnect: api 1
[BLASTBufferQueue] [ViewRootImpl[MainActivity]#0] destructor()
[BufferQueueConsumer] [ViewRootImpl[MainActivity]#0(BLAST Consumer)0](id:18ab00000000,api:0,p:-1,c:6315) disconnect
[BLASTBufferQueue] releaseBufferCallbackThunk bufferId:27122718474246 framenumber:3 blastBufferQueue is dead
[View] [Warning] assignParent to null: this = DecorView@1e1d17e[MainActivity]
[DOTNET] Foreground task is running...
[DOTNET] Foreground task is running...
[DOTNET] Background task is running...
[DOTNET] Foreground task is running...
[DOTNET] Background task is running...
[DOTNET] Foreground task is running...
[TabLayout] MODE_SCROLLABLE + GRAVITY_FILL is not supported, GRAVITY_START will be used instead
[ViewRootImpl[MainActivity]] hardware acceleration = true, sRendererEnabled = true, forceHwAccelerated = false
[BufferQueueConsumer] [](id:18ab00000001,api:0,p:-1,c:6315) connect: controlledByApp=false
[BLASTBufferQueue] [ViewRootImpl[MainActivity]#1] constructor()
[BufferQueueProducer] [ViewRootImpl[MainActivity]#1(BLAST Consumer)1](id:18ab00000001,api:1,p:6315,c:6315) connect: api=1 producerControlledByApp=true
Thread started:  #13
[DOTNET] Background task is running...
[DOTNET] Foreground task is running...
**System.ObjectDisposedException:** 'Cannot access a closed Stream.'

[DOTNET] Background task is running...
@DeepWorksStudios DeepWorksStudios added the t/bug Something isn't working label Jun 1, 2023
@Eilon Eilon added the area-image Image loading, sources, caching label Jun 1, 2023
@drasticactions
Copy link
Contributor

drasticactions commented Jun 12, 2023

The stream is being closed after the image is loaded.

https://github.com/dotnet/maui/blob/main/src/Core/src/ImageSources/StreamImageSourceService/StreamImageSourceService.Android.cs#L32

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?

@jonathanpeppers
Copy link
Member

@DeepWorksStudios
Copy link
Author

will this fix be released with the next release of .net 8 preview ?

@jonathanpeppers
Copy link
Member

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

@PureWeen PureWeen added the s/try-latest-version Please try to reproduce the potential issue on the latest public version label Jun 26, 2023
@ghost
Copy link

ghost commented Jun 26, 2023

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.

@DeepWorksStudios
Copy link
Author

DeepWorksStudios commented Jun 26, 2023

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

@ghost ghost removed the s/try-latest-version Please try to reproduce the potential issue on the latest public version label Jun 26, 2023
@samhouts samhouts added this to the .NET 8 milestone Aug 8, 2023
@samhouts samhouts added the fixed-in-8.0.0-preview.5.8529 Look for this fix in 8.0.0-preview.5.8529! label Aug 8, 2023
@PureWeen
Copy link
Member

PureWeen commented Aug 9, 2023

Fixed by #14109

@PureWeen PureWeen closed this as completed Aug 9, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Sep 8, 2023
@samhouts samhouts added the fixed-in-7.0.96 Look for this fix in 7.0.96 SR8! label Oct 10, 2023
@Eilon Eilon added area-controls-image Image control and removed area-image Image loading, sources, caching labels May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-image Image control fixed-in-7.0.96 Look for this fix in 7.0.96 SR8! fixed-in-7.0.100 fixed-in-7.0.101 fixed-in-8.0.0-preview.5.8529 Look for this fix in 8.0.0-preview.5.8529! platform/android 🤖 t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants