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 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.
Created attachment 20152 [details]
Project to illustrate the bug
This fails in the out of the box template BTW.
In an NSFileProviderExtension you need to create a FileCoordinator. To do that you need the ProviderIdentifer.
However, the NSFileProviderExtension code does not run on the UI thread.
I get this error: "UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread."
stack trace is this:
at UIKit.UIApplication.EnsureUIThread () [0x00023] in /Users/builder/data/lanes/3985/35d1ccd0/source/xamarin-macios/src/UIKit/UIApplication.cs:88
at UIKit.NSFileProviderExtension.get_ProviderIdentifier () [0x00000] in /Users/builder/data/lanes/3985/35d1ccd0/source/xamarin-macios/src/build/ios/native/UIKit/NSFileProviderExtension.g.cs:263
at FileProvider.FileProvider.CreateDocumentDirectory () [0x00013] in /ProjectLocation/FileProvider/FileProvider.cs:28
at FileProvider.FileProvider.StartProvidingItemAtUrl (Foundation.NSUrl url, System.Action`1[T] completionHandler) [0x00008] in /ProjectLocation/FileProvider/FileProvider.cs:77
I have attached a sample project that illustrates the issue.
Also, see here: https://forums.xamarin.com/discussion/89945/cant-access-provideridentifier-in-nsfileproviderextension
While UIKit is, by default, not thread safe it's not the case here (even if not clearly stated as such in the documentation). The fact that the type purpose is file coordination does imply threading.
The workaround given in the forum is correct. Also this thread check is not done (by default) on release builds (for performance reasons).
Thanks for the bug report!
Now that I have hacked past the ProviderIdentifer, I also cannot access the DocumentStorageUrl property. I get the same UI thread error.
This is a check that applies, by default, to every member of UIKit.* types, i.e. it was not specific to the property you mentioned before.
To disable the feature globally please see . This is the same (default) setting for release builds.
PR master https://github.com/xamarin/xamarin-macios/pull/1836
Can you provide proper steps or description for verifying this bug.
Sure. If you go back to my initial description you'll see I was creating an out of the box file provider extension. That extension would crash when it was run.
1. Build the app I provided
2. Set the file provider extension as the startup project
3. Run the extension and launch an app like Pages to invoke the FileProviderBug doc picker.
4. The FileProvider will crash in its constructor when it tries to access ProviderIdentifier.