Bug 29971 - Used Xcode for Storyboard, caused crash in Xamarin iOS Designer
Summary: Used Xcode for Storyboard, caused crash in Xamarin iOS Designer
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: General ()
Version: 5.9
Hardware: PC Mac OS
: Normal critical
Target Milestone: 5.10 (C6)
Assignee: Bugzilla
Depends on:
Reported: 2015-05-12 09:51 UTC by Kevin.Murray
Modified: 2015-07-14 09:34 UTC (History)
5 users (show)

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

The storyboard with error shown. (147.16 KB, image/png)
2015-05-12 09:51 UTC, Kevin.Murray
Designer log file showing the unexpected application end. (643.37 KB, application/octet-stream)
2015-05-12 09:51 UTC, Kevin.Murray
IDE log file (15.90 KB, application/octet-stream)
2015-05-12 15:24 UTC, Kevin.Murray
Another log. (11.71 KB, application/octet-stream)
2015-05-12 15:30 UTC, Kevin.Murray

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:

Description Kevin.Murray 2015-05-12 09:51:23 UTC
Created attachment 11164 [details]
The storyboard with error shown.

I created an iOS unified single view application in Xamarin Studio for the Mac.  I then told Xamarin to open the Main.storyboard in the Xcode Interface Designer.  I set up my storyboard there (it was a single View Controller with two views attached, nothing overly complicated).  When I saved it and went back to Xamarin Studio, I double clicked the storyboard file to open it in the Xamarin iOS Designer.  It opened, but showed an exclamation point.  I clicked the exclamation point and an error window popped up.  However, clicking into that error window crashed Xamarin Studio.

I did figure out the problem with the storyboard by loading it in Xcode again -- it turns out Xcode issued a warning that one of the UI elements had two conflicting constraints.  I corrected the problem, and the storyboard loads without issue in Xamarin now.  Unfortunately, I haven't been able to recreate the bad storyboard, but I have included a screenshot of the error window, and a log from the iOS Designer.
Comment 1 Kevin.Murray 2015-05-12 09:51:58 UTC
Created attachment 11165 [details]
Designer log file showing the unexpected application end.
Comment 2 Alan McGovern 2015-05-12 15:14:52 UTC
Can you include the Ide.*.log file? That's Xamarin Studio's one and that will contain the excpetion details for why Xamarin Studio crashed. The log you attached is just for our renderer and so does not have the information we need.
Comment 3 Kevin.Murray 2015-05-12 15:24:17 UTC
Created attachment 11175 [details]
IDE log file
Comment 4 Alan McGovern 2015-05-12 15:28:18 UTC
That log file looks like it's from a session where xamarin studio gracefully exited.  The last line in the log is 'INFO [2015-05-11 13:38:01Z]: IPhoneDesignerSdkManager: Shutting down the designer service' which is only printed when the normal shutdown sequence is executed.

Are you sure this log is from the session where xamarin studio crashed? I'm still trying to reproduce the problem, but that stacktrace would be invaluable.
Comment 5 Kevin.Murray 2015-05-12 15:30:45 UTC
Created attachment 11176 [details]
Another log.

Sorry, was one timestamp off...this one ends in a Object Reference Not Set To An Instance Of An Object exception...
Comment 6 Alan McGovern 2015-05-12 19:36:20 UTC
Perfect, that definitely looks like the issue. The relevant part is:

System.NullReferenceException: Object reference not set to an instance of an object
  at Xwt.Mac.CompositeCell.Fill () [0x0008a] in /Users/builder/data/lanes/1494/75607267/source/monodevelop/main/external/xwt/Xwt.Mac/Xwt.Mac.CellViews/CompositeCell.cs:145 
  at Xwt.Mac.CompositeCell.set_ObjectValue (Foundation.NSObject value) [0x0006b] in /Users/builder/data/lanes/1494/75607267/source/monodevelop/main/external/xwt/Xwt.Mac/Xwt.Mac.CellViews/CompositeCell.cs:116 
  at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSendSuper_IntPtr (intptr,intptr,intptr)
  at AppKit.NSControl.MouseDown (AppKit.NSEvent theEvent) [0x00000] in <filename unknown>:0 
  at Xwt.Mac.NSTableViewBackend.MouseDown (AppKit.NSEvent theEvent) [0x00010] in /Users/builder/data/lanes/1494/75607267/source/monodevelop/main/external/xwt/Xwt.Mac/Xwt.Mac/NSTableViewBackend.cs:94 
  at (wrapper managed-to-native) Gtk.Application:gtk_main ()
Comment 7 Alan McGovern 2015-07-14 07:15:54 UTC
I matched the line numbers using the xwt hash shipped in that build and the NullReference is because the `source` field is null.

By the looks of the code, this should never happen. There is an IntPtr constructor here which would mask a reference counting/GC issue where the Cells are garbage collected early. If that constructor ever ran, it means our C# class was GC'ed and a new one was created. If that happens then `source` would be null and we'd crash as shown in this stacktrace.
Comment 9 Alan McGovern 2015-07-14 07:31:47 UTC
I don't think this crash originated in designer code. I can't seem to find anywhere where we cause a CompositeCell to be created, so it's likely to be triggered by something in XS itself.
Comment 10 Alan McGovern 2015-07-14 09:34:33 UTC
Ah, i triggered something using our code! I had a bit of a chat with Rolf. The issue is reminiscent of the bug fixed by xamarin.mac commit d762a2202ef87fa8407da5b92444dd4e144485ba.

I added logging to Xwt to rule out a bug in Xwt itself, so if we reproduce this issue with XS builds containing commit https://github.com/mono/xwt/commit/19abd928a3c885073422821ffc62f66c24dc4f74 then we'll need to investigate further.

I'm resolving this as it's not reproducible and there's nothing further we can do with it until we get a report of the crash from a build with that xwt commit.