-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Bug] System.ObjectDisposedException: 'Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.ImageRenderer'.' #10031
Comments
Hey @easoftwaresanderson thanks for the report! Would you be able to add a small reproduction project for this or at least the full stack trace would be super helpful. Thanks! |
I'm not able to do this small project now. But I'll try asap . Thanks for your response. |
That would be great! For the stack trace; when you hit the exception like in the screenshot, just click the "continue debug" button, so the play button and check the application output pane. The full stack trace should be in there. It will start with the message you posted here: "System.ObjectDisposedException: 'Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.ImageRenderer'.'" and after that lists all the methods that this error message was bubbled up from. Does that make sense? |
I have the same issue, I am simply adding a FacebookButtonLoginRenderer to Android based on this tutorial https://evgenyzborovsky.com/2018/03/09/using-native-facebook-login-button-in-xamarin-forms/ From what I found on the web, I added a try, catch, but the error still shows up on the error list (image below). This is a link to this particular Renderer https://github.com/yuv4ik/XFFacebookLoginButtonExample/blob/master/Droid/Renderers/FacebookLoginButtonRenderer.cs The exception is: System.ObjectDisposedException: Cannot access a disposed object. For reference: |
it's hard to know without a stack trace but I'm guessing this is caused by this override
Which we fixed here But it's really hard to know without a complete stack trace |
If you set this flag do you still get the same exception? |
Yes, I get the same exception. This one was with the flag set. |
@easoftwaresanderson sounds good Without a full stack trace though we might only be lucky to address your use case. This type of exception is basically the same as an NRE exception. Without a full stack trace it's hard to know what specific path is causing yours |
Here my stack trace , sorry not send it before. 0x1 in System.Diagnostics.Debugger.Mono_UnhandledException at /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/mcs/class/corlib/System.Diagnostics/Debugger.cs:120,4 C# |
yes, this doesn't work. This issue is so random, and looks like there is no work around for Xamarin Forms 4.4.0.9... I am using Xamarin.Forms Material Visual for some of the controls, and below flag fixes my issue as a work around for now. |
Thank you I had done setting this flag, but unfortunately I didn't succeed. I decreased the navigation of pages to get around the issue, so I managed to make it functional and published an alpha version for test users. In the tests I get in App Center >> Diagnostics >> Issues the following related crash is occurring JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) |
I might be wrong, but this exception might be related to the back button and not to a specific view. Ive got the same exception with Android.Webview on the starting page if I exit through the back button and open the app again. Sometimes I need to do this a few times in order to reproduce. Maybe overwriting the back-button in some way leads to an workaround.
|
I might have found a workaround, althrough Im not sure if this is healthy for the garbage collector:
|
the above workaround did not work for me, setting Dispose to return still causes exception |
We are seeing this as well. Bummer about to release on Android and we are running into a 5 month old bug. |
Did you put it into a custom renderer? Is there any other code in your overrided method? If so, can I see your code? |
But I updated my project to Xamarin Forms 5.x after reading below link but this issue still persists. A work around for XF 4.7 and above is by reseting the ItemSource. |
I am also facing the same issue but on navigating back from a hybrid webview - https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/hybridwebview System.ObjectDisposedException: 'Cannot access a disposed object. |
I had a similar issue with navigation in xamarin forms shell, could solve it by updating Xamarin.Essentials, Xamarin.CommunityToolkit and Xamarin.Forms. |
This was a mistake from my side. The website was calling a function after xamarin forms disposed the webview |
I updated Xamarin.Essentials (1.61.1), Xamarin.Forms (5.0.0.2012). But the problem still hasn't gone away. |
I am facing same issue "System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer'." Im using Xamarin 4.8 and Xamarin.Essentials (1.61.1) . |
Also receiving the error.
08-03 12:41:41.216 I/MonoDroid( 6680): UNHANDLED EXCEPTION: |
I am having the same issue my Xamarin.Forms 5..0.0.2196 anyone found a walkaround |
I have handled by resetting the Collections in the catch. |
sorry could you give me an example for how resetting the collection |
Reset the binding ObservableCollection by clearing and initializing it again.
|
For whoever that might still be watching this, I have opened a PR (#14933) for this with hopefully something that should fix this. Would you be able to grab the NuGet as described here and let us know if this fixes this issue? That will greatly speed up the review process. Besides verifying if this particular issue is fixed also be sure to check other scenarios in the same area to make sure that this fix doesn't accidentally has side-effects 🙂 Thanks! |
Description
I have been sporadic crashes on Android where I get System.ObjectDisposedException: 'Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.ImageRenderer'.'
It happen when a start a faster navigation between pages (using prism navigation), when I tapped one item in listView, I open another page with other listView with items chosen before. So I'm used open and click in a button to back navigation quickly.
In 3 or 4 times doing it crash happen.
Steps to Reproduce
4 - Click on button back , or use one button to back navigation
5 - Repeat this steps quickly 3 or 4 times or until crash happen
Expected Behavior
No message crash
Actual Behavior
Crashes for customers and end users
Basic Information
Com.OneSignal" Version="3.7.2
Microsoft.AppCenter.Analytics" Version="3.0.0"
Microsoft.AppCenter.Crashes" Version="3.0.0"
Microsoft.Azure.DocumentDB.Core" Version="2.9.4"
Plugin.Permissions" Version="3.0.0.12"
Prism.Unity.Forms" Version="7.0.0.396"
Rg.Plugins.Popup" Version="1.2.0.223"
Xam.Plugin.Connectivity" Version="3.2.0"
Xam.Plugin.Media" Version="4.0.1.5"
Xam.Plugins.Forms.ImageCircle" Version="3.0.0.5"
Xam.Plugins.Messaging" Version="5.2.0"
Xamarin.Essentials" Version="1.5.0"
Xamarin.Forms" Version="4.6.0.379-pre1"
Xamarin.Forms.Maps" Version="4.5.0.356"
XamarinForms.CardView" Version="1.1.1.5"
Android 8.0 Api 26
Screenshots
Reproduction Link
Workaround
No known workarounds currently.
The text was updated successfully, but these errors were encountered: