Bug 11049 - UICollectionViewLayoutAttributes::CreateForCell
Summary: UICollectionViewLayoutAttributes::CreateForCell
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 6.3.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-03-11 15:20 UTC by Nick
Modified: 2013-03-12 17:40 UTC (History)
2 users (show)

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

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 Nick 2013-03-11 15:20:37 UTC
This method enforces use on the UI thread with UIApplication.EnsureUIThread (), but why? Whats the problem with constructing one in a background thread exactly?

Full definition below:

[Export ("layoutAttributesForCellWithIndexPath:"), CompilerGenerated]
public static UICollectionViewLayoutAttributes CreateForCell (NSIndexPath indexPath)
	UIApplication.EnsureUIThread ();
	if (indexPath == null)
		throw new ArgumentNullException ("indexPath");
	return (UICollectionViewLayoutAttributes)Runtime.GetNSObject (Messaging.IntPtr_objc_msgSend_IntPtr (UICollectionViewLayoutAttributes.class_ptr, UICollectionViewLayoutAttributes.selLayoutAttributesForCellWithIndexPath_, indexPath.Handle));
Comment 1 Sebastien Pouliot 2013-03-12 17:40:32 UTC
WIth a few exceptions UIKit code is not thread-safe. 

As such all UIKit.* methods are, by default, calling EnsureUIThread to avoid running into hard to find and near-to-impossible to duplicate bugs caused by accessing UIKit structures from several threads. 

If you find some Apple documentation about a specific API being thread-safe let us know and we'll update ou bindings to match this.

More details @ http://tirania.org/monomac/archive/2012/Sep-10.html including instruction on how you can, at your own risk, turn the feature completely or partially off.