Hi guys,
I've written an app with a multi-page form in Xamarin Forums. Users complain about getting errors I can hardly reproduce. There's no way to test this while debugging.
HockeyApp gives me this error when they switch x times back and forth between the pages and then click on a button (and only a button), not a dropdown or other input fields. They render properly and I'm using the last version of Xamarin Forms.
Right now I'm only using Forms for Android, so I can only test this on Android.
<br />
Xamarin caused by: android.runtime.JavaProxyThrowable: System.ObjectDisposedException: Cannot access a disposed object.<br />
Object name: 'Xamarin.Forms.Platform.Android.Platform+DefaultRenderer'.<br />
Java.Interop.JniPeerMembers.AssertSelf(IJavaPeerable self)<bd30a18775d94dc8b6263aecd1ca9077>:0<br />
Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualVoidMethod(string encodedMember, IJavaPeerable self, JniArgumentValue* parameters)<bd30a18775d94dc8b6263aecd1ca9077>:0<br />
Android.Views.View.SetBackgroundColor(Color color)<9ab9faae1b4b4f0da28e7c4ac61e2c78>:0<br />
Xamarin.Forms.Platform.Android.VisualElementRenderer<TElement>.UpdateBackgroundColor()<8783e2b68568446a8522c36407e66253>:0<br />
Xamarin.Forms.Platform.Android.VisualElementRenderer<TElement>.OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)<8783e2b68568446a8522c36407e66253>:0<br />
<Module>.invoke_void_object_PropertyChangedEventArgs(object, PropertyChangedEventArgs)(wrapper delegate-invoke)<br />
Xamarin.Forms.BindableObject.OnPropertyChanged(string propertyName)<6e20d7af277949f4a7bb952d64b81cda>:0<br />
Xamarin.Forms.Element.OnPropertyChanged(string propertyName)<6e20d7af277949f4a7bb952d64b81cda>:0<br />
Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindableObject.BindablePropertyContext context, object value, bool currentlyApplying, BindableObject.SetValueFlags attributes, bool silent)<6e20d7af277949f4a7bb952d64b81cda>:0<br />
Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, object value, BindableObject.SetValueFlags attributes, BindableObject.SetValuePrivateFlags privateAttributes)<6e20d7af277949f4a7bb952d64b81cda>:0<br />
Xamarin.Forms.BindingExpression.ApplyCore(object sourceObject, BindableObject target, BindableProperty property, bool fromTarget)<6e20d7af277949f4a7bb952d64b81cda>:0<br />
Xamarin.Forms.BindingExpression.Apply(bool fromTarget)<6e20d7af277949f4a7bb952d64b81cda>:0<br />
Xamarin.Forms.BindingExpression.BindingExpressionPart.<PropertyChanged>b__47_0()<6e20d7af277949f4a7bb952d64b81cda>:0<br />
Java.Lang.Thread.RunnableImplementor.Run()<9ab9faae1b4b4f0da28e7c4ac61e2c78>:0<br />
Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this)<9ab9faae1b4b4f0da28e7c4ac61e2c78>:0<br />
at (wrapper dynamic-method) System.Object:94a3beb6-4f7c-4b9d-958e-0e8b8d73194b (intptr,intptr)<br />
mono.java.lang.RunnableImplementor.n_run(Native Method)<br />
mono.java.lang.RunnableImplementor.run()RunnableImplementor.java:30<br />
android.os.Handler.handleCallback()Handler.java:751<br />
android.os.Handler.dispatchMessage()Handler.java:95<br />
android.os.Looper.loop()Looper.java:154<br />
android.app.ActivityThread.main()ActivityThread.java:6120<br />
java.lang.reflect.Method.invoke(Native Method)<br />
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run()ZygoteInit.java:865<br />
com.android.internal.os.ZygoteInit.main()ZygoteInit.java:755<br />
Because of a memoryleak in Forms, I had to change it to images with FFImageLoading.
Unfortunately, I cannot post much code, but this is the grid row that keeps crashing:
<br />
<?xml version="1.0" encoding="utf-8" ?><br />
<Grid xmlns="n.com/schemas/2014/forms"
xmlns:x="ft.com/winfx/2009/xaml"
xmlns:forms="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"
xmlns:extensions="clr-***.Extensions;assembly=***"
x:Class="***.Views.Editors.BooleanEditor"
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Padding="5,0"
x:Name="Grid" IsVisible="{Binding Visible}" HeightRequest="80"><br />
<Grid.RowDefinitions><br />
<RowDefinition Height="80"/><br />
</Grid.RowDefinitions></p>
<p><Grid.ColumnDefinitions><br />
<ColumnDefinition Width=".2*"/><br />
<ColumnDefinition Width="1*"/><br />
<ColumnDefinition Width="3*"/><br />
<ColumnDefinition Width="1*"/><br />
<ColumnDefinition Width="6*"/><br />
<ColumnDefinition Width=".5*"/><br />
<ColumnDefinition Width="1*"/><br />
<ColumnDefinition Width=".5*"/><br />
<ColumnDefinition Width="1*"/><br />
<ColumnDefinition Width=".5*"/><br />
</Grid.ColumnDefinitions></p>
<p><Grid.Children><br />
<forms:CachedImage Grid.Row="0" Grid.Column="0" WidthRequest="24" HeightRequest="24" DownsampleHeight="24" DownsampleWidth="24" Source="{extensions:ImageResource ***.Images.info.png}"
HorizontalOptions="Start" VerticalOptions="Center" IsVisible="{Binding HasMemo}" CacheType="All" Margin="15,0,0,0"><br />
<forms:CachedImage.GestureRecognizers><br />
<TapGestureRecognizer Command="{Binding BindingContext.ItemHelpCommand, Source={x:Reference Grid}}"/><br />
</forms:CachedImage.GestureRecognizers><br />
</forms:CachedImage></p>
<pre><code><ContentView Grid.RowSpan="1" Grid.Row="0" Grid.Column="2" VerticalOptions="FillAndExpand">
<StackLayout Spacing="0" VerticalOptions="End" Margin="0,0,0,25">
<StackLayout Spacing="0">
<Label HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Start" VerticalTextAlignment="Center" Text="{Binding Name}" FontSize="14"/>
</StackLayout>
<Label IsVisible="{Binding Required, Converter={StaticResource InvertBoolean}}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Start" VerticalTextAlignment="End" Text="{extensions:Translate DynamicFormOptional}" FontSize="10"/>
</StackLayout>
</ContentView>
<ContentView BackgroundColor="{Binding BgColor}" Grid.Row="0" Grid.Column="4" Margin="0,0,0,12">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.Children>
<Label Grid.Row="0" Grid.Column="0" HorizontalOptions="Start" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Start" VerticalTextAlignment="Center" Text="{Binding PreviousValue, Converter={StaticResource TextTranslation}}" IsVisible="{Binding BindingContext.ValueHasChanged, Source={x:Reference Grid}}" />
<Label Grid.Row="0" Grid.Column="0" HorizontalOptions="Start" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Start" VerticalTextAlignment="Center" IsVisible="{Binding BindingContext.ValueHasChanged, Source={x:Reference Grid}, Converter={StaticResource InvertBoolean}}" />
<forms:CachedImage VerticalOptions="Center" Grid.Row="1" Grid.Column="0" DownsampleToViewSize="True" Source="{extensions:ImageResource ***.Images.buttonNoOff.png}" IsVisible="{Binding Value, Converter={StaticResource NullableBoolean}, ConverterParameter=True}" CacheType="All">
<forms:CachedImage.GestureRecognizers>
<TapGestureRecognizer Command="{Binding BindingContext.BooleanNoCommand, Source={x:Reference Grid}}"/>
</forms:CachedImage.GestureRecognizers>
</forms:CachedImage>
<forms:CachedImage VerticalOptions="Center" Grid.Row="1" Grid.Column="0" DownsampleToViewSize="True" Source="{extensions:ImageResource ***.Images.buttonNoOn.png}" IsVisible="{Binding Value, Converter={StaticResource InvertNullableBoolean}}" CacheType="All">
<forms:CachedImage.GestureRecognizers>
<TapGestureRecognizer Command="{Binding BindingContext.BooleanNoCommand, Source={x:Reference Grid}}"/>
</forms:CachedImage.GestureRecognizers>
</forms:CachedImage>
<forms:CachedImage VerticalOptions="Center" Grid.Row="1" Grid.Column="1" WidthRequest="147" HeightRequest="100" DownsampleHeight="40" DownsampleWidth="147" DownsampleToViewSize="False" Source="{extensions:ImageResource ***.Images.buttonYesOff.png}" IsVisible="{Binding Value, Converter={StaticResource InvertNullableBoolean}, ConverterParameter=True}" CacheType="All">
<forms:CachedImage.GestureRecognizers>
<TapGestureRecognizer Command="{Binding BindingContext.BooleanYesCommand, Source={x:Reference Grid}}"/>
</forms:CachedImage.GestureRecognizers>
</forms:CachedImage>
<forms:CachedImage VerticalOptions="Center" Grid.Row="1" Grid.Column="1" WidthRequest="147" HeightRequest="100" DownsampleHeight="40" DownsampleWidth="147" DownsampleToViewSize="False" Source="{extensions:ImageResource ***.Images.buttonYesOn.png}" IsVisible="{Binding Value, Converter={StaticResource NullableBoolean}}" CacheType="All">
<forms:CachedImage.GestureRecognizers>
<TapGestureRecognizer Command="{Binding BindingContext.BooleanYesCommand, Source={x:Reference Grid}}"/>
</forms:CachedImage.GestureRecognizers>
</forms:CachedImage>
</Grid.Children>
</Grid>
</ContentView>
<forms:CachedImage Grid.RowSpan="2" Grid.Row="0" Grid.Column="6" WidthRequest="24" HeightRequest="24" DownsampleHeight="24" DownsampleWidth="24" DownsampleToViewSize="False" Source="{Binding HasIssue, Converter={StaticResource HasIssueBoolConverter}}" IsVisible="{Binding HasIssueColumn}" CacheType="All">
<forms:CachedImage.GestureRecognizers>
<TapGestureRecognizer Command="{Binding BindingContext.HasIssueCommand, Source={x:Reference Grid}}"/>
</forms:CachedImage.GestureRecognizers>
</forms:CachedImage>
<forms:CachedImage Grid.RowSpan="2" Grid.Row="0" Grid.Column="8" WidthRequest="24" HeightRequest="24" DownsampleHeight="24" DownsampleWidth="24" DownsampleToViewSize="False" Source="{Binding CameraIcon, Converter={StaticResource CameraIconConverter}}" IsVisible="{Binding PictureRequired}" CacheType="All">
<forms:CachedImage.GestureRecognizers>
<TapGestureRecognizer Command="{Binding BindingContext.Photo, Source={x:Reference Grid}}"/>
</forms:CachedImage.GestureRecognizers>
</forms:CachedImage>
</Grid.Children>
<br />
public partial class BooleanEditor : Grid, IEditor<br />
{<br />
public BooleanEditor()<br />
{<br />
InitializeComponent();<br />
}</p>
<pre><code> public EditorTypes EditorType => EditorTypes.Boolean;
}
I have removed the
<br />
BackgroundColor="{Binding BgColor}"<br />
for testing, but that did not change anything.
Please please help me, I'm getting desperate.