Bug 57910

Summary: ObjectDisposedException in Xamarin.Forms.Platform.Android.Renderers.ProgressBarRenderer
Product: Forms Reporter: Matthew Richardson <info>
Component: AndroidAssignee: Bugzilla <bugzilla>
Status: RESOLVED FIXED    
Severity: normal CC: jas, jimmy.garrido, pamorris, rui.marinho, sahou
Priority: ---    
Version: 2.3.5   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS   
Tags: ac android pregressbar gc navigation fr Is this bug a regression?: ---
Last known good build:
Attachments: Repro Project for Android

Description Matthew Richardson 2017-07-03 14:57:03 UTC
Created attachment 23264 [details]
Repro Project for Android

System.ObjectDisposedException: Cannot access a disposed object.
[AndroidRuntime] Object name: 'Android.Widget.ProgressBar'.
[AndroidRuntime]   at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <bd30a18775d94dc8b6263aecd1ca9077>:0 
[AndroidRuntime]   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <bd30a18775d94dc8b6263aecd1ca9077>:0 
[AndroidRuntime]   at Android.Widget.ProgressBar.set_Progress (System.Int32 value) [0x00022] in <d855bac285f44dda8a0d8510b679b1e2>:0 
[AndroidRuntime]   at Xamarin.Forms.Platform.Android.ProgressBarRenderer.UpdateProgress () [0x00012] in <0c75dce398e543a3bb407fe5fdb5e25c>:0 
[AndroidRuntime]   at Xamarin.Forms.Platform.Android.ProgressBarRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e)

Crash when GC occurs during navigation i.e. pushing or popping from the navigation stack.

2.3.5-pre5      BAD
2.3.4.247       BAD

Using the supplied repro project, push and pop the demo page approx 2-3 times to get the crash.
Tested on a Nexus 7 device, Android 6.0.1.

Similar to https://bugzilla.xamarin.com/show_bug.cgi?id=57789.
Note: I actually came across this crash while trying to create a repro for #57789 and thought would bug it separately.
Comment 1 Jimmy [MSFT] 2017-07-05 17:51:04 UTC
I was able to reproduce this crash on a Nexus 5X running Android 7.1.1. I had to push the button to navigate to the next page then immediately press the back button. In my case it took more than 2-3 times but it did eventually crash with the following:

> UNHANDLED EXCEPTION:
> System.ObjectDisposedException: Cannot access a disposed object.
> Object name: 'Android.Widget.ProgressBar'.
> at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <bd30a18775d94dc8b6263aecd1ca9077>:0 
> at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <bd30a18775d94dc8b6263aecd1ca9077>:0 
> at Android.Widget.ProgressBar.set_Progress (System.Int32 value) [0x00022] in <d855bac285f44dda8a0d8510b679b1e2>:0 
> at Xamarin.Forms.Platform.Android.ProgressBarRenderer.UpdateProgress () [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:38 
> at Xamarin.Forms.Platform.Android.ProgressBarRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:37 
> at (wrapper delegate-invoke) <Module>:invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
> at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x0000a] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:137 
> at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:388 
> 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) [0x000f4] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:592 
> at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:389 
> at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x001f9] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:174 
> at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:56 
> at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__47_0 () [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:540 
> at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <d855bac285f44dda8a0d8510b679b1e2>:0 
> at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <d855bac285f44dda8a0d8510b679b1e2>:0 
> at (wrapper dynamic-method) System.Object:c88c9f0c-180a-4758-a714-b5e2c28990d0 (intptr,intptr)
Comment 2 Rui Marinho 2017-08-15 18:24:25 UTC
Should be fixed on 2.4.0-pre1
Comment 3 Samantha Houts [MSFT] 2017-08-15 19:01:54 UTC
https://github.com/xamarin/Xamarin.Forms/pull/1063
Comment 4 Rui Marinho 2017-10-18 22:27:30 UTC
Should be fixed on 2.4.0 service release 2