Bug 61052 - iOS designer unusably slow / Custom components are not being rendered because problems were detected
Summary: iOS designer unusably slow / Custom components are not being rendered because...
Status: NEEDINFO
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS Designer ()
Version: 4.8.0 (15.5)
Hardware: PC Mac OS
: Normal normal
Target Milestone: Future Cycle
Assignee: Pavel Yakovlev
URL:
Depends on:
Blocks:
 
Reported: 2017-12-08 16:02 UTC by Elte Hupkes
Modified: 2018-04-02 13:17 UTC (History)
6 users (show)

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


Attachments
Log file after a "Custom components are not being rendered...." (1.06 MB, text/plain)
2017-12-08 16:02 UTC, Elte Hupkes
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 for Bug 61052 on Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.
Related Links:
Status:
NEEDINFO

Description Elte Hupkes 2017-12-08 16:02:36 UTC
Created attachment 25956 [details]
Log file after a "Custom components are not being rendered...."

Since upgrading to Visual Studio for Mac 7.3 at the start of this week I've been unable to work with any of my storyboards. Most of the time, opening a storyboard file results in a "Custom components were not being rendered because problems were detected" error at the top of the screen after about a minute of attempted loading. Occasionally, or if I press "try again" often enough, the storyboard will load, but doing pretty much anything takes forever and will usually result in the same error again.

Originally I naively upgraded Xcode, which of course made the problem go away because now I couldn't open storyboards at all anymore (Xcode is too new!). Having upgraded to the latest version with Xcode 9.2 support today, the problem persists.

I've attached a one of the logs that opens after clicking the "Open log" button in the "Custom components..." error.

The project builds and runs just fine. If I create a new Xamarin.iOS project, I do not seem to have the same problems, not even if I add the same NuGet packages to it.  Before 15.5 / 7.3 I did not have this problem. Basically I'm out of ideas, so I hope you guys can help me gain some insight in what change caused this and what can be done about it on either Xamarin's side or my side so I can continue development on our iOS app.
Comment 1 Elte Hupkes 2017-12-13 10:42:21 UTC
After a tedious elimination process I found a NuGet package that, when present, causes the designer to be very slow. The package in question is `TagListView` (https://www.nuget.org/packages/TagListView), from my debugging efforts it seems that it is doing something illegal in one of the custom views' `Dispose(bool)` method, perhaps causing the designer backend to crash and reinitialize. This might explain why the process sometimes does work, it's potentially trying to dispose managed resources which have already been disposed depending on the order in which GC is doing this.

Although this is a coding error in a custom component, previously this was apparently handled more gracefully, and I'd expect at leats some information on what is misbehaving so it doesn't take a full day to debug.
Comment 2 John Miller [MSFT] 2018-01-30 14:37:59 UTC
Hi Elte,

Thanks for following up with the additional information on TagListView. I am able to reproduce some odd behavior after adding that NuGet package and trying to use TagListView in the designer. 

## Steps To Reproduce

1. Create a single view iOS app
2. Add the TagListView NuGet to the iOS app project
3. Opent the storyboard in the designer and find the TagListView in the toolbox
4. Drag this onto the default view
5. Drag a TagButton onto the TagListView

## Actual Results

After step #4, the designer becomes noticeably slower to use and the loading indicator appears after any adjustment of the TagListView frame. 
After step #5, I get some warnings that custom components are not being rendered. Attached is the log that banner allows me to open.

## Expected Results

The designer performance should not degrade to a crawl because of a bad custom component. It should instead disable it gracefully and explain why clearly.  

## Version Info

I tested this with VSMac and experienced the same issue so It does not appear to be specific to XVS.

=== Visual Studio Enterprise 2017 for Mac (Preview) ===

Version 7.5 Preview (7.5 build 250)
Installation UUID: b968d862-551c-4a33-ab4e-9666400e357c
Runtime:
	Mono 5.8.0.108 (2017-10/9aa78573ee2) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 508000108

=== NuGet ===

Version: 4.3.1.4445

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Version: 2.0.0-preview2-25407-01
SDK: /usr/local/share/dotnet/sdk/2.0.0-preview2-006497/Sdks
SDK Version: 2.0.0-preview2-006497
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.8.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.1
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Version: 8.2.0.6 (Visual Studio Enterprise)
Android SDK: /Users/johnmiller/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		7.0 (API level 24)
		7.1 (API level 25)
		8.0 (API level 26)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 26.0.0
SDK Build Tools Version: 26.0.2

Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Apple Developer Tools ===

Xcode 9.2 (13772)
Build 9C40b

=== Xamarin.Mac ===

Version: 4.2.0.8 (Visual Studio Enterprise)

=== Xamarin.iOS ===

Version: 11.8.0.8 (Visual Studio Enterprise)
Hash: eaff169d
Branch: d15-6
Build date: 2018-01-09 18:39:05-0500

=== Xamarin Inspector ===

Version: 1.4.0
Hash: b3f92f9
Branch: master
Build date: Fri, 19 Jan 2018 22:00:34 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 705000250
Git revision: 500eed91298a4dc298f244b6eb2078c67fc8f14e
Build date: 2018-01-26 06:12:03-05
Xamarin addins: 128cde428c7ad21426ac44d9685718a645937936
Build lane: monodevelop-lion-master

=== Operating System ===

Mac OS X 10.13.2
Darwin 17.3.0 Darwin Kernel Version 17.3.0
    Thu Nov  9 18:09:22 PST 2017
    root:xnu-4570.31.3~1/RELEASE_X86_64 x86_64
Comment 3 Pavel Yakovlev 2018-04-02 09:41:04 UTC
The problem is in the `XplatSolutions.TagButton` component in the `Dispose` method.
It causes the server side to throw unhandled exception when the ToolBox is rendered. This error in this custom component stably terminates the server.
The designer has to start a new server instance every time and render Toolbox. It takes about 4+ seconds.

-=[ LOG ]=-

UIKit.UIKitThreadAccessException: UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread.
  at UIKit.UIApplication.EnsureUIThread () [0x00020] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.11.0.56/src/Xamarin.iOS/UIKit/UIApplication.cs:89 
  at UIKit.UIView.RemoveGestureRecognizer (UIKit.UIGestureRecognizer gestureRecognizer) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.11.0.56/src/Xamarin.iOS/UIKit/UIView.g.cs:1421 
  at XplatSolutions.TagButton.Dispose (System.Boolean disposing) [0x00028] in <8562fb0b9b9c488390635a704b96e143>:0 
  at Foundation.NSObject.Finalize () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.11.0.56/src/Xamarin.iOS/Foundation/NSObject2.cs:129
Comment 4 Alan McGovern 2018-04-02 12:01:12 UTC
Good diagnosing!

John, it's expected that things might get slow while we restart. Sometimes failures in 3rd party controls are transient and retrying the rendering process fixes it. When you did get the 'custom controls were not loaded' message, was the performance restored to it's original level? 


How to address the underlying issue:

This is the kind of problem we cannot work around other than by attempting to disable all custom controls. `XplatSolutions.TagButton` is buggy and is calling UIKit methods from the finalizer thread. This is forbidden by UIKit as it's only supposed to be accessed when on the main thread.

The second issue is that the XplatSolutions.TagButton.Dispose(bool) method is mis-implemented as it should not be referencing/using other managed objects (which may or may not have already been disposed/finalized) when it's invoked from it's own finalizer.

The best option here is to report it as a bug to the toolkit owner and see if it can be addressed!
Comment 5 John Miller [MSFT] 2018-04-02 13:17:36 UTC
@Alan,

> was the performance restored to it's original level? 

Unfortunately, I don't recall. It was too long ago. :\

Your explanation sounds reasonable. Can this be updated from NEEDINFO? Seems it's been answered.