Xamarin.forms: [Bug] Layout.ResolveLayoutChanges crashing on System.ObjectDisposedException

Created on 1 Apr 2020  ·  24Comments  ·  Source: xamarin/Xamarin.Forms

Description

We are seeing sporadic crashes specifically on Android where we get System.ObjectDisposedException: Cannot access a disposed object when doing Layout.ResolveLayoutChanges for Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer

Expected Behavior

It should not crash

Actual Behavior

It crashes for customers and users

Workaround

No known workarounds currently.

Basic Information

  • Version with issue: 4.6.0-pre2
  • Last known good version: Unknown
  • IDE: VS For Mac
  • Android Support Library Version: N/A
  • Affected Devices: Random Android devices

  • Platform Target Frameworks:

    • Android: 7.0 to 10.0

Stack trace

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer'.
  at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <5c01cc23b53949bca33fa3e8371e1af3>:0
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <5c01cc23b53949bca33fa3e8371e1af3>:0
  at Android.Views.View.get_Context () [0x0000a] in <9208d5fd0c8c43b7a00f304ba0f7c041>: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:1332
  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:855
  at Xamarin.Forms.VisualElement.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00025] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:787
  at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:770
  at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:646
  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:704
  at Xamarin.Forms.Grid.CalculateAutoCells (System.Double width, System.Double height) [0x000e5] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:133
  at Xamarin.Forms.Grid.MeasureGrid (System.Double width, System.Double height, System.Boolean requestSize) [0x0000c] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:485
  at Xamarin.Forms.Grid.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x0000e] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:18
  at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266
  at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224
  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:792
  at Xamarin.Forms.Layout.ResolveLayoutChanges () [0x0005c] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:392
  at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <9208d5fd0c8c43b7a00f304ba0f7c041>:0
  at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <9208d5fd0c8c43b7a00f304ba0f7c041>:0
  at at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.51(intptr,intptr)
fastrenderers label high high impact Android needs-repro ❔ unverified bug

All 24 comments

I can confirm the issue. Tested on Android Emulator and real device using XF 4.6.0-pre2.

[MonoDroid] System.ObjectDisposedException: Cannot access a disposed object.
[MonoDroid] Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer'.
[MonoDroid]   at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <26521a5118b44c858c385715922b9d5d>:0 
[MonoDroid]   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <26521a5118b44c858c385715922b9d5d>:0 
[MonoDroid]   at Android.Views.View.get_Context () [0x0000a] in <d3b924763d4a465c85b26f6e8edc8a53>:0 
[MonoDroid]   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:1332 
[MonoDroid]   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:855 
[MonoDroid]   at Xamarin.Forms.VisualElement.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00025] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:787 
[MonoDroid]   at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:770 
[MonoDroid]   at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:646 
[MonoDroid]   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:704 
[MonoDroid]   at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x0007b] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:154 
[MonoDroid]   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 
[MonoDroid]   at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266 
[MonoDroid]   at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224 
[MonoDroid]   at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:792 
[MonoDroid]   at Xamarin.Forms.Layout.ResolveLayoutChanges () [0x0005c] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:392 
[MonoDroid]   at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <d3b924763d4a465c85b26f6e8edc8a53>:0 
[MonoDroid]   at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <d3b924763d4a465c85b26f6e8edc8a53>:0 
[MonoDroid]   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.44(intptr,intptr)

tested on XF 4.6.0 pre3

    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) D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:1332
    Forms+AndroidPlatformServices.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) D:\a\1\s\Xamarin.Forms.Platform.Android\Forms.cs:855
    VisualElement.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:787
    VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:770
    VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:646
    VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:704
    Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) D:\a\1\s\Xamarin.Forms.Core\Layout.cs:154
    Grid.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:49
    Layout.UpdateChildrenLayout () D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266
    Layout.OnSizeAllocated (System.Double width, System.Double height) D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224
    VisualElement.SizeAllocated (System.Double width, System.Double height) D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:792
    Layout.ResolveLayoutChanges () D:\a\1\s\Xamarin.Forms.Core\Layout.cs:392
    Thread+RunnableImplementor.Run ()
    IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this)
    (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.26(intptr,intptr)

Does anyone have a reproduction they could zip and attach?

In my example it's really hard to create a reproduction project, because the issue does not occur in a for me reproducable way. And until now I was not able to figure out what exactly triggers it. I just can say that all ui changing actions are fired on mainthread, because a race condition as described in #9753 was the first I thought of.
It seems to occur in random situations, but XF 4.6.0.726 is also affected.
Maybe @SneWs and @Reveon have more detailed information.

Same random Error with XF 4.6.0.726
Stack Traces :

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)
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)
TemplatedView.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags)
StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint)
StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders)
StackLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags)
StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint)
StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders)
StackLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags)
StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint)
StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders)
StackLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags)
TemplatedView.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags)
StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint)
StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders)
StackLayout.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.42(intptr,intptr)

We have not been able to repro this locally, we only see this in crash reports from customers out in the wild. So unfortunately no good way of providing a solid repro project from myself.

Just tested it on 4.6.0.726 and I still see this issue.

I tried to create repro but with no luck as the issue is very random. Maybe this could be related to #10031 (It's ImageRenderer but the stack and exception look the same).

Just tested it on 4.6.0.726 and I still see this issue.

I tried to create repro but with no luck as the issue is very random. Maybe this could be related to #10031 (It's ImageRenderer but the stack and exception look the same).

Great Reveon,

I think that it probally is the same issue , it is very random.

So, hardest to know the cause exception and could be verified asap ,

We need to find the solution quickly, this is being very bad.

I can reliably reproduce this issue with one of our production apps.

Because it's a commercial app, I can't publicly post the source code. @kingces95 or @samhouts how can I privately submit a repro to Xamarin/Microsoft; and would you be willing/able to sign an NDA first (my boss would prefer that)?

Hi, same problem with 4.6.0.772, i downgrade again in 4.3.0.991211

@Sylv1F You should actually be OK with 4.4.x - I just tested every released build upwards from 4.3.x - every build up to and including 4.4.0.991864 worked fine. Starting with 4.5.0.356, this crash occurs. So it seems the bug was introduced in XF 4.5.

@mpnow Thanks ! I upgrade framework after framework.
At this time last XF 4.4.0.991864 is Ok, and XF 4.5.0.356 work but the crash is random, so i continue upgrade slowly...
50/5000
The problem could be related to external packages ?
I use mainly Rg.Plugins.Popup, SkiaSharp, Plugin.SegmentedControl, Acr.UserDialogs

Upgrade to XF 4.6.0.800 crash, downgrade in XF 4.5.0.266 ok

Last really stable XF : XF 4.4.0.991864

@Sylv1F Downgrading to XF 4.4.0.991864 "fixed" the issue for me. Thanks for sharing

just tested 4.7.0.937-pre4 and the issue is still there

I found the origin of my crash. I have a masterdetailpage with a MasterDetailPage.Master with a listview and a MessagingCenter.Subscribe. This Listview contains an ObservableRangeCollection .
In a detailpage I have a messagingcenter.send to modify this ObservableRangeCollection and update my ListView.

Before XF 4.5 no problem
After XF 4.5+ random crashes

I added INotifyPropertyChanged to Items, it looks better ...

87/5000
Finally I deleted my bindings in my menu (listview) and the crashes disappeared

Bug still exists in Xamarin.Forms 4.8.0.1269 for 2 emulators Android versions 7.1 and 9.0.
Crash report from AppCenter:

JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self)
System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer'.

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)
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)
StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint)
StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders)
StackLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags)
TemplatedView.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags)
StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint)
StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders)
StackLayout.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.36(intptr,intptr)

I can confirm, that for me XF 4.4.0.991864 did NOT fix it, still geting same exception.

Bug still exist in Xamarin.Forms 4.8.0.1364

Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer'.
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 <9a14097a65a445eaa85f6a3a1ade52a3>: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:854 
at Xamarin.Forms.Image.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Image.cs:74 
at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:837 
at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:713 
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:771 
at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x0007b] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:154 
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:266 
at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224 
at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:859 
at Xamarin.Forms.Layout.ResolveLayoutChanges () [0x0005c] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:392 
at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <9a14097a65a445eaa85f6a3a1ade52a3>:0 
at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <9a14097a65a445eaa85f6a3a1ade52a3>:0 
t (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.1(intptr,intptr)

Bug still exist in Xamarin.Forms 4.8.0.1364

Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer'.
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 <9a14097a65a445eaa85f6a3a1ade52a3>: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:854 
at Xamarin.Forms.Image.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Image.cs:74 
at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:837 
at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:713 
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:771 
at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x0007b] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:154 
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:266 
at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224 
at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:859 
at Xamarin.Forms.Layout.ResolveLayoutChanges () [0x0005c] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:392 
at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <9a14097a65a445eaa85f6a3a1ade52a3>:0 
at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <9a14097a65a445eaa85f6a3a1ade52a3>:0 
t (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.1(intptr,intptr)

See what I found where the crash is happening: https://github.com/xamarin/Xamarin.Forms/blob/main/Xamarin.Forms.Platform.Android/Platform.cs
Line 1332

// FIXME: potential crash
IVisualElementRenderer visualElementRenderer = GetRenderer(view);

Can anyone who is seeing this issue test with the nuget here?

https://dev.azure.com/xamarin/public/_build/results?buildId=25860&view=artifacts&type=publishedArtifacts

And then please let me know if you still see the exception?

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

Was this page helpful?
0 / 5 - 0 ratings