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

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

Closed
vsfeedback opened this issue May 20, 2020 · 76 comments
Labels
4.4.0 regression on 4.4.0 a/collectionview a/fastrenderers a/label a/listview Problems with the ListView/TableView e/5 🕔 5 feedback-ticket Issue originates from https://developercommunity.visualstudio.com i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often i/regression in-progress This issue has an associated pull request that may resolve it! m/high impact ⬛ p/Android s/unverified New report that has yet to be verified t/bug 🐛

Comments

@vsfeedback
Copy link

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)

@pauldipietro pauldipietro added this to New in Triage May 20, 2020
@jsuarezruiz jsuarezruiz added a/label p/Android s/unverified New report that has yet to be verified t/bug 🐛 labels May 21, 2020
@devthepenguin
Copy link

Related #8262

Workaround-#8262 (comment)

Building a custom renderer for a ListView or its cells is one approach to reducing the effect of layout calculations on scrolling performance.
ListView best practices-https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/listview/performance

@devthepenguin
Copy link

Try to implement INotifyPropertyChanged (System.ComponentModel) for the class which contains the ListView.
Set the handler for public event PropertyChangedEventHandler PropertyChanged as follows for the set accessor of the property modified-

var args = new PropertyChangedEventArgs(nameOf(typeOf(string)));
PropertyChanged?.Invoke(this, args);

@Sylv1F
Copy link

Sylv1F commented May 22, 2020

Related #10159

@samhouts samhouts added i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often feedback-ticket Issue originates from https://developercommunity.visualstudio.com a/listview Problems with the ListView/TableView labels May 26, 2020
@samhouts
Copy link
Member

Can you please attach a small project that demonstrates this issue? Thanks!

@samhouts samhouts added 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 May 29, 2020
@samhouts samhouts moved this from New to Needs Info in Triage May 29, 2020
@pedroyan
Copy link

pedroyan commented Jun 1, 2020

I'm also facing the same issue crashing my app

Stack Trace:

Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer'.
Java.Interop.JniPeerMembers.AssertSelf(Java.Interop.IJavaPeerable self) in <26521a5118b44c858c385715922b9d5d>
Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod(System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) in <26521a5118b44c858c385715922b9d5d>
Android.Views.View.get_Context() in <4ccdb3137d974856b786e1aeebbfbab6>
Xamarin.Forms.Platform.Android.Platform.GetNativeSize(Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:1341
Xamarin.Forms.Forms+AndroidPlatformServices.GetNativeSize(Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) in D:\a\1\s\Xamarin.Forms.Platform.Android\Forms.cs:930
Xamarin.Forms.VisualElement.OnSizeRequest(System.Double widthConstraint, System.Double heightConstraint) in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:800
Xamarin.Forms.VisualElement.OnMeasure(System.Double widthConstraint, System.Double heightConstraint) in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:783
Xamarin.Forms.VisualElement.GetSizeRequest(System.Double widthConstraint, System.Double heightConstraint) in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:659
Xamarin.Forms.VisualElement.Measure(System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:717
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) in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:163
Xamarin.Forms.StackLayout.CalculateLayout(Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:123
Xamarin.Forms.StackLayout.OnSizeRequest(System.Double widthConstraint, System.Double heightConstraint) in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:80
Xamarin.Forms.VisualElement.OnMeasure(System.Double widthConstraint, System.Double heightConstraint) in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:783
Xamarin.Forms.VisualElement.GetSizeRequest(System.Double widthConstraint, System.Double heightConstraint) in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:659
Xamarin.Forms.Layout.GetSizeRequest(System.Double widthConstraint, System.Double heightConstraint) in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:132
Xamarin.Forms.VisualElement.Measure(System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:717
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) in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:198
Xamarin.Forms.StackLayout.CalculateLayout(Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:123
Xamarin.Forms.StackLayout.LayoutChildren(System.Double x, System.Double y, System.Double width, System.Double height) in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:58
Xamarin.Forms.Layout.UpdateChildrenLayout() in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266
Xamarin.Forms.Layout.OnSizeAllocated(System.Double width, System.Double height) in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224
Xamarin.Forms.VisualElement.SizeAllocated(System.Double width, System.Double height) in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:805
Xamarin.Forms.Layout.ResolveLayoutChanges() in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:392
Java.Lang.Thread+RunnableImplementor.Run() in <4ccdb3137d974856b786e1aeebbfbab6>
Java.Lang.IRunnableInvoker.n_Run(System.IntPtr jnienv, System.IntPtr native__this) in <4ccdb3137d974856b786e1aeebbfbab6>
(wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.48(intptr,intptr)

@pedroyan
Copy link

pedroyan commented Jun 1, 2020

Downgrading XF to version 4.4.0.991864 solved the issue on our production app. Credits: #10159 (comment)

@Sylv1F
Copy link

Sylv1F commented Jun 2, 2020

Can you please attach a small project that demonstrates this issue? Thanks!

@samhouts I can't publish the source code, it's a commercial application ... and it can only work with data.

@pedroyan
Copy link

pedroyan commented Jun 2, 2020

Can you please attach a small project that demonstrates this issue? Thanks!

@samhouts unfortunately I can't publish the code due to contractual reasons

@kukakes
Copy link

kukakes commented Jun 2, 2020

Hello, just checking if there are any timelines on by when the fix would be available. We have a major release going out and is now on hold just because of this issue after we upgraded our Xamarin framework. At this point we can't go back to the old framework as well.

Please help.

@samhouts
Copy link
Member

samhouts commented Jun 2, 2020

These issues are very difficult to resolve without a reproduction. You may be able to work around it by enabling the legacy renderers. If you're able to post a reproduction project, we may be able to resolve the issue fully. Thank you!

@Sylv1F
Copy link

Sylv1F commented Jun 3, 2020

These issues are very difficult to resolve without a reproduction. You may be able to work around it by enabling the legacy renderers. If you're able to post a reproduction project, we may be able to resolve the issue fully. Thank you!

I understand, I am trying to reproduce on a test project.

@kukakes
Copy link

kukakes commented Jun 7, 2020

These issues are very difficult to resolve without a reproduction. You may be able to work around it by enabling the legacy renderers. If you're able to post a reproduction project, we may be able to resolve the issue fully. Thank you!

@samhouts, I tried enabling the legacy renderers as per the provided instructions however surprisingly the error still persists!

I tried cleaning the solution, closing/opening VS but the error still persists.

Please suggest. Any help in this regard would be immensely helpful!

@hartez hartez moved this from Needs Info to New in Triage Jun 9, 2020
@hartez hartez removed the s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. label Jun 9, 2020
@samhouts samhouts moved this from New to Needs Info in Triage Jun 9, 2020
@ThumbGen
Copy link

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

@PureWeen
Copy link
Contributor

Next SR of 4.8

@redradist
Copy link

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
Copy link

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

@redradist
Copy link

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
Copy link

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?

thisisthekap pushed a commit to thisisthekap/Xamarin.Forms that referenced this issue Oct 1, 2020
@samhouts samhouts moved this from In Progress to Done in vNext+1 (5.0.0) Oct 1, 2020
@samhouts samhouts removed this from Done in vNext+1 (5.0.0) Oct 1, 2020
thisisthekap pushed a commit to thisisthekap/Xamarin.Forms that referenced this issue Oct 7, 2020
@TsplayerT
Copy link

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
Copy link
Contributor

hartez commented Oct 14, 2020

@TsplayerT Can you post the full stack trace?

@TsplayerT
Copy link

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
Copy link

mduchev commented Oct 21, 2020

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
Copy link
Contributor

@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
Copy link
Contributor

@mduchev Are you seeing your exception in 4.8?

@PureWeen
Copy link
Contributor

@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
Copy link

mduchev commented Oct 21, 2020

@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
Copy link

@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
Copy link

mduchev commented Oct 28, 2020

@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.

@samhouts samhouts removed this from Done in Android Ready For Work Nov 3, 2020
@samhouts samhouts removed this from Done in CollectionView Nov 3, 2020
@mduchev
Copy link

mduchev commented Nov 4, 2020

@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
Copy link

AshishMantosh commented Jan 18, 2021

ZeProgFactory

What was the workaround?

@bikrambhandari48
Copy link

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>b__19_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].b__16_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
Copy link

@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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4.4.0 regression on 4.4.0 a/collectionview a/fastrenderers a/label a/listview Problems with the ListView/TableView e/5 🕔 5 feedback-ticket Issue originates from https://developercommunity.visualstudio.com i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often i/regression in-progress This issue has an associated pull request that may resolve it! m/high impact ⬛ p/Android s/unverified New report that has yet to be verified t/bug 🐛
Projects
No open projects
Development

No branches or pull requests