Xamarin Forms MasterDetail page navigation causing crash on android [Fatal signal 6 (SIGABRT), code -6], Works on iOS and UWP
Asked Answered
P

2

10

I have a Master Detail like below

public partial class LeaguesMDPage : MasterDetailPage
{
    public LeaguesMDPage()
    {
        InitializeComponent();
        Master = new LeaguesPage();
        Detail = new NavigationPage(new DivisionsPage(new League()));
    }
}

League Page (the Master) design has a list view like below

    <ListView
    ItemsSource="{Binding Leagues}"
    SelectedItem="{Binding SelectedLeague, Mode=TwoWay}"
    IsPullToRefreshEnabled="True"
    RefreshCommand="{Binding UpdateLeagues}"
    IsRefreshing="{Binding IsBusy}"
    >

and the code behind is

public partial class LeaguesPage : ContentPage
{
    LeaguesViewModel vm;

    public LeaguesPage()
    {
        InitializeComponent();
        BindingContext = vm = new LeaguesViewModel(this);
    }
    protected override void OnAppearing()
    {
        base.OnAppearing();
        vm.UpdateLeagues.Execute(false);   
    }
}

In the LeaguesViewModel I have the the SelectedLeague property setter update the Detail page and hide the Master like so

League _SelectedLeague;

public League SelectedLeague
{
    get { return _SelectedLeague; }
    set
    {
        _SelectedLeague = value;
        OnPropertyChanged();
        if (_SelectedLeague != null)
        {
            Debug.WriteLine($"Navigating to DivisionsPage with LeagueID {_SelectedLeague.ID}");
            var mdp = (MasterDetailPage)App.Current.MainPage;
            Device.OnPlatform(                     
                    Android: () => { mdp.IsPresented = false; },
                    iOS: () => { mdp.IsPresented = false; },
                    WinPhone: () => { },
                    Default: () => { mdp.IsPresented = false; }
                );
            mdp.Detail = new NavigationPage(new DivisionsPage(_SelectedLeague));
            _SelectedLeague = null;
        }
    }
}

This does seems to work as I hope sometimes. It Navigates to the new DivisionsPage and hides the master. Seems to work fine on iOS and UWP, but its crashing on Android with the following

[0:] Server Returned 34 divisions
[0:] Navigating to DivisionsPage with LeagueID 12
[0:] UpdatePoolRankings: Called GetDivisionsAsync
03-23 02:40:52.151 W/Mono    ( 6249): The request to load the assembly System.Core v4.0.0.0 was remapped to v2.0.5.0
03-23 02:40:52.151 D/Mono    ( 6249): Unloading image System.Core.dll [0x99db7700].
03-23 02:40:52.151 D/Mono    ( 6249): Image addref System.Core[0xaec169a0] -> System.Core.dll[0x9d166d00]: 11
03-23 02:40:52.151 D/Mono    ( 6249): Config attempting to parse: 'System.Core.dll.config'.
03-23 02:40:52.151 D/Mono    ( 6249): Config attempting to parse: '/Users/builder/data/lanes/4009/f3074d2c/source/monodroid/builds/install/mono-x86/etc/mono/assemblies/System.Core/System.Core.config'.
03-23 02:40:52.152 W/Mono    ( 6249): The request to load the assembly System.Core v4.0.0.0 was remapped to v2.0.5.0
03-23 02:40:52.152 D/Mono    ( 6249): Unloading image System.Core.dll [0x99db7700].
03-23 02:40:52.152 D/Mono    ( 6249): Image addref System.Core[0xaec169a0] -> System.Core.dll[0x9d166d00]: 12
03-23 02:40:52.152 D/Mono    ( 6249): Config attempting to parse: 'System.Core.dll.config'.
03-23 02:40:52.152 D/Mono    ( 6249): Config attempting to parse: '/Users/builder/data/lanes/4009/f3074d2c/source/monodroid/builds/install/mono-x86/etc/mono/assemblies/System.Core/System.Core.config'.
03-23 02:40:52.383 D/Mono    ( 6249): [0x9b5bf930] hill climbing, change max number of threads 4
[0:] Server Returned 3 divisions
03-23 02:40:52.421 F/        ( 6249): * Assertion at /Users/builder/data/lanes/4009/f3074d2c/source/mono/mono/metadata/sgen-tarjan-bridge.c:1139, condition `xref_count == xref_index' not met
03-23 02:40:52.421 F/libc    ( 6249): Fatal signal 6 (SIGABRT), code -6 in tid 6249 (ClubApp.Droid)
InspectorDebugSession(21): Disposed
InspectorDebugSession(21): HandleTargetEvent: TargetExited

Please let me know if more details are need, thanks!

Picrite answered 24/3, 2017 at 2:34 Comment(7)
Could you please share a basic demo that can reproduce this problem?Honeyhoneybee
@ElvisXia-MSFT Here is a reduced version but i have been able to reproduce the problem here bitbucket.org/schnabs/clubapp_42990427 To repo be sure to use android and in a loop keep clicking to open the master, then pick from the list, open master, pick from master list and so on until it crashesPicrite
I have found another person having this issue bugzilla.xamarin.com/show_bug.cgi?id=54120 Also I think this is were its coming from inside mono github.com/mono/mono/blob/master/mono/metadata/…Picrite
I have the exact same issue!Tripp
In my case I also use a Master-Detail. In my detail I have a ListView, which it navigates to another page that has ListView. When I go back, sometimes the app crashes with the exact same message. I am using Xamarin formsTripp
@Picrite Did you find a solution ?Chekhov
Did you guys tried to set the Title of your menu list page?Parallelepiped
R
0

I updated your sample to the latest release of 2.3.4 and it runs on Android without an issue. I would suggest that you remove the code behind in your MasterDetailPage and update it to the following:

<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:ClubApp.Views;assembly=ClubApp"
             xmlns:model="clr-namespace:ClubApp.Models;assembly=ClubApp"
             x:Class="ClubApp.Views.MainMasterDetailPage" 
             Title="MD Page"
             IsPresented="True">
    <MasterDetailPage.Master>
        <local:LeaguesPage />
    </MasterDetailPage.Master>
    <MasterDetailPage.Detail>
        <NavigationPage>
            <x:Arguments>
                <local:DivisionsPage>
                    <x:Arguments>
                        <model:League />
                    </x:Arguments>
                </local:DivisionsPage>
            </x:Arguments>
        </NavigationPage>
    </MasterDetailPage.Detail>
</MasterDetailPage>
Rainfall answered 31/5, 2017 at 17:27 Comment(8)
You address the bug with Xamarin Forms (I didn't test your solution). The bug is also present with a (native) Xamarin Android app. Do you have a solution for that case ?Chekhov
You didn't post a non-Forms repro. If your problem is with a Forms app, then based on your sample you should only need to update to the latest stable release.Rainfall
I'm not the OP (but I started the bounty). I just have the same problem with a non-Forms app, and I thought you might know about the underlying issue that could be transposed to my case.Chekhov
If you post a repro I can take a lookRainfall
Here is a sample app : drive.google.com/open?id=0B7De5DfDEi--QlJEN29xNjhDZGc After going back and forth 17 times it crashes (17 times for my Lg G4c but 30 times for a Galaxy S6, but it is always the same amount).Chekhov
Apparently it's also a bug caused by Xamarin Android 7.3 : github.com/reactiveui/ReactiveUI/issues/1379Chekhov
@StephaneMathis the issue that you're having is a completely different issue from the original question asked. But as pointed out in the Xamarin.Android 7.3 Release Notes, you simply need to add an Environment.txt file with the value MONO_GC_PARAMS=bridge-implementation=old and it will work just fine.Rainfall
2020 and I'm having same issue with xamarin android, using master detail page.Danikadanila
T
0

I had a similar problem which turned out to be caused by a bug in the android renderer for the NavigationPage. Check out this thread at the Xamarin Forum there is a linked bug report and a workaround. The issue should be fixed in the current XamForms version.

You could try to leave out the NavigationPage (and set your DivisionsPage directly as the Detail) to find out if it's the NavigationPage which causes the crash.

Tremulous answered 24/11, 2017 at 11:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.