Bug 37832 - App Crashes with TabbedPage on "second tap go to root controller" event
Summary: App Crashes with TabbedPage on "second tap go to root controller" event
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS ()
Version: 2.0.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL: http://agileapp.co
Depends on:
Blocks:
 
Reported: 2016-01-20 11:40 UTC by alex@agileapp.co
Modified: 2016-12-21 20:01 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Repro project (216.56 KB, application/x-zip-compressed)
2016-12-21 20:00 UTC, E.Z. Hart [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description alex@agileapp.co 2016-01-20 11:40:15 UTC
Hi there

I can give fairly detailed repro steps for this but it happens when using a Xamarin Forms TabbedPage with each tab bar item root page being a navigation page. 

The error received is 
System.NullReferenceExceptionObject reference not set to an instance of an object
Xamarin.Forms.Platform.iOS.NavigationRenderer.ParentingViewController.Dispose(bool disposing)
Foundation.NSObject.Dispose()NSObject2.cs:130
at Xamarin.Forms.Platform.iOS.NavigationRenderer+<>c__DisplayClass49_0+<<RemoveViewControllers>b__0>d.MoveNext () [0x00105] in <filename unknown>:0

To reproduce create a project with a tabbed page with approx 5 view controllers each of which being a navigationpage. Run the app and click quickly between tabs going backwards and forwards between tabs. I believe that when the "Second" tap on one tab bar item is triggered which usually pops to the root viewcontroller this is where the crash happens. 

This happens both in the simulator and on ios devices.
Comment 1 khentyimentu 2016-02-09 14:13:31 UTC
I observe the same behavior with Xamarin.Forms version 2.0.1.6505. I randomly click on the tab buttons until i get:

System.NullReferenceException: Object reference not set to an instance of an object
  at Xamarin.Forms.Platform.iOS.Platform.GetRenderer (Xamarin.Forms.VisualElement bindable) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.NavigationRenderer.GetAppearedOrDisappearedTask (Xamarin.Forms.Page page) [0x00011] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.NavigationRenderer.RemoveViewControllers (Boolean animated) [0x00048] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.NavigationRenderer.PopToRootViewController (Boolean animated) [0x00008] in <filename unknown>:0
  at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Users/builder/data/lanes/2689/962a0506/source/maccore/src/UIKit/UIApplication.cs:77
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/2689/962a0506/source/maccore/src/UIKit/UIApplication.cs:61
  at TabbedNavigationNullReference.iOS.Application.Main (System.String[] args) [0x00008] in /Users/kahva/projects/TabbedNavigationNullReference/iOS/Main.cs:17

My application is as simple as:

using System;

using Xamarin.Forms;

namespace TabbedNavigationNullReference
{
  public class App : Application
  {
    public App ()
    {
      MainPage = new TabbedPage {
        Children = {
          new NavigationPage (new ContentPage { Content = new ListView () }) { Title = "One" },
          new NavigationPage (new ContentPage { Content = new ListView () }) { Title = "Two" },
          new NavigationPage (new ContentPage { Content = new ListView () }) { Title = "Three" },
          new NavigationPage (new ContentPage { Content = new ListView () }) { Title = "Four" },
          new NavigationPage (new ContentPage { Content = new ListView () }) { Title = "Five" }
        }
      };
    }
  }
}
Comment 2 khentyimentu 2016-02-09 14:27:12 UTC
The aforementioned app worked fine with Xamarin.Forms 1.3.5.
Comment 3 alex@agileapp.co 2016-02-09 14:53:18 UTC
khenty, I have also found the same bug listed here https://bugzilla.xamarin.com/show_bug.cgi?id=37873

and the response is that it "should" be fixed in version 2.1.0.

I don't know when that is due for release but it seems like a fairly fundamental issue with Xamarin forms as it inhibits the entire navigation structure to work in this manner. Tabs and navigation pages must be incredibly common. 

Alex
Comment 4 Fulvio 2016-02-26 03:57:00 UTC
We're now experiencing this with Xamarin.Forms 2.0.1.6505.

Has this been resolved?
Comment 5 Hiran Peiris 2016-06-01 09:13:32 UTC
This is happening in 2.2.0.45 also.
Xamarin team please fix this Asap
Comment 6 alex@agileapp.co 2016-06-01 11:23:53 UTC
Hi Hiran

I believe it got fixed in 2.3

Alex
Comment 7 alex@agileapp.co 2016-06-01 11:25:32 UTC
Second thoughts, I meant 2.1 so not sure on 2.2.0.45 perhaps its broken again!
Comment 8 aed 2016-06-06 19:43:35 UTC
Repro x3 on XF2.2.0.45:

System.NullReferenceExceptionObject reference not set to an instance of an object
Xamarin.Forms.Platform.iOS.NavigationRenderer.ParentingViewController.Dispose(bool disposing)
Foundation.NSObject.Dispose()
at Xamarin.Forms.Platform.iOS.NavigationRenderer+<>c__DisplayClass54_0+<<RemoveViewControllers>b__0>d.MoveNext () <0x100b62bdc + 0x00157> in <filename unknown>:0
Comment 9 adrianknight89 2016-11-21 02:50:01 UTC
If this is fixed, can you close the bug? I tested it on latest master and wasn't able to reproduce the issue.
Comment 10 E.Z. Hart [MSFT] 2016-12-21 20:00:56 UTC
Created attachment 18965 [details]
Repro project

I can repro this with 2.1, but with 2.2 and above I've not been able to make the crash happen.