Declined
Last Updated: 19 Sep 2019 14:22 by ADMIN
Anthony
Created on: 17 Jul 2019 22:22
Category: ListView
Type: Bug Report
0
System.ObjectDisposedException: Cannot access a disposed object

Hi,

I rolled my app with the ListView out to production and are getting 8+ crashes a day from 140 users with the above issue. I have included a stack trace. I cannot find the steps to reproduce the issue in development. I have rolled back to using the native ListView as this does not crash the app.

Attached is an example project to see what I am doing in general terms, but I have not been able to reproduce this crash in it.

My guess is that a DataTemplate is not being cleaned up properly and when the data behind is changed it attempts to access the control that represented the data in the DataTemplate.

Regards
Anthony

Xamarin caused by: android.runtime.JavaProxyThrowable: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Android.Support.V7.Widget.SwitchCompat'.
Java.Interop.JniPeerMembers.AssertSelf(IJavaPeerable self)<9cb01525c8ce48268eb7a54e1b653d67>:0
Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualVoidMethod(string encodedMember, IJavaPeerable self, JniArgumentValue* parameters)<9cb01525c8ce48268eb7a54e1b653d67>:0
Android.Widget.CompoundButton.set_Checked(bool value)<83e36ed05052486983583851de96589e>:0
Xamarin.Forms.Platform.Android.AppCompat.SwitchRenderer.HandleToggled(object sender, EventArgs e)<e6fe81c4055a4db5bd435b7d12d894e3>:0
at Xamarin.Forms.Switch+<>c.<.cctor>b__14_0 (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x0001c] in <209f66ed8fe04cb6a815feb8c3b62471>:0
Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindableObject.BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes, bool silent)<209f66ed8fe04cb6a815feb8c3b62471>:0
Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, object value, SetValueFlags attributes, BindableObject.SetValuePrivateFlags privateAttributes)<209f66ed8fe04cb6a815feb8c3b62471>:0
Xamarin.Forms.BindingExpression.ApplyCore(object sourceObject, BindableObject target, BindableProperty property, bool fromTarget)<209f66ed8fe04cb6a815feb8c3b62471>:0
Xamarin.Forms.BindingExpression.Apply(bool fromTarget)<209f66ed8fe04cb6a815feb8c3b62471>:0
Xamarin.Forms.BindingExpression.BindingExpressionPart.<PropertyChanged>b__49_0()<209f66ed8fe04cb6a815feb8c3b62471>:0
Java.Lang.Thread.RunnableImplementor.Run()<83e36ed05052486983583851de96589e>:0
Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this)<83e36ed05052486983583851de96589e>:0
at (wrapper dynamic-method) System.Object.31(intptr,intptr)
mono.java.lang.RunnableImplementor.n_run(Native Method)
mono.java.lang.RunnableImplementor.run()RunnableImplementor.java:30
android.os.Handler.handleCallback()Handler.java:739
android.os.Handler.dispatchMessage()Handler.java:95
android.os.Looper.loop()Looper.java:145
android.app.ActivityThread.main()ActivityThread.java:6914
java.lang.reflect.Method.invoke(Native Method)
java.lang.reflect.Method.invoke()Method.java:372
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run()ZygoteInit.java:1404
com.android.internal.os.ZygoteInit.main()ZygoteInit.java:1199

 

Attached Files:
2 comments
ADMIN
Lance | Manager Technical Support
Posted on: 19 Sep 2019 14:22

Hi,

I have marked this Bug Report Declined due to inactivity. If the issue re-appears in the future, feel free to post a reply or open a support ticket for us to reconsider the issue.

Regards,
Lance | Technical Support Engineer, Principal
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
ADMIN
Lance | Manager Technical Support
Posted on: 18 Jul 2019 16:47
Hi Anthony,

Thank you for the test code. I immediately noticed a problem on the PersonContentPage; the RadListView is inside the BusyIndicator content. See this KB article for the reason why it is a problem and also a solution for it - RadBusyIndicator with Data Bound Controls.

Can you update the implementation(s) in your application, following the instructions in the KB, and let us know if you still experience the issue.

To help you jump start the fix, here's what it should look like after updating the PersonContentPage:

- I moved the BusyIndicator on top of the RadListView (this will prevent it being removed from the Visual Tree)
- I bound IsBusy to the RadBusyIndicator.IsVisible (so that gestures are not blocked)

<Grid BindingContext="{Binding Data}">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
 
    <Entry Grid.Column="0"
           Grid.Row="0"
           Margin="5,0,0,0"
           Text="{Binding Path=Name}"
           Unfocused="Editor_Unfocused" />
 
    <telerikDataControls:RadListView x:Name="ChildListView"
                      ItemsSource="{Binding Passengers}"
                      ItemTemplateSelector="{StaticResource PassengerDataTemplateSelector}"
                      FooterTemplate="{StaticResource FooterTemplate}"
                      ItemSwipeContentTemplate="{StaticResource ItemSwipeDataTemplate}"
                      IsItemSwipeEnabled="True"
                      SwipeOffset="200,0,0,0"
                      SwipeThreshold="200"
                      Grid.Row="1">
        <telerikDataControls:RadListView.ItemStyle>
            <telerikListView:ListViewItemStyle BackgroundColor="{Binding Colour}" />
        </telerikDataControls:RadListView.ItemStyle>
    </telerikDataControls:RadListView>
 
    <primitives:RadBusyIndicator Grid.Row="1"
                    AnimationType="Animation3"
                    IsBusy="{Binding IsBusy}"
                    IsVisible="{Binding IsBusy}"
                    AnimationContentColor="DarkGray"
                    AnimationContentWidthRequest="50"
                    AnimationContentHeightRequest="50" />
</Grid>

Regards,
Lance | Technical Support Engineer, Principal
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items