Bug 58803 - MonoTouchDesignServerUnified quit unexpectedly popup
Summary: MonoTouchDesignServerUnified quit unexpectedly popup
Status: NEEDINFO
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: iOS Designer (show other bugs)
Version: 7.1 (d15-3)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: master
Assignee: Bugzilla
URL:
Depends on: 58226
Blocks:
  Show dependency tree
 
Reported: 2017-08-16 09:15 UTC by Marco Burato
Modified: 2017-10-13 02:44 UTC (History)
11 users (show)

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


Attachments
Popup (40.63 KB, image/png)
2017-08-16 09:15 UTC, Marco Burato
Details
Banner (13.79 KB, image/png)
2017-08-16 09:15 UTC, Marco Burato
Details
Logs (195.18 KB, application/zip)
2017-08-16 09:52 UTC, Valentin Denis
Details
Logs (57.64 KB, application/zip)
2017-08-16 10:18 UTC, Marco Burato
Details
Logs 2 (63.05 KB, application/zip)
2017-08-16 10:41 UTC, Marco Burato
Details
logs_deniz (2.36 MB, text/plain)
2017-10-11 16:05 UTC, Deniz Haciali
Details

Description Marco Burato 2017-08-16 09:15:35 UTC
Created attachment 24224 [details]
Popup

After upgrading VSmac to 7.1.0.1297 (the version bundled with Xamarin 15.3), when opening a storyboard I get:
- a popup that says "MonoTouchDesignServerUnified quit unexpectedly"
- a banner is shown in the designer, which says "Custom components are not being rendered because problems were detected"

This happens every time. Clicking the "try again" button repeats the error, as well as opening other storyboards.
Comment 1 Marco Burato 2017-08-16 09:15:58 UTC
Created attachment 24225 [details]
Banner
Comment 2 Alan McGovern 2017-08-16 09:22:22 UTC
Can you attach the log files generated from the session where the error occurred? You can find the logs by clicking Help -> Open Log Directory. If you delete everything there, then reproduce the problem, then attach the full set of log files (there'll be 4 or 5 files) that would be great!
Comment 3 Valentin Denis 2017-08-16 09:52:35 UTC
Created attachment 24226 [details]
Logs

I got the same issue, Here are my logs from the designer (my other logs are empty)
Comment 4 Marco Burato 2017-08-16 10:18:47 UTC
Created attachment 24227 [details]
Logs

These are my log files.

I don't know if it's related or not, but I see a NullReferenceException invoking my code in the code-behind. Why does the designer try to call that code? It will obviously not work because other app-level things need to be initialised.
Comment 5 Marco Burato 2017-08-16 10:41:52 UTC
Created attachment 24230 [details]
Logs 2

So, as an experiment, I've changed my code to avoid that NullReferenceException and it helps. I don't get the popup anymore, although one view controller in the storyboard is all red (doesn't load correctly).

However, I've tried another storyboard and I get again that popup. The log shows a different problem now (SIGSEGV). Please see attachment.
Comment 6 Alan McGovern 2017-08-16 12:49:27 UTC
@Valentin
This is a known issue we addressed several weeks ago but could not include the fix in the final 15.3 release.

The workaround for what you're experiencing is to open the storyboard file as text and remove the `device` element from the top of the storyboard. It typically looks something like:
    <device id="retina4_0" orientation="portrait">
        <adaptation id="fullscreen"/>
    </device>
If you have further issues can you file a new bug report so we can use this report to deal exclusively with Marco's issue. Thanks!

@Marco,
In the first set of logs we can see that your code threw an exception asynchronously when iOS invoked the ViewDidAppear method. We can apply a further mitigation which should prevent the crash dialog from appearing in cases like this. However as the exception is asynchronous we have no easy way to capture it and propagate that information back to the IDE.

That said, the second set of logs is very interesting. It looks like an a native crash is occurring when invoking standard iOS functions, which is bizarre. It's possible this is related to a custom control too as the issue looks like it went away when the designer automatically disabled custom control support. Would you be able to privately share a copy of your project so we can reproduce and diagnose the issue locally?

A direct email to me would be fine, or we can create a new private bug in bugzilla so you can attach it there. Let me know which option is preferable if you are able to share it.
Comment 7 Marco Burato 2017-08-16 13:37:18 UTC
@Alan:

Regarding the first problem, I'm not sure why you say it's an "asynchronous" exception, to me it looks a normal exception thrown while executing the call to ViewDidDisappear. Anyway, my question is: why does the designer run that method at all?
Also, as far as I can tell, this didn't happen in previous versions of XS/VS and wouldn't happen in Interface Builder if coding the app in ObjC/Swift.

Regarding the second problem, I can't share the full project but I'll try to make you a test project with just the Storyboard, so you can reproduce.
Comment 8 Alan McGovern 2017-08-16 13:46:52 UTC
iOS itself is invoking this method some time after the view is made visible. The designer itself is not involved in this particular method invocation, which is why we cannot catch it and report it like we can for exceptions thrown inside `LoadView` or inside constructors.

>  at EviApp.DataLogRecordNewViewController.StopLogging () [0x0000d] in /Users/marco/Desktop/EviApp_dashboard/EviApp-ios/UI/DataLogRecordNewViewController.cs:180 
>  at EviApp.DataLogRecordNewViewController.ViewDidDisappear (System.Boolean animated) [0x0000f] in /Users/marco/Desktop/EviApp_dashboard/EviApp-ios/UI/DataLogRecordNewViewController.cs:79 
>  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)

It would also happen in Xcode if you had written a custom control which Xcode was able to load (  https://developer.apple.com/library/content/referencelibrary/GettingStarted/DevelopiOSAppsSwift/ImplementingACustomControl.html ).

If the iOS designer disabled custom control loading then the issue would also not occur, but things would not render as accurately.
Comment 9 Doug Shontz 2017-08-16 16:31:40 UTC
If it will help anyone, we hit this problem this morning as well after an update to 15.3.  We tried removing the <device> node but that made no difference.  What did make a difference, however, was simply re-cloning the project from Github to get an "unbuilt" version of the project and then cleaning and rebuilding that.

My assumption from our logs is that the problem existed somewhere in the designer files and the clean/rebuild from a fresh project fixed that.
Comment 12 Bert Degenhart Drenth 2017-08-26 08:51:06 UTC
I experience the same problem.
It is very frustrating and makes "normal" work almost impossible.
Sometimes the designer crashes and sometimes a restart let's me continue to work.
Another possible related issues is that the loading of the storyboard is extremely slow. I took a look at the log files, but they are so big and don't make much sense to me. Besides that, I think resolving this issue is a case for Microsoft/Xamarin and I should concentrate on my own work: building apps efficiently using Visual Studio instead of trying to find the root cause of a designer crash.
Comment 13 Kraig Spear 2017-08-26 22:45:21 UTC
Happens with this storyboard 

https://1drv.ms/u/s!Av_yP9VT72Vi-jU8I82JNLdvDJFb

No custom components.
Comment 14 Alan McGovern 2017-08-28 11:06:03 UTC
Kraig, Bert, Doug: if you are experiencing issues could you attach the log files from a session where you triggered the error?

So far the only confirmed issue is the mis-handling of the `device` element in the xml which has been addressed.

Secondly, we do have a mitigation in place to ensure the macOS crash report dialog doesn't appear when the rendering processes encounters an error. This mitigation did not work in all cases, but we've enhanced that so it works in more cases. That will ship in a future release.

However the underlying cause of the issue could simply be user-code throwing asynchronous exceptions like I described in comment 8.
Comment 15 Marco Burato 2017-08-29 06:59:15 UTC
@Alan, I had sent you an email on Aug 16th but never got a reply, so maybe it was flagged as spam?

Here's the email:

****

Hi Alan,

I've tried to create a project which replicates a segfault but haven't managed to.
I've successfully created one that replicates the exception in ViewDidDisappear though. Since I had to copy all the storyboards, if you need the project, I need to ask permission to my manager first.

Now, what I can say is that after working around that NullReferenceException, I'm getting all sorts of segfaults and other errors in many storyboards.
Please see the attached logs and screenshots.
I feel like something's wrong here, I wonder if there's some memory corruption or threading issue.

Going back to the exception on ViewDidDisappear, please let me point out a few things.
I agree that a Custom View needs its code executed to render properly. Views are independent building blocks used in the UI and can be instantiated independently from the rest of the app, so there's no problem with that.
View Controllers, however, are the glue between the Views and the business logic. They will almost always need other things in the app to have already been setup (ie. a "login" view-controller might want to prepopulate the username in a textbox and that username must have already been loaded along with other settings from an XML file when the app is launched).

I understand you're not invoking ViewDidDisappear in your code, but even iOS/UIKit/xxx shouldn't be calling it either, unless the view controller is actually being presented.
Other things that make me think something iffy is going on:
- if I create a brand new iOS single-page project in VSmac and add exceptions to ViewWillAppear/ViewWillDisappear, it does NOT cause any problems in the iOS Designer, so they don't get called
- in my project the ViewDidDisappear method gets called regardless if the storyboard I'm trying to open contains that view controller or not


Best regards,

*****

Please let me know if you want that storyboards-only project to investigate.
I'm attaching Logs and screenshots privately.
Comment 16 Marco Burato 2017-08-29 07:02:10 UTC
Uhm... apparently I can't add private comments/attachments, so please let me know how to pass them to you if you can't find the email.
Comment 17 xamarin-release-manager 2017-09-05 19:04:05 UTC
Fixed in version 7.2.0.583 (d15-4)

Author: Alan McGovern
Commit: bc1ccf4001b185bc517287e6d378d66d56c18c40 (xamarin/md-addins)
Included in Commit: 861d3eb8f64655762b85235dde49874645208f51 (mono/monodevelop)
Comment 18 Alan McGovern 2017-09-05 22:41:57 UTC
Sorry - that was our bug auto-closer being a little pro-active as we landed a workaround for one aspect of this.

The simplest way to attach a private comment/attachment would be to create a new bug report and click the `Xamarin Team (Private Bug)` checkbox before submitting it. You'll be free to attach private things to the report then.

I did find your email - it had been flagged as potential spam alright. I reviewed the log files and it looks like there's a crash occuring within iOS itself. To diagnose that we would need a testcase which reproduces the issue. I don't know if your storyboard alone would be sufficient for that, or if a full compilable copy of the project would be needed. You could check if the storyboard file alone is enough by adding it to a new project and seeing if you can trigger the same failure case.

The interesting part of the log are the places where you see this string `critical: Stacktrace` and also `Native stacktrace:`. It's possible this is fallout from another error, but unfortunately nothing shows up in the logs.
Comment 19 Marco Burato 2017-09-06 13:56:47 UTC
I've just double-checked and the storyboard-only project will only reproduce the issue with Exceptions thrown in ViewDidDisappear() and similar. There are no other sorts of crashes.

Unfortunately, I can't share the full project.
Comment 20 Marco Burato 2017-09-29 12:24:36 UTC
Until this issue is fixed I can't upgrade VSmac and today I've discovered 7.0 won't work with Xcode 9, so I can't upgrade that either.

Is there any way to prepare a test case with precompiled source plus the storyboard files?
Comment 21 Alan McGovern 2017-10-02 11:16:41 UTC
If you want to supply a pre-compiled test case I believe this should work:

0) Create a copy of your project locally so you can safely delete files without affecting your actual work.
1) Compile the project.
2) Delete the `.git` directory (or whatever metadata your version control system might store inside your checkout).
3) Delete all the .cs files from the directory.
4) Delete any other files which are proprietary/secret.
5) Zip up the directory structure.

Now unzip that file to another location, open the sln/csporj in the IDE and attempt to reproduce the problem. If you can still reproduce the issue then we should also be able to reproduce it using the same zip file. That should be all we need to diagnose/fix the issue. The zip is likely to be quite large but there's no easy way to trim down the binaries without increasing the chance of masking/hiding the root of the problem.

This is not a private bug so it'd be best to send the attachment directly.

Thanks!
Comment 22 Marco Burato 2017-10-02 15:49:07 UTC
That worked! I've also removed the other projects to keep the ZIP a bit smaller. Still quite big but manageable.

I've sent you a download link via email.
Comment 23 Marco Burato 2017-10-10 08:20:16 UTC
Alan, I've sent you a 2nd test project and another email but got no reply so I think they might have been marked as spam like it happened before. Could you kindly confirm you've received those emails?
Comment 24 Deniz Haciali 2017-10-11 16:04:05 UTC
Hi all,

we are suffering from the same issue after upgrading to Visual Studio Community 2017 for Mac Version 7.2 (build 636). 

When I clean the solution, I dont get any error. I took a look to the logs file attahced by @marco and @denis and it seems like the root cause for us is different, however I did not want to file anotrher one since we get the same error. The log file is attached.
Comment 25 Deniz Haciali 2017-10-11 16:05:09 UTC
Created attachment 25274 [details]
logs_deniz

Note You need to log in before you can comment on or make changes to this bug.