Bug 51733 - Fatal error when trying to instantiate a view controller from a storyboard. App quits and no error is given
Summary: Fatal error when trying to instantiate a view controller from a storyboard. A...
Status: RESOLVED INVALID
Alias: None
Product: iOS
Classification: Xamarin
Component: Debugger ()
Version: XI 10.4 (C9)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-01-24 14:21 UTC by Tom Harvey
Modified: 2017-03-13 03:49 UTC (History)
2 users (show)

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


Attachments
Environment details (85.29 KB, image/png)
2017-01-24 14:21 UTC, Tom Harvey
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 INVALID

Description Tom Harvey 2017-01-24 14:21:59 UTC
Created attachment 19459 [details]
Environment details

Very frustrating issue I've just had when making a large change, the app quits unexpectedly and debug session ended and there was no error in the console. Took a while to gradually trace what was causing the problem. Wasted about half an hour of my day.

Steps to reproduce
1. Add a storyboard called "Main" and then add following line of code anywhere in your app
UIStoryboard.FromName("Main", null).InstantiateViewController("SomeViewControllerWithNoStoryboardID")
2. Start simulator with the debugger attached and cause the above line of code to be executed

Expected behaviour
1. A useful error message with stack trace and line number. Either Debugger breaks on the "InstantiateViewController" line or just an error in the application log will do.

Actual behaviour
1. App exits and debug session quits with no error message given at all

Environment
Xamarin Studio Community on latest Alpha Channel 10.4.0.88
(Full details in screenshot)
Comment 1 Tom Harvey 2017-01-24 14:43:14 UTC
On a similar note, I also received exactly the same behaviour when I tried to create and instance of the a TableViewController that was designed on the storyboard like this.

NavigationController.PushViewController(new MyTableViewController(), true);

instead of:

var storyboard = UIStoryboard.FromName("Main", null);
var vc = storyboard.InstantiateViewController("MyTableViewController");
NavigationController.PushViewController(vc, true);

The App quit and debug session ended with no error message at all.

"MyTableViewController" had a header view with a label inside which obviously wasn't being initiated, however because there was no error message it was extremely difficult to spot the issue.
Comment 2 Vincent Dondain [MSFT] 2017-01-24 22:27:34 UTC
Hi Tom,

I can easily understand the frustration of not having an error or any indication to help pinpoint the problem.

In order to try to solve this issue I would need to be able to exactly reproduce what you experienced and I fail to do so.

If I follow the steps to reproduce in #comment1 you simply add a new storyboard (MyStoryboard.storyboard) and try to do:

UIStoryboard.FromName("MyStoryboard", null).InstantiateViewController("SomeViewControllerWithNoStoryboardID")

I get this exception:

https://www.dropbox.com/s/kxwlirxixq2psuv/Screenshot%202017-01-24%2012.45.48.png?dl=0

So I know I have to add a SomeViewControllerWithNoStoryboardID to the view controller (is the exception not showing up or I'm not doing the right thing?).

Also if my project includes a NavigationController just doing NavigationController.PushViewController (new UIViewController (), true); works.

Would it be possible for you to write a short test case with that showcase the issue you're experiencing so I (or any other iOS team member) can reproduce it?

Thanks.
Comment 3 Tom Harvey 2017-01-25 21:38:42 UTC
Got it! HockeySDK is causing the issue. Appreciate this may no longer the be appropriate place to log the issue.

Steps to reproduce
1. Place this code in AppDelegate FinishedLaunching
            var manager = BITHockeyManager.SharedHockeyManager;
			manager.Configure("37d9232914b841f387ec1f4ff35e9f52");	// random key to demonstrate issue
			manager.StartManager();
			manager.Authenticator.AuthenticateInstallation(); // This line is obsolete in crash only builds

            var storyboard = UIStoryboard.FromName("Main", null);
			var vc = storyboard.InstantiateViewController("SomeViewControllerWithNoStoryboardID");

Additional example where it was happening to me:
1. I had a line of code like this
            NSBundle.MainBundle.LoadNib("TestView", null, null);
There error was hidden but when I disable HockeySDK I can see this:
Xamarin.iOS: Received unhandled ObjectiveC exception: NSUnknownKeyException [<NSObject 0x6000008092d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key View
Comment 4 Tom Harvey 2017-02-02 10:12:57 UTC
Hi what is the status if this issue now? I see the status is NEEDINFO. Is there anything else you need from me?
Comment 5 Vincent Dondain [MSFT] 2017-03-13 03:49:43 UTC
Ah indeed:

Adding

```
var manager = BITHockeyManager.SharedHockeyManager;
manager.Configure("37d9232914b841f387ec1f4ff35e9f52");
manager.StartManager();
manager.Authenticator.AuthenticateInstallation();
```

before

var storyboard = UIStoryboard.FromName ("Main", null);
var vc = storyboard.InstantiateViewController ("SomeViewControllerWithNoStoryboardID");

Captures the exception shown in the screenshot I pasted before:

"NSInvalidArgumentException Reason: Storyboard (<UIStoryboard: 0x608000266200>) doesn't contain a view controller with identifier 'SomeViewControllerWithNoStoryboardID'"

This issue is only related to the Hockey App SDK and not to the Xamarin.iOS debugger as the exception is indeed shown in normal circumstances.

Seems Hockey App is capturing exceptions (for reporting of course) but I wonder why it's still not shown in the IDE. I will follow up on Monday to know more about this behavior and potentially open a bug against Hockey App at the proper location.

Closing this as invalid.