Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] System.ObjectDisposedException: 'Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.ImageRenderer'.' #10031

Closed
easoftwaresanderson opened this issue Mar 19, 2020 · 28 comments · Fixed by #14933

Comments

@easoftwaresanderson
Copy link

easoftwaresanderson commented Mar 19, 2020

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

  1. Open on page with ListView Items , choose one Item
  2. Navigate to another page with other items and choose one
  3. Navigate to a 3º page with items chosen
    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

  • Version with issue: 4.6.0.379-pre1
  • Last known good version: 4.5 in Visual Studio 2019 16.4
  • IDE: in Visual Studio 2019 16.5
  • Platform Target Frameworks:
    • iOS: N/A
    • Android: 5.1 to 9
    • UWP: N/A
  • Android Support Library Version:
  • Nuget Packages:
    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"
  • Affected Devices:
    Android 8.0 Api 26

Screenshots

image

Reproduction Link

Workaround

No known workarounds currently.

@easoftwaresanderson easoftwaresanderson added s/unverified New report that has yet to be verified t/bug 🐛 labels Mar 19, 2020
@pauldipietro pauldipietro added this to New in Triage Mar 19, 2020
@jfversluis
Copy link
Member

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!

@jfversluis jfversluis added i/regression p/Android s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Mar 19, 2020
@jfversluis jfversluis moved this from New to Needs Info in Triage Mar 19, 2020
@easoftwaresanderson
Copy link
Author

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 .
How can I get full stack trace?
I'm using try catch around the code navigation, but I don't get any exception.

Thanks for your response.

@jfversluis
Copy link
Member

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?

@samhouts samhouts moved this from Needs Info to New in Triage Mar 20, 2020
@samhouts samhouts moved this from New to Needs Info in Triage Mar 20, 2020
@rezamohamed
Copy link

rezamohamed commented Mar 21, 2020

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.
Object name: 'Xamarin.Facebook.Login.Widget.LoginButton'

For reference:
Xamarin.Forms v4.5.0.396
Debugging to Android Emulator 9.0 API 28
Visual Studio 2019 v16.5.0

image

@PureWeen
Copy link
Contributor

it's hard to know without a stack trace but I'm guessing this is caused by this override

Which we fixed here
239ba50#diff-73413fddc3cbc5833a45ef04800f3f68L29

But it's really hard to know without a complete stack trace

@PureWeen PureWeen added 4.0.0 regression on 4.0.0 and removed s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. s/unverified New report that has yet to be verified labels Mar 28, 2020
@PureWeen
Copy link
Contributor

If you set this flag
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/internals/fast-renderers#backwards-compatibility

do you still get the same exception?

@PureWeen PureWeen moved this from Needs Info to Ready For Work in Triage Mar 28, 2020
@PureWeen PureWeen added this to the 4.7.0 milestone Mar 28, 2020
@easoftwaresanderson
Copy link
Author

If you set this flag
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/internals/fast-renderers#backwards-compatibility

do you still get the same exception?

Yes, I get the same exception. This one was with the flag set.

@PureWeen
Copy link
Contributor

@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

@easoftwaresanderson
Copy link
Author

@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#
0x1F in Xamarin.Forms.Platform.Android.Platform.GetNativeSize at D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:1332,4 C#
0x3 in Xamarin.Forms.Forms.AndroidPlatformServices.GetNativeSize at D:\a\1\s\Xamarin.Forms.Platform.Android\Forms.cs:855,5 C#
0x2D in Xamarin.Forms.VisualElement.OnSizeRequest at D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:787,4 C#
0x13 in Xamarin.Forms.Image.OnSizeRequest at D:\a\1\s\Xamarin.Forms.Core\Image.cs:74,4 C#
0x3 in Xamarin.Forms.VisualElement.OnMeasure at D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:770,4 C#
0x56 in Xamarin.Forms.VisualElement.GetSizeRequest at D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:646,4 C#
0x57 in Xamarin.Forms.VisualElement.Measure at D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:704,4 C#
0x120 in Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion at D:\a\1\s\Xamarin.Forms.Core\Layout.cs:166,5 C#
0x152 in Xamarin.Forms.Grid.LayoutChildren at D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:49,5 C#
0x160 in Xamarin.Forms.Layout.UpdateChildrenLayout at D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266,4 C#
0x10 in Xamarin.Forms.Layout.OnSizeAllocated at D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224,4 C#
0x3 in Xamarin.Forms.VisualElement.SizeAllocated at D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:792,4 C#
0x60 in Xamarin.Forms.Layout.ResolveLayoutChanges at D:\a\1\s\Xamarin.Forms.Core\Layout.cs:392,6 C#

@samhouts samhouts moved this from Ready For Work to Needs Estimate in Triage Apr 1, 2020
@kgouraw
Copy link

kgouraw commented Apr 30, 2020

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.
Forms.SetFlags("UseLegacyRenderers");
(https://docs.microsoft.com/en-us/xamarin/xamarin-forms/internals/fast-renderers#backwards-compatibility)

@easoftwaresanderson
Copy link
Author

I am using Xamarin.Forms Material Visual for some of the controls, and below flag fixes my issue as a work around for now.
Forms.SetFlags("UseLegacyRenderers");
(https://docs.microsoft.com/en-us/xamarin/xamarin-forms/internals/fast-renderers#backwards-compatibility)

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)
System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.ImageRenderer'.

JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self)
JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters)
View.get_Context ()
Platform.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint)
Forms+AndroidPlatformServices.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint)
VisualElement.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
Image.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags)
Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region)
Grid.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height)
Layout.UpdateChildrenLayout ()
Layout.OnSizeAllocated (System.Double width, System.Double height)
VisualElement.SizeAllocated (System.Double width, System.Double height)
Layout.ResolveLayoutChanges ()
Thread+RunnableImplementor.Run ()
IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this)
(wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.60(intptr,intptr)

@actopozipc
Copy link

actopozipc commented Aug 2, 2020

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.
I also tried reproducing the bug through lockscreen, but it did not succeed.

Maybe overwriting the back-button in some way leads to an workaround.
Edit: Stacktrace:


08-02 02:50:05.253 I/MonoDroid(24776): UNHANDLED EXCEPTION:
08-02 02:50:05.258 I/MonoDroid(24776): System.ObjectDisposedException: Cannot access a disposed object.
08-02 02:50:05.258 I/MonoDroid(24776): Object name: 'Android.Webkit.WebView'.
08-02 02:50:05.258 I/MonoDroid(24776):   at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <26521a5118b44c858c385715922b9d5d>:0 
08-02 02:50:05.258 I/MonoDroid(24776):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <26521a5118b44c858c385715922b9d5d>:0 
08-02 02:50:05.258 I/MonoDroid(24776):   at Android.Webkit.WebView.EvaluateJavascript (System.String script, Android.Webkit.IValueCallback resultCallback) [0x00050] in <4ccdb3137d974856b786e1aeebbfbab6>:0 
08-02 02:50:05.258 I/MonoDroid(24776):   at BingMap.Droid.BingMap.RemovePin () [0x00024] in C:\Users\user\Documents\GitHub\mapbarrierefrei\BingMaps\BingMaps.Android\BingMap.Droid\BingMap.cs:140 
08-02 02:50:05.258 I/MonoDroid(24776):   at BingMap.Droid.BingMap.Remove_Pin (System.Object sender, System.Object e) [0x00023] in C:\Users\user\Documents\GitHub\mapbarrierefrei\BingMaps\BingMaps.Android\BingMap.Droid\BingMap.cs:126 
08-02 02:50:05.258 I/MonoDroid(24776):   at BingMap.BingMapView.RemoveAllPins () [0x00001] in C:\Users\user\Documents\GitHub\mapbarrierefrei\BingMaps\BingMaps\BingMap\BingMapView.cs:57 
08-02 02:50:05.258 I/MonoDroid(24776):   at BingMap.BingMapView.Pins_CollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00001] in C:\Users\user\Documents\GitHub\mapbarrierefrei\BingMaps\BingMaps\BingMap\BingMapView.cs:34 
08-02 02:50:05.258 I/MonoDroid(24776):   at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:263 
08-02 02:50:05.258 I/MonoDroid(24776):   at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object oldItem, System.Object newItem, System.Int32 index) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:354 
08-02 02:50:05.259 I/MonoDroid(24776):   at System.Collections.ObjectModel.ObservableCollection`1[T].SetItem (System.Int32 index, T item) [0x0001c] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:210 
08-02 02:50:05.259 I/MonoDroid(24776):   at System.Collections.ObjectModel.Collection`1[T].set_Item (System.Int32 index, T value) [0x00027] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/ObjectModel/Collection.cs:59 
08-02 02:50:05.259 I/MonoDroid(24776):   at BingMaps.MainPage+<>c__DisplayClass6_0.<RefreshLocationAsync>b__1 () [0x0009b] in C:\Users\user\Documents\GitHub\mapbarrierefrei\BingMaps\BingMaps\MainPage.xaml.cs:119 
08-02 02:50:05.259 I/MonoDroid(24776):   at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 
08-02 02:50:05.259 I/MonoDroid(24776):   at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <4ccdb3137d974856b786e1aeebbfbab6>:0 
08-02 02:50:05.259 I/MonoDroid(24776):   at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <4ccdb3137d974856b786e1aeebbfbab6>:0 
08-02 02:50:05.259 I/MonoDroid(24776):   at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <4ccdb3137d974856b786e1aeebbfbab6>:0 
08-02 02:50:05.259 I/MonoDroid(24776):   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.40(intptr,intptr)
08-02 02:50:05.271 W/nyname.BingMap(24776): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
08-02 02:50:05.274 D/Mono    (24776): DllImport searching in: '__Internal' ('(null)').
08-02 02:50:05.274 D/Mono    (24776): Searching for 'java_interop_jnienv_throw'.
08-02 02:50:05.274 D/Mono    (24776): Probing 'java_interop_jnienv_throw'.
08-02 02:50:05.274 D/Mono    (24776): Found as 'java_interop_jnienv_throw'.
**System.ObjectDisposedException:** 'Cannot access a disposed object.
Object name: 'Android.Webkit.WebView'.'

@actopozipc
Copy link

I might have found a workaround, althrough Im not sure if this is healthy for the garbage collector:

  1. Create a custom renderer for the View that throws the exception
 protected override void Dispose(bool disposing)
        {
            return;
        }

@crs2m5smith
Copy link

the above workaround did not work for me, setting Dispose to return still causes exception

@samhouts samhouts modified the milestones: 4.7.0, 5.0.0 Aug 13, 2020
@samhouts samhouts removed this from To do in 4.7.0 Aug 13, 2020
@samhouts samhouts added this to To do in vNext+1 (5.0.0) Aug 13, 2020
@multitracks
Copy link

We are seeing this as well. Bummer about to release on Android and we are running into a 5 month old bug.

@actopozipc
Copy link

the above workaround did not work for me, setting Dispose to return still causes exception

Did you put it into a custom renderer? Is there any other code in your overrided method? If so, can I see your code?
Anyway, I hate this solution, because not disposing leads to a massive usage of RAM

@kgouraw
Copy link

kgouraw commented Sep 24, 2020

But I updated my project to Xamarin Forms 5.x after reading below link but this issue still persists.
#10801

A work around for XF 4.7 and above is by reseting the ItemSource.

@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
@AswinPG
Copy link

AswinPG commented Mar 5, 2021

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.
Object name: 'Android.Webkit.WebView'.'

@n8water
Copy link

n8water commented Apr 2, 2021

I had a similar issue with navigation in xamarin forms shell, could solve it by updating Xamarin.Essentials, Xamarin.CommunityToolkit and Xamarin.Forms.

@AswinPG
Copy link

AswinPG commented Apr 2, 2021

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.
Object name: 'Android.Webkit.WebView'.'

This was a mistake from my side. The website was calling a function after xamarin forms disposed the webview

@avksp
Copy link

avksp commented Apr 23, 2021

I had a similar issue with navigation in xamarin forms shell, could solve it by updating Xamarin.Essentials, Xamarin.CommunityToolkit and Xamarin.Forms.

I updated Xamarin.Essentials (1.61.1), Xamarin.Forms (5.0.0.2012). But the problem still hasn't gone away.

@kiran-nel
Copy link

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) .
any solution.?

@Tim-Rossiter
Copy link

Tim-Rossiter commented Jul 30, 2021

Also receiving the error.
Xamarin Forms, Prism, Custom Renderer for Android following Microsoft docs w/back navigation
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/hybridwebview
https://docs.microsoft.com/en-us/answers/questions/403328/hybridwebview-cangoback-amp-goback-using-mvvm.html

Cannot access a disposed object.
Object name: 'Android.Webkit.WebView'.

08-03 12:41:41.216 I/MonoDroid( 6680): UNHANDLED EXCEPTION:
08-03 12:41:41.219 I/MonoDroid( 6680): Crashlytics.MonoExceptionHelper: Exception of type 'Crashlytics.MonoExceptionHelper' was thrown.
08-03 12:41:41.219 I/MonoDroid( 6680): --- End of managed Crashlytics.MonoExceptionHelper stack trace ---
08-03 12:41:41.219 I/MonoDroid( 6680): crc64fe7e538dcffb0c36.MonoExceptionHelper: (ObjectDisposedException) Cannot access a disposed object.
08-03 12:41:41.219 I/MonoDroid( 6680): Object name: 'Android.Webkit.WebView'.
08-03 12:41:41.219 I/MonoDroid( 6680): at Java.Interop.JniPeerMembers.AssertSelf(Java.Interop.IJavaPeerable self)0x00029
08-03 12:41:41.219 I/MonoDroid( 6680): at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualObjectMethod(System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters)0x00000
08-03 12:41:41.219 I/MonoDroid( 6680): at Android.Webkit.WebView.get_Url()0x00000
08-03 12:41:41.219 I/MonoDroid( 6680): at Xamarin.Forms.Platform.Android.FormsWebViewClient.OnReceivedError(Android.Webkit.WebView view, Android.Webkit.IWebResourceRequest request, Android.Webkit.WebResourceError error)0x00000
08-03 12:41:41.219 I/MonoDroid( 6680): at Kickback2020.Droid.CustomRenderers.CustomWebViewClient.OnReceivedError(Android.Webkit.WebView view, Android.Webkit.IWebResourceRequest request, Android.Webkit.WebResourceError error)[0x00001](C:\Users\Tim Rossiter\Source\Repos\kickback2020\src\Kickback2020.Android\CustomRenderers\CustomWebViewRenderer.cs:153)
08-03 12:41:41.219 I/MonoDroid( 6680): at Android.Webkit.WebViewClient.n_OnReceivedError_Landroid_webkit_WebView_Landroid_webkit_WebResourceRequest_Landroid_webkit_WebResourceError_(System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_view, System.IntPtr native_request, System.IntPtr native_error)0x00021
08-03 12:41:41.219 I/MonoDroid( 6680): at at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.157(intptr,intptr,intptr,intptr,intptr).(unknown.cs:1)
08-03 12:41:41.219 I/MonoDroid( 6680):
08-03 12:41:41.223 E/AndroidRuntime( 6680): FATAL EXCEPTION: main
08-03 12:41:41.223 E/AndroidRuntime( 6680): Process: com.krs.jacksons, PID: 6680
08-03 12:41:41.223 E/AndroidRuntime( 6680): crc64fe7e538dcffb0c36.MonoExceptionHelper: (ObjectDisposedException) Cannot access a disposed object.
08-03 12:41:41.223 E/AndroidRuntime( 6680): Object name: 'Android.Webkit.WebView'.
08-03 12:41:41.223 E/AndroidRuntime( 6680): at Java.Interop.JniPeerMembers.AssertSelf(Java.Interop.IJavaPeerable self)0x00029
08-03 12:41:41.223 E/AndroidRuntime( 6680): at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualObjectMethod(System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters)0x00000
08-03 12:41:41.223 E/AndroidRuntime( 6680): at Android.Webkit.WebView.get_Url()0x00000
08-03 12:41:41.223 E/AndroidRuntime( 6680): at Xamarin.Forms.Platform.Android.FormsWebViewClient.OnReceivedError(Android.Webkit.WebView view, Android.Webkit.IWebResourceRequest request, Android.Webkit.WebResourceError error)0x00000
08-03 12:41:41.223 E/AndroidRuntime( 6680): at Kickback2020.Droid.CustomRenderers.CustomWebViewClient.OnReceivedError(Android.Webkit.WebView view, Android.Webkit.IWebResourceRequest request, Android.Webkit.WebResourceError error)[0x00001](C:\Users\Tim Rossiter\Source\Repos\kickback2020\src\Kickback2020.Android\CustomRenderers\CustomWebViewRenderer.cs:153)
08-03 12:41:41.223 E/AndroidRuntime( 6680): at Android.Webkit.WebViewClient.n_OnReceivedError_Landroid_webkit_WebView_Landroid_webkit_WebResourceRequest_Landroid_webkit_WebResourceError_(System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_view, System.IntPtr native_request, System.IntPtr native_error)0x00021
08-03 12:41:41.223 E/AndroidRuntime( 6680): at at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.157(intptr,intptr,intptr,intptr,intptr).(unknown.cs:1)
08-03 12:41:41.242 I/Process ( 6680): Sending signal. PID: 6680 SIG: 9

@minaairsupport
Copy link

I am having the same issue
Forms.SetFlags("UseLegacyRenderers");
tried pass source by viewmodel
dosent work for me as well

my Xamarin.Forms 5..0.0.2196

anyone found a walkaround

@kgouraw
Copy link

kgouraw commented Nov 12, 2021

I am having the same issue Forms.SetFlags("UseLegacyRenderers"); tried pass source by viewmodel dosent work for me as well

my Xamarin.Forms 5..0.0.2196

anyone found a walkaround

I have handled by resetting the Collections in the catch.

@minaairsupport
Copy link

sorry could you give me an example for how resetting the collection

@kgouraw
Copy link

kgouraw commented Nov 12, 2021

sorry could you give me an example for how resetting the collection

Reset the binding ObservableCollection by clearing and initializing it again.

public void Reset(IEnumerable<T> range) { this.Items.Clear(); if (range != null) { AddRange(range); } }

@jfversluis
Copy link
Member

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!

Triage automation moved this from Needs Estimate to Closed Dec 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Triage
  
Closed
Development

Successfully merging a pull request may close this issue.