xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

System.ObjectDisposedException: Cannot access a disposed object 'Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer' #10801

Closed vsfeedback closed 4 years ago

vsfeedback commented 4 years ago

This issue has been moved from a ticket on Developer Community.


After upgrading to the Xamarin Forms 4.6.0726, starting getting frequent intermittent crash on Android. Upon investigation, found that this is coming from Xamarin's LabelRenderer

05-17 07:27:06.656 E/mono ( 5133): 05-17 07:27:06.656 E/mono ( 5133): Unhandled Exception: 05-17 07:27:06.656 E/mono ( 5133): System.ObjectDisposedException: Cannot access a disposed object. 05-17 07:27:06.656 E/mono ( 5133): Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer'. 05-17 07:27:06.656 E/mono ( 5133): at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.29(intptr,intptr) 05-17 07:27:06.656 E/mono ( 5133): at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.29(intptr,intptr) 05-17 07:27:06.656 E/mono-rt ( 5133): [ERROR] FATAL UNHANDLED EXCEPTION: System.ObjectDisposedException: Cannot access a disposed object. 05-17 07:27:06.656 E/mono-rt ( 5133): Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer'. 05-17 07:27:06.656 E/mono-rt ( 5133): at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.29(intptr,intptr) 05-17 07:27:06.656 E/mono-rt ( 5133): at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.29(intptr,intptr) 05-17 07:27:06.698 D/ ( 5133): HostConnection::get() New Host Connection established 0xbd1b1240, tid 5133

Not sure where it is coming from. I have ListView as main view and wondering something is wrong with newer version of ListView causing leak and crash.

I don't have a custom label renderer so it has to be coming from Xamarin's platform renderer Please suggest.


Original Comments

Visual Studio Feedback System on 5/17/2020, 11:54 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.


Original Solutions

(no solutions)

Reveon commented 4 years ago

@Edgaras91 take a look on this

BartoszKopec commented 4 years ago

@Edgaras91, Click on the link. On the right of "nuget" panel there will be "more" button (3 vertical dots), from context menu select "download [...]". Then set (as @Reveon mentioned) local source of local nugets in your system files (e.g. "C:\repos\localNugets") and place zip's content of downloaded zip to this folder (there will be a few Xamarin .nupkg files). Then in your VS open NuGet manager and from this combobox obraz select your local source (mine is called just "local") Finally just install/update Xamarin.Forms to selected project as usual.

Edgaras91 commented 4 years ago

Thank you @Reveon and @BartoszKopec . However, I also have Dev Ops continuous integrations, this will be fun.. Hope this is approved fix and will be rolled out ASAP!

BartoszKopec commented 4 years ago

@Edgaras91 I'm using App Center as CI and have same problem - can't use it! 😄

InquisitorJax commented 4 years ago

Can also confirm this looks to be solved. @PureWeen do we know what the eta would more or less be for which release this is scheduled?

ZeProgFactory commented 4 years ago

Hi, For the people who have this issue: in my case I had several Labels that changed visibility via IsVisible. I changed it for BackGroundColor and TextColor is Color.Transparent or not, and the issue disappeared … Hope this helps ...

ThumbGen commented 4 years ago

Will this fix be included in the next 4.8? Or just 5.0?

PureWeen commented 4 years ago

Next SR of 4.8

redradist commented 4 years ago

The same exception on 4.8.0.1451:

{InnerException: null  StackTrace:   at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <324349c9a2dd47568c91620d2bd3db5a>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <324349c9a2dd47568c91620d2bd3db5a>:0 
  at Android.Views.View.get_Context () [0x0000a] in <f69f42e19d884caca4279f1717610a26>:0 
  at Xamarin.Forms.Platform.Android.Platform.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) [0x00019] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:1341 
  at Xamarin.Forms.Forms+AndroidPlatformServices.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\Forms.cs:921 
  at Xamarin.Forms.VisualElement.OnSizeRequest (Syst

    at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <324349c9a2dd47568c91620d2bd3db5a>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <324349c9a2dd47568c91620d2bd3db5a>:0 
  at Android.Views.View.get_Context () [0x0000a] in <f69f42e19d884caca4279f1717610a26>:0 
  at Xamarin.Forms.Platform.Android.Platform.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) [0x00019] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:1341 
  at Xamarin.Forms.Forms+AndroidPlatformServices.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\Forms.cs:921 
  at Xamarin.Forms.VisualElement.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00025] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:811 
  at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:796 
  at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:686 
  at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:738 
  at Xamarin.Forms.StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) [0x00236] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:198 
  at Xamarin.Forms.StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) [0x00058] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:123 
  at Xamarin.Forms.StackLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00019] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:80 
  at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:796 
  at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:686 
  at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:113 
  at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:738 
  at Xamarin.Forms.StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) [0x000a8] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:163 
  at Xamarin.Forms.StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) [0x00058] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:123 
  at Xamarin.Forms.StackLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00019] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:80 
  at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:796 
  at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:686 
  at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:113 
  at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:738 
  at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x0007b] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:133 
  at Xamarin.Forms.TemplatedView.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00019] in D:\a\1\s\Xamarin.Forms.Core\TemplatedView.cs:29 
  at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:239 
  at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:203 
  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:814 
  at Xamarin.Forms.Layout.ResolveLayoutChanges () [0x0005c] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:362 
  at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <f69f42e19d884caca4279f1717610a26>:0 
  at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <f69f42e19d884caca4279f1717610a26>:0 
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.36(intptr,intptr)

  Cannot access a disposed object.
Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer'.

Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer

Java.Interop

System.ObjectDisposedException
joshuangfraedom commented 4 years ago

It's not in that release, you will need to wait for Xamarin forms 4.8 Service Release 3

redradist commented 4 years ago

It's not in that release, you will need to wait for Xamarin forms 4.8 Service Release 3

@joshuangfraedom You mean that this issue is fixed in Xamarin forms 4.8 Service Release 3 ?

When it is planned to be published ? How long to wait ... :-)))

joshuangfraedom commented 4 years ago

I'm not sure sorry, it looks like the fix for this is currently in XF 5.0 Prerelease 1 if you wanted to give that a go. @samhouts are we able to get an update on another service release for 4.8?

TsplayerT commented 4 years ago

I tested a project with the same error, Xamarin 5.0.0.1539-pre2 and it still persists

System.ObjectDisposedException: Cannot access a dropped object

Using this line Forms.SetFlags ("UseLegacyRenderers") in the project the exception have the ObjectName: Xamarin.Forms.Platform.Android.AppCompat.FrameRenderer

Without flag line the ObjectName: Xamarin.Forms.Platform.Android.FastRenderers.FrameRenderer

hartez commented 4 years ago

@TsplayerT Can you post the full stack trace?

TsplayerT commented 4 years ago

Here it is:

Main thread Details
Java.Interop JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self)
Java.Interop JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters)
Android.Views View.set_Enabled (System.Boolean value)
Xamarin.Forms.Platform.Android.FastRenderers VisualElementRenderer.UpdateIsEnabled ()
Xamarin.Forms.Platform.Android.FastRenderers VisualElementRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) (wrapper delegate-invoke .invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
Xamarin.Forms BindableObject.OnPropertyChanged (System.String propertyName)
Xamarin.Forms Element.OnPropertyChanged (System.String propertyName)
Xamarin.Forms BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent)
Xamarin.Forms BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes)
Xamarin.Forms BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget)
Xamarin.Forms BindingExpression.Apply (System.Boolean fromTarget)
Xamarin.Forms BindingExpression+BindingExpressionPart.b__49_0 ()
Java.Lang Thread+RunnableImplementor.Run ()
Java.Lang IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.24(intptr,intptr)

The details of the error and other information are attached. report.txt

mduchev commented 4 years ago

This should be reopened. I can also reproduce it on 5.0.0.1558-pre3. Keep in mind that I've got the following case - I have a couple of elements (Label incl.) inside a Frame. I've wrapped the Frame in my own class - TestFrame. There, I've overridden the OnElementPropertyChanged. The exception happens when I get a property changed event for "Y" property. Keep in mind that, occasionally, I'm getting the exception in the LabelRenderer itself, rather than the Frame. I suppose that the issue still persists, just in this case it appears when we have a Frame. Here's a stack trace:

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Test.Droid.Renderers.TestFrameRenderer'.
  at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <42748fcc36b74733af2d9940a8f3cc8e>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <42748fcc36b74733af2d9940a8f3cc8e>:0 
  at Android.Views.View.get_Context () [0x0000a] in <7d2292394f8c488b97f5bc2a0ac0240d>:0 
  at Test.Droid.Renderers.TestFrameRenderer.UpdateFrame (Test.Views.Controls.TestFrame frameElement) [0x00001] in ...Test.Android\Renderers\TestFrameRenderer.cs:50 
  at Test.Droid.Renderers.TestFrameRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x0001f] in ...\Test.Android\Renderers\TestFrameRenderer.cs:44 
  at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
  at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:229 
  at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:362 
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:464 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:400 
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x00042] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:335 
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindablePropertyKey propertyKey, System.Object value) [0x0000e] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:319 
  at Xamarin.Forms.VisualElement.set_Y (System.Double value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:556 
  at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x00050] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:408 
  at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:779 
  at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x001da] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:157 
  at Xamarin.Forms.Grid.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00144] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:49 
  at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:239 
  at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:203 
  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:869 
  at Xamarin.Forms.Layout.ResolveLayoutChanges () [0x00069] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:374 
  at Xamarin.Forms.Platform.Android.Platform+DefaultRenderer.OnMeasure (System.Int32 widthMeasureSpec, System.Int32 heightMeasureSpec) [0x0000f] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:1319 
  at Android.Views.View.n_OnMeasure_II (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 widthMeasureSpec, System.Int32 heightMeasureSpec) [0x00008] in <7d2292394f8c488b97f5bc2a0ac0240d>:0 
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.36(intptr,intptr,int,int)
PureWeen commented 4 years ago

@mduchev I realize the exception name is the same but this type of exception is like a NullReferenceException. Each one is a different cause. The one you are having won't be related to this one.

If you can create a new issue with a repro that would be helpful

PureWeen commented 4 years ago

@mduchev Are you seeing your exception in 4.8?

PureWeen commented 4 years ago

@mduchev I noticed your exception is coming from a custom renderer

If you just use our renderer do you see the same exception?

You might need to check if your FrameRenderer has been disposed and not call into this code

at Test.Droid.Renderers.TestFrameRenderer.UpdateFrame (Test.Views.Controls.TestFrame frameElement) [0x00001] in ...Test.Android\Renderers\TestFrameRenderer.cs:50 
  at Test.Droid.Renderers.TestFrameRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x0001f] in ...\Test.Android\Renderers\TestFrameRenderer.cs:44 
mduchev commented 4 years ago

@PureWeen It may be another issue, can't say for sure. I'm seeing ObjectDisposedException and, like I said, occasionally, the exception is ObjectDisposedException for the FastRenderers.LabelRenderer (for the same flow!). Unfortunately, I cannot upload a repro. I'll try to create one and test it with the Frame wrapping the Label. I just tried with 4.8.0.1560 and the exception is there. I've also tested & confirmed it with 4.7.0.1351 & 5.0.0.1558-pre3.

TsplayerT commented 4 years ago

@mduchev or does anyone know why version 5 of Xamarin will be released saying that this problem has been fixed but is still occurring? I could not understand.

Even using this line Forms.SetFlags (" UseLegacyRenderers ") in the project, an exception occurs with ObjectName: Xamarin.Forms.Platform.Android.AppCompat.FrameRenderer

Without line to flag, the exception has this ObjectName: Xamarin.Forms.Platform.Android.FastRenderers.FrameRenderer

mduchev commented 4 years ago

@TsplayerT I think that the issue that we are both seeing (the FrameRenderer exception) is a separate issue. The main issue - the one with the LabelRenderer may be indeed fixed, but a similar bug is happening with the FrameRenderer. I also noticed the new exception only when I'm using something inside a Frame. Unfortunately, I cannot pinpoint the exact layout and steps which crash the app. If you can, please provide a sample project and open a new issue for the frame exception.

mduchev commented 4 years ago

@ZeProgFactory Thank you for the perfect workaround for people like me, who can't update to the latest Xamarin version, due to a lot of issues, which are still pending to be added to a specific sprint even...

AshishMantosh commented 3 years ago

ZeProgFactory

What was the workaround?

bikrambhandari48 commented 2 years ago

Same issue with Xamarin.Forms version 5.0.0.2401. This should a top priority in deveopment.

Below is the stack trace of the error.

System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.Platform+DefaultRenderer'. at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <2e109281f9514c53b44688fd4549adb2>:0 at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <2e109281f9514c53b44688fd4549adb2>:0 at Android.Views.View.get_Parent () [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-30/mcw/Android.Views.View.cs:10002 at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].UpdateParentPageTraversalOrder () [0x00000] in D:\a_work\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:424 at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00138] in D:\a_work\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:386 at (wrapper delegate-invoke) .invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs) at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a_work\1\s\Xamarin.Forms.Core\BindableObject.cs:266 at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a_work\1\s\Xamarin.Forms.Core\Element.cs:362 at Xamarin.Forms.Element.set_Parent (Xamarin.Forms.Element value) [0x000e9] in D:\a_work\1\s\Xamarin.Forms.Core\Element.cs:206 at Xamarin.Forms.Element.OnChildRemoved (Xamarin.Forms.Element child, System.Int32 oldLogicalIndex) [0x00000] in D:\a_work\1\s\Xamarin.Forms.Core\Element.cs:342 at Xamarin.Forms.VisualElement.OnChildRemoved (Xamarin.Forms.Element child, System.Int32 oldLogicalIndex) [0x00000] in D:\a_work\1\s\Xamarin.Forms.Core\VisualElement.cs:847 at Xamarin.Forms.Layout1[T].OnChildRemoved (Xamarin.Forms.Element child, System.Int32 oldLogicalIndex) [0x00000] in D:\a_work\1\s\Xamarin.Forms.Core\Layout.cs:33 at Xamarin.Forms.Layout.OnInternalRemoved (Xamarin.Forms.View view, System.Int32 oldIndex) [0x00012] in D:\a_work\1\s\Xamarin.Forms.Core\Layout.cs:455 at Xamarin.Forms.Layout.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0002b] in D:\a_work\1\s\Xamarin.Forms.Core\Layout.cs:418 at (wrapper delegate-invoke) .invoke_void_object_NotifyCollectionChangedEventArgs(object,System.Collections.Specialized.NotifyCollectionChangedEventArgs) at System.Collections.ObjectModel.ObservableCollection1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:263 at System.Collections.ObjectModel.ObservableCollection1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:338 at System.Collections.ObjectModel.ObservableCollection1[T].RemoveItem (System.Int32 index) [0x00021] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:182 at System.Collections.ObjectModel.Collection1[T].Remove (T item) [0x00027] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/ObjectModel/Collection.cs:128 at Xamarin.Forms.ObservableWrapper2[TTrack,TRestrict].Clear () [0x00030] in D:\a_work\1\s\Xamarin.Forms.Core\ObservableWrapper.cs:45 at Xamarin.Forms.BindableLayoutController.CreateChildren () [0x00010] in D:\a_work\1\s\Xamarin.Forms.Core\BindableLayout.cs:225 at Xamarin.Forms.BindableLayoutController.SetItemsSource (System.Collections.IEnumerable itemsSource) [0x00051] in D:\a_work\1\s\Xamarin.Forms.Core\BindableLayout.cs:165 at Xamarin.Forms.BindableLayoutController.set_ItemsSource (System.Collections.IEnumerable value) [0x00000] in D:\a_work\1\s\Xamarin.Forms.Core\BindableLayout.cs:126 at Xamarin.Forms.BindableLayout+<>c.<.cctor>b19_0 (Xamarin.Forms.BindableObject b, System.Object o, System.Object n) [0x00000] in D:\a_work\1\s\Xamarin.Forms.Core\BindableLayout.cs:12 at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a_work\1\s\Xamarin.Forms.Core\BindableObject.cs:512 at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a_work\1\s\Xamarin.Forms.Core\BindableObject.cs:446 at Xamarin.Forms.Internals.TypedBinding2[TSource,TProperty].ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x0011f] in D:\a_work\1\s\Xamarin.Forms.Core\TypedBinding.cs:233 at Xamarin.Forms.Internals.TypedBinding2[TSource,TProperty].Apply (System.Boolean fromTarget) [0x00029] in D:\a_work\1\s\Xamarin.Forms.Core\TypedBinding.cs:115 at Xamarin.Forms.Internals.TypedBinding2+PropertyChangedProxy[TSource,TProperty].b16_0 () [0x00000] in D:\a_work\1\s\Xamarin.Forms.Core\TypedBinding.cs:297 at Xamarin.Forms.DispatcherExtensions.Dispatch (Xamarin.Forms.IDispatcher dispatcher, System.Action action) [0x00013] in D:\a_work\1\s\Xamarin.Forms.Core\DispatcherExtensions.cs:42 at Xamarin.Forms.Internals.TypedBinding2+PropertyChangedProxy[TSource,TProperty].OnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00033] in D:\a_work\1\s\Xamarin.Forms.Core\TypedBinding.cs:297 at Xamarin.Forms.BindingExpression+WeakPropertyChangedProxy.OnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00012] in D:\a_work\1\s\Xamarin.Forms.Core\BindingExpression.cs:667 at (wrapper delegate-invoke) .invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs) at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a_work\1\s\Xamarin.Forms.Core\BindableObject.cs:266 at StorefrontRetail.ViewModels.Base.ExtendedBindableObject.SetProperty[T] (T& backingStore, T value, System.String propertyName, System.Action onChanged) [0x0002f] in D:\Vault\CrossPlatform\NEXUS\V14_5\MobileApp\StorefrontRetail\StorefrontRetail\StorefrontRetail\ViewModels\Base\ExtendedBindableObject.cs:22 at StorefrontRetail.ViewModels.Setting.SettingViewModel.set_Settings (System.Collections.Generic.List`1[T] value) [0x00000] in D:\Vault\CrossPlatform\NEXUS\V14_5\MobileApp\StorefrontRetail\StorefrontRetail\StorefrontRetail\ViewModels\Setting\SettingViewModel.cs:26 at StorefrontRetail.ViewModels.Setting.SettingViewModel.InitialiseDataAsync (System.Object navigationData) [0x00002] in D:\Vault\CrossPlatform\NEXUS\V14_5\MobileApp\StorefrontRetail\StorefrontRetail\StorefrontRetail\ViewModels\Setting\SettingViewModel.cs:94

boris-df commented 2 years ago

@PureWeen the Nuget is not available anymore (link showing an empty page) - i think i cannot use some nuget for our project so easily anyway - but i'm very curious what that workaround was? Do you have the code to share? Was it some custom-renderers? Thanks in advance