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!

schnabs
  • 125
  • 9
  • Could you please share a basic demo that can reproduce this problem? – Elvis Xia - MSFT Mar 27 '17 at 09:20
  • @ElvisXia-MSFT Here is a reduced version but i have been able to reproduce the problem here https://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 crashes – schnabs Mar 30 '17 at 21:14
  • I have found another person having this issue https://bugzilla.xamarin.com/show_bug.cgi?id=54120 Also I think this is were its coming from inside mono https://github.com/mono/mono/blob/master/mono/metadata/sgen-tarjan-bridge.c#L1140 – schnabs Apr 01 '17 at 15:13
  • I have the exact same issue! – CCamilo Apr 03 '17 at 14:15
  • 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 forms – CCamilo Apr 04 '17 at 07:25
  • @schnabs Did you find a solution ? – Stephane Mathis May 30 '17 at 09:21
  • Did you guys tried to set the Title of your menu list page? – Ravindra Kumar May 30 '17 at 20:56

2 Answers2

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>
Dan Siegel
  • 5,370
  • 2
  • 11
  • 25
  • 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 ? – Stephane Mathis Jun 01 '17 at 07:13
  • 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. – Dan Siegel Jun 01 '17 at 07:22
  • 1
    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. – Stephane Mathis Jun 01 '17 at 07:29
  • If you post a repro I can take a look – Dan Siegel Jun 01 '17 at 07:30
  • Here is a sample app : https://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). – Stephane Mathis Jun 01 '17 at 11:42
  • Apparently it's also a bug caused by Xamarin Android 7.3 : https://github.com/reactiveui/ReactiveUI/issues/1379 – Stephane Mathis Jun 01 '17 at 13:05
  • @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](https://developer.xamarin.com/releases/android/xamarin.android_7/xamarin.android_7.3/#Known_Issues), you simply need to add an Environment.txt file with the value `MONO_GC_PARAMS=bridge-implementation=old` and it will work just fine. – Dan Siegel Jun 01 '17 at 16:20
  • 2020 and I'm having same issue with xamarin android, using master detail page. – Éder Rocha May 29 '20 at 01:31
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.

NikoR
  • 458
  • 2
  • 6