Bug 33084 - Unable to set CGColor to SCNMaterialProperty.Contents
Summary: Unable to set CGColor to SCNMaterialProperty.Contents
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll (show other bugs)
Version: XI 8.10
Hardware: PC Mac OS
: --- major
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-08-13 23:22 UTC by Frank A. Krueger
Modified: 2016-10-19 18:44 UTC (History)
4 users (show)

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


Description Frank A. Krueger 2015-08-13 23:22:00 UTC
SCNMaterialProperty.Contents should be able to be set to a variety of objects, including CoreGraphics objects.

However, the binding forces NSObjects and thus prevent CGColor use.

The ContentColor binding forces you to use UIColor and doesn't support CGColor.

Similar problems occur for CGImage and the ContentImage binding.

These are important to support because SceneKit is multithreaded but the UIColor and UIImage classes are locked to the UI thread. For instance, thumbnail generation is usually done in a background thread but this cannot be done because of this binding.

This is also a bug on the Mac binding. Please fix both. :-)

(Also, the names are strange. Why is one pluralized "Contents", and the others are "Content"? I think the names should have been ColorContents not ContentColor since the color is the content, not an attribute of the content.)
Comment 1 Sebastien Pouliot 2015-08-14 08:48:45 UTC
Yes, it seems the API should accept an INativeObject (not an NSObject).

> UIColor and UIImage classes are locked to the UI thread.

The UIColor type is marked as [ThreadSafe] in our bindings and you should be able to use it in background threads. For UIImage it's not the entire API, but most members are marked as [ThreadSafe].

If you're hitting a case where that does not work please attach a test case as something (else) must be wrong and needs to be verified.
Comment 2 Frank A. Krueger 2015-08-14 14:01:50 UTC
Thanks for the clarifications. The last time I tried to use a UIColor on a background thread it blew up with a Xamarin exception. But that might have been literally years ago. I've just taken it as doctrine. Nice to know it works!
Comment 3 Chris Hamons 2016-10-19 18:44:26 UTC
@Frank - Here's a quick patch to hack in setting a CGColor:


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