Bug 37587 - NullReferenceException in iOS.NavigationRenderer
Summary: NullReferenceException in iOS.NavigationRenderer
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS ()
Version: 2.0.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-01-11 19:56 UTC by alan.spires
Modified: 2017-08-22 09:34 UTC (History)
8 users (show)

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

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 NOT_REPRODUCIBLE

Description alan.spires 2016-01-11 19:56:26 UTC
I am consistently getting this error in the thousands and have no way to trap or diagnose it. 

  at Xamarin.Forms.Platform.iOS.NavigationRenderer+ParentingViewController.Dispose (Boolean disposing) <0x100accd70 + 0x00034> in <filename unknown>:0 
  at Foundation.NSObject.Dispose () <0x100b5de10 + 0x00023> in <filename unknown>:0 
  at Xamarin.Forms.Platform.iOS.NavigationRenderer+<>c__DisplayClass49_0+<<RemoveViewControllers>b__0>d.MoveNext () <0x100ad17b0 + 0x0023f> in <filename unknown>:0 

Occurring over 2000 times in the past 30 days. Any ways you could open up some ability to diagnose this?
Comment 1 aed 2016-06-06 19:44:31 UTC
I can repro this albeit more rarely:

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

Alan - did you find a fix?
Comment 2 alan.spires 2016-06-06 20:37:13 UTC
This problem seemed to just fade away with updates for me. Cheers.
Comment 3 adrianknight89 2016-09-29 05:13:56 UTC
Would have been great to see a repro.

Can you close the ticket if the issue no longer persists? Not sure if aed still has it.
Comment 4 Stephane Delcroix 2016-12-20 20:53:29 UTC
Could you please provide a simple reproduction case ?
Comment 5 sh.naz 2017-01-06 11:22:47 UTC
Same problem here. A periodically ocurring crash.
Comment 6 sh.naz 2017-03-23 16:00:38 UTC
@Stephane Delcroix

We have been experiencing this crash on daily basis, 2-3 crashes per day. We get the following stacktrace in HockeyApp very time. We are using XF 2.3.3.175. Please look at the source code, line 540 in ...iOS\NavigationRenderer.cs.

PS: RemoveXFSecondaryNavBar is a simple custom renderer which I use to set BarTextColor in OnElementChanged and nothing more.


System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'RemoveXFSecondaryNavBar'.
  at Foundation.NSObject.get_SuperHandle () [0x0004e] in /Users/builder/data/lanes/3988/e02d2723/source/xamarin-macios/src/Foundation/NSObject2.cs:423 
  at UIKit.UINavigationController.get_ViewControllers () [0x00030] in /Users/builder/data/lanes/3988/e02d2723/source/xamarin-macios/src/build/ios/native/UIKit/UINavigationController.g.cs:557 
  at Xamarin.Forms.Platform.iOS.NavigationRenderer+<>c__DisplayClass57_0+<<RemoveViewControllers>b__0>d.MoveNext () [0x00030] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:540
Comment 7 sh.naz 2017-05-24 07:34:25 UTC
Hey guys, I still have this issue with XF version 2.3.4.231. Same exception as above. (different code line number though)

It is this line in the source code:
https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs#L550
Comment 8 sh.naz 2017-06-09 06:26:48 UTC
Anyone???
Comment 10 Stephane Delcroix 2017-06-19 19:44:22 UTC
@sh.naz we are still waiting for a sample project triggering the issue.
Comment 12 sh.naz 2017-06-20 12:36:58 UTC
@Stephane Delcroix

Because it is a periodically occuring error, we have not yet been able to create a sample project which can be used to recreate the crash consistently.
Comment 13 sh.naz 2017-06-20 12:42:22 UTC
But the error occurs 3-4 times daily in our apps.
Comment 14 Paul DiPietro [MSFT] 2017-06-20 15:21:29 UTC
We are going to close this for the time being as not reproducible until we can receive a reproduction project. You are welcome to reopen this ticket when you are able to provide us with one for further investigation.
Comment 15 aed 2017-06-21 04:43:59 UTC
The crash occurs where sh.naz says it does. 

We also have two apps on the app store and this is the most frequent crash. It's very hard to repro locally.

XF team, can you just do a null check or a try/catch around that line, even if you don't have a repro. It looks like a synchronization issue.
Comment 16 Andriy Borysov 2017-08-22 09:34:19 UTC
The issue still happens sometimes in XF v2.3.4.267.

It looks like the actual line, that causes this exception is https://github.com/xamarin/Xamarin.Forms/blob/release-2.3.4-sr3/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs#L841 . As for me, it's very obvious place of a crash.