Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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 34271 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
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
Accessing properties of NSShadow from background threads throws non-UI thread exception. This would appear to be same mis-conception as with NSMutableParagrahStyle (see https://bugzilla.xamarin.com/show_bug.cgi?id=28032). My understanding is that the issue with NSMutableParagraphStyle is fixed internally but am not clear as to whether its in iOS 9 release or not - we have had to hold off on this release due to other issues. What is the status with NSShadow, was that addressed at the same time or not yet fixed?
Sadly thread safety is not something that is well documented by Apple
for their API. It's even not uncommon to find Apple own's sample not
correctly using some API.
If the thread safety rules are not provided for an API then the
following rules are applied:
1. UIKit is considered thread unsafe
> For the most part, use UIKit classes only from your app’s main thread.
> This is particularly true for classes derived from UIResponder or
> that involve manipulating your app’s user interface in any way.
2. Some exceptions are listed, globally, in this document
3. Any other document (e.g. WWDC videos) that we can double-check
with Apple (radar) to confirm it's thread safe.
Te misuse of some API on incorrect threads can lead to hard to
find/duplicate issues inside application code. This is why XI has,
by default, added thread checks inside the (debug only) builds.
We'll review the case for NSShadow and see if we should treat it
as thread-safe (or not) by default. At the moment this type is not
considered as thread-safe.
Note that you can totally disable this feature globally or locally:
NSShadow can be applied to NSAttributedString/NSMutableAttributedString - the latter are thread safe and thus NSShadow would have to be to be usable. However the article you reference is very useful and I can code work around for now.
Created attachment 23769 [details]
Solution demonstrating defect
Attached solution attempts to access NSShadow from a background thread, in which case it throws (which is caught and written to console). Does it again from UI thread, in which case it doesn't throw.
Marking as "enhancement"
Thanks so much for taking the time to submit this report! I can confirm using the latest Xamarin.iOS 10.12.0.14 I am able to reproduce this issue. Marking this report as CONFIRMED.