I am using a UIActivityViewController
to share a video file.
The video file is generated before it's being shared using an UIActivityItemProvider
.
Because the file generation and sharing can take a while for longer videos, it's important that the user can cancel the sharing operation.
This all worked without a problem in iOS7.0. The user could tap the cancel button on the UIActivityViewController
at any time, and the sharing operation was canceled.
When testing the same functionality on iOS7.1.1, taps on the cancel button while a sharing operation is executed no longer work. It is as if the main thread is blocked, but all of the sharing code is executing on background threads.
Is there something I'm missing here, or is there a known issue/change in iOS7.1? (I couldn't find anything in the release notes)
UPDATE
Thanks for all the comments.
Further debugging appears to suggest that there might be a threading issue.My UIActivityItemProvider's
item method is using a semaphore to make a block-based asynchronous export method defacto synchronous
. Hereby also blocking the thread it is executing on. I thought this shouldn't be a problem as the documentation for the -(void)item
method says:
This method is called on a secondary thread of your app.
Under iOS7.0 the UIActivityItemProvider's
cancel method was called from another thread than the one using the semaphore (as expected from the documentation), but under iOS7.1, could it be called from the same (blocked) thread, causing it to never execute? I can't test for this, as the cancel method never gets executed and I'm not responsible for calling it.
Is there an alternative way to force my export method to execute synchronously without blocking? Basically my issue is that UIActivityItemProvider'
item method has a long running export method, but `UIActivityItemProvider still needs to be able to receive cancel calls while it is exporting.