Bug 33084 - Unable to set CGColor to SCNMaterialProperty.Contents
Summary: Unable to set CGColor to SCNMaterialProperty.Contents
Status: CONFIRMED
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
URL:
Depends on:
Blocks:
 
Reported: 2015-08-13 23:22 UTC by Frank A. Krueger
Modified: 2016-10-19 18:44 UTC (History)
4 users (show)

Tags:
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 for Bug 33084 on Developer Community or GitHub 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 or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

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:

https://gist.github.com/chamons/99a8b6ee46abc3218828adb31ae319f2