Android Application crashed with ObjectDisposedException. Stack trace points to ImageElementManager.cs code that was changed by the introduction of gif animated images.
Application does not crash by either catching the ObjectDisposedException or checking for disposal
proposed fix: #8906
Application crashes.
-- will try to create a repro --
Stack Trace:
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer'.
at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <e7e2d009b69d4e5f9a00e6ee600b8a8e>:0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000]
in <e7e2d009b69d4e5f9a00e6ee600b8a8e>:0
at Android.Widget.ImageView.get_Drawable () [0x0000a] in <82e50ec67af648c3b9f43b3d70e21b96>:0
at Xamarin.Forms.Platform.Android.FastRenderers.ImageElementManager.TryUpdateBitmap
(Xamarin.Forms.Platform.Android.IImageRendererController rendererController, Android.Widget.ImageView Control, Xamarin.Forms.IImageElement newImage, Xamarin.Forms.IImageElement previous) [0x00111]
in D:\a\1\s\Xamarin.Forms.Platform.Android\FastRenderers\ImageElementManager.cs:139
at Xamarin.Forms.Platform.Android.FastRenderers.ImageElementManager.OnElementChanged (System.Object sender, Xamarin.Forms.Platform.Android.VisualElementChangedEventArgs e) [0x00094]
in D:\a\1\s\Xamarin.Forms.Platform.Android\FastRenderers\ImageElementManager.cs:54
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.27(intptr,intptr)
at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.27(intptr,intptr)
--- End of inner exception stack trace ---
Same here
I see the same error:
JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self)
System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer'.
I just encountered this. I have a page that immediately loads an image from an URL, but it takes a few seconds to load. If I load the page and then immediately back out to the previous page, the image will try to load after the page is already popped, and I get this error.
How did you fix the problem ?
This should be fixed by
https://github.com/xamarin/Xamarin.Forms/pull/9034
Tested fix with nighly build. It solves the problem
I am experiencing same issue after upgrading to latest Xamarin Forms version 4.4.0.991265+398-sha.ee1eca51d-azdo.3306453 with the following error:
{System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer'.
at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <e7e2d009b69d4e5f9a00e6ee600b8a8e>:0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <e7e2d009b69d4e5f9a00e6ee600b8a8e>:0
at Android.Widget.ImageView.get_Drawable () [0x0000a] in <11f101b564894ca7af6c482ddc51c698>:0
at Xamarin.Forms.Platform.Android.FastRenderers.ImageElementManager.TryUpdateBitmap (Xamarin.Forms.Platform.Android.IImageRendererController rendererController, Android.Widget.ImageView Control, Xamarin.Forms.IImageElement newImage, Xamarin.Forms.IImageElement previous) [0x00111] in D:\a\1\s\Xamarin.Forms.Platform.Android\FastRenderers\ImageElementManager.cs:139
at Xamarin.Forms.Platform.Android.FastRenderers.ImageElementManager.OnElementChanged (System.Object sender, Xamarin.Forms.Platform.Android.VisualElementChangedEventArgs e) [0x00094] in D:\a\1\s\Xamarin.Forms.Platform.Android\FastRenderers\ImageElementManager.cs:54
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <11f101b564894ca7af6c482ddc51c698>:0
at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <11f101b564894ca7af6c482ddc51c698>:0
at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <11f101b564894ca7af6c482ddc51c698>:0
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.18(intptr,intptr)}
Please when will the fix be available in latest update?
Thanks
@microwales :
Can you check on Xamarin Forms version 4.4.0.991477
I think, it has been fixed.
@microwales :
Can you check on Xamarin Forms version 4.4.0.991477I think, it has been fixed.
Yes it is fixed in the latest package. Thanks @tendynewbies
Should be fixed on 4.4.0.991477