xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.46k stars 511 forks source link

iOS Designer will not open storyboards #3156

Closed danbridgellc closed 6 years ago

danbridgellc commented 6 years ago

Steps to Reproduce

  1. Create new iOS app (I used Page Based App)
  2. Attempt to open Main.storyboard

Expected Behavior

iOS Designer should open storyboard with ability to modify

Actual Behavior

Connects to Mac and then the progress bar just continues to cycle

Environment

I have also tried the stable release 15.5 with same results... currently using preview - see below...

1.Microsoft Visual Studio Enterprise 2017 Preview
Version 15.6.0 Preview 1.1
VisualStudio.15.Preview/15.6.0-pre.1.1+27205.2004
Microsoft .NET Framework
Version 4.7.02046

Installed Version: Enterprise

Visual F# 4.1   00369-90000-00000-AA740
Microsoft Visual F# 4.1

Application Insights Tools for Visual Studio Package   8.10.01106.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017   15.0.31128.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services   1.0
Provides languages services for ASP.NET Core Razor.

Azure App Service Tools v3.0.0   15.0.31121.0
Azure App Service Tools v3.0.0

C# Tools   2.6.0-beta3-62405-07. Commit Hash: 4939752b756ad32cb2ce1bfeab1d4f1637966e08
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

JavaScript Language Service   2.0
JavaScript Language Service

Merq   1.1.17-rc (cba4571)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Continuous Delivery Tools for Visual Studio   0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Mono Debugging for Visual Studio   4.8.4-pre (3fe64e3)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   4.5.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

SQL Server Data Tools   15.1.61710.120
Microsoft SQL Server Data Tools

TypeScript Tools   15.5.11025.1
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   2.6.0-beta3-62405-07. Commit Hash: 4939752b756ad32cb2ce1bfeab1d4f1637966e08
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

Xamarin   4.8.0.753 (6575bd113)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   4.8.188 (c5813fa34)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin.Android SDK   8.1.0.25 (HEAD/d8c6e504f)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   11.6.1.2 (6857dfc)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Build Logs

iOSDesigner-2018-01-03__20-35-43.234584.log

Example Project (If Possible)

App1.zip

dalexsoto commented 6 years ago

@alanmcgovern FYI!

danbridgellc commented 6 years ago

Sorry, can you clarify what Future milestone means? I am dead in the water right now on development due to this issue...based on the logs, do you believe it is a bug or would a complete reinstall fix? Are others having this issue?

dalexsoto commented 6 years ago

@danbridgellc I understand, I already notified @alanmcgovern who is the one can give you a more accurate answer on the timeline/workarounds for this issue.

alanmcgovern commented 6 years ago

Hi,

We have an internal task to improve the discoverability of these kinds of errors, but the problem here is that the C# classes being instantiated from your project are throwing exceptions during rendering, and those exceptions are corrupting the iOS runtime and crashing our rendering process.

We should be falling back to 'safe mode' automatically which causes us to skip these controls and replace them with a placeholder, but it looks like this particular kind of crash is not being caught by our heuristics. We'll investigate that.

In the meantime, if you open the log file and search for NullReferenceException you'll see several controls which are causing issues. If you can fix the null reference exception when in design time mode then you should bypass the issue. The two ones in this log are:

System.NullReferenceException: Object reference not set to an instance of an object
[2018-01-03 20:37:49.7] INFO:   at danbridge.iOS.Views.DbxDigitalLabel.set_TextColor (UIKit.UIColor value) [0x00027] in
[2018-01-03 20:37:50.0] INFO: System.NullReferenceException: Object reference not set to an instance of an object
[2018-01-03 20:37:50.0] INFO:   at Syncfusion.SfChart.iOS.SFChart.UpdateChart () [0x00076] in <ee9ef4a01ed947e3a8bf983f99a75918>:0 
[2018-01-03 20:37:50.0] INFO:   at Syncfusion.SfChart.iOS.SFChart.LayoutSubviews () [0x00006] in <ee9ef4a01ed947e3a8bf983f99a75918>:0 
danbridgellc commented 6 years ago

Thanks for the responses...I suspected as much regarding something in my code and I even fixed the DbxDigitalLablel already...the code in the Syncfusion chart component I can not address so I will have to contact them on that piece. All this said - the odd thing here is that neither of these components are being used by the sample project I attached to this issue. I started a clean project and tried to open an empty storyboard and that produced the log I attached. So am I missing something here - did I not get clean logs or is an empty storyboard somehow attempting to load "previously used" controls?

danbridgellc commented 6 years ago

I cleaned up the logs and then attempted to open an empty storyboard...at this point the only null ref error is the Syncfusion.SfChart component. So since it seems to be hitting this when opening an empty storyboard, I assume this is due to it loading that component for the Toolbox possibly?? How do I control which components are loaded by the designer? Is there anyway to have a reference to the library (syncfusion in this case) and it not load by the designer since I am not using the chart component specifically in a storyboard (I am using it in code)?

alanmcgovern commented 6 years ago

If you have a custom control ( https://developer.xamarin.com/guides/ios/user_interface/designer/ios_designable_controls_walkthrough/ ) and that custom control instantiates and uses the chart control internally, then you would have to adjust your code to not create that control when running inside the design time context.

We did have an issue where we did not correctly respect the DesignTimeVisible attribute, but that should've been addressed as part of the latest 15.5.x releases. The associated bug for that was https://bugzilla.xamarin.com/show_bug.cgi?id=58803. If your build does not contain that patch then that could explain why you're seeing this issue. Do double check that you're on the latest stable release.

danbridgellc commented 6 years ago

My comment about creating the chart in code was referring to my actual project that is having the same issue as this sample project - sorry if I caused confusion. I will stick to this sample project for now!

So no sir I do not have a custom control that uses the chart internally...I have a brand new project that I did not write one line of code in...when I attempt to open the Main.Storyboard it fails with the log I attached. The sample project is also attached to this issue.

Can you help me understand how the iOS designer determines which controls to attempt to load? Is it based on them being referenced? Does VS have settings that hold this list based on them meeting the Custom Control requirements? I ask because as I state - this is an brand new project and I have not added any references nor any code.

therealjohn commented 6 years ago

@danbridgellc

Would you also re-upload a new log from the issue when you open the sample project? You might want to delete existing logs to make sure you have the correct one. The timestamps in the log should match the time you are testing it. The sample opens fine for me. However, I don't have any SFChart things installed.

alanmcgovern commented 6 years ago

The logic is (essentially) to request the list of assemblies from MSBuild after it processes/loads the project files contained in your solution. It would be curious if we were consistently getting the chart control in the list when your project, or any project it transitively references, does not reference it. It would imply there's some system level setting which is unexpectedly adding the reference.

One possible cause of that happening is the Directory.Build.props and Directory.Build.targets support with modern MSBuild. Perhaps those files exist somewhere in your checkout/computer and they are causing the reference to be added.

danbridgellc commented 6 years ago

Thank you both for responses, sorry for delay on my end...I worked on this over the weekend and here is what I found...

  1. Launched VS
  2. Cleaned up the logs
  3. Opened my "real" project with ref to SfChart and attempted to open empty storyboard - failed as expected
  4. Closed solution
  5. Cleaned up the logs
  6. Opened sample App1 project without ref to SfChart - still failed on SfChart

So that got me thinking - I closed out of VS completely and then...

  1. Opened sample App1 project without ref to SfChart - it worked fine!

So it looks like VS or the designer is holding on to a reference once loaded??

Finally, I logged a ticket with Syncfusion over the past weekend and they provided me an updated version with a fix on Monday - quick turn!

So now that I understand how this all works I should be able to troubleshoot better in the future.

Thanks for all the help - this issue can be closed.