You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Michael Gauthier <mi...@silverorange.com> on 2013/12/10 17:45:23 UTC
File plugin threading on iOS
When using the File plugin on iOS I get a lot of "THREAD WARNING Plugin
should use a background thread" messages. Is the iOS plugin actually
using blocking filesystem calls internally?
Cheers,
Mike
Re: File plugin threading on iOS
Posted by Ian Clelland <ic...@chromium.org>.
I'm hoping to have it all merged by the end of this week, if all of the
tests still pass.
Thanks for checking it out! :)
Ian
On Wed, Dec 11, 2013 at 8:59 AM, Michael Gauthier <mi...@silverorange.com>wrote:
>
> On 2013-12-10 18:10, Ian Clelland wrote:
>
>> On Tue, Dec 10, 2013 at 4:40 PM, Michael Gauthier <mike@silverorange.com
>> >wrote:
>>
>> I quickly updated the File plugin to do the local file uri stuff in
>>> resolveLocalFileSystemURI in the background using [self.commandDelegate
>>> runInBackground:^{}].
>>>
>>>
>> Dev or master?
>>
>> I made the change in master. Dev looks way awesomer. When do you think
> you will release?
>
>
>
>
>>
>>> It works and allows my app interface to respond while the FS calls are
>>> resolving. Is this approach crazy or obviously broken in some way?
>>>
>>>
>> Probably not crazy -- depending on how you've implemented it :) It's
>> basically what I'm doing in my branch as well.
>>
>> Currently, I have CDVFile using that pattern, [self.commandDelegate
>> runInBackground:], to call the actual implementation method in
>> CDVLocalFilesystem or CDVAssetLibraryFilesystem. CDVFile passes the
>> implementation methods a callback function that sends the actual plugin
>> response when the operation is finished. (Keeping all of the
>> "Cordova-plugin-y" bits in CDVFile, and just having the raw file
>> operations
>> in the file system implementation classes.
>>
>> You can see an example of what I've done in the implementation of [CDVFile
>> readAsText:] and in [CDVLocalFilesystem readFileAtURL:start:end:
>> callback:]
>> in the dev branch.
>>
>> Ian
>>
>>
>
Re: File plugin threading on iOS
Posted by Michael Gauthier <mi...@silverorange.com>.
On 2013-12-10 18:10, Ian Clelland wrote:
> On Tue, Dec 10, 2013 at 4:40 PM, Michael Gauthier <mi...@silverorange.com>wrote:
>
>> I quickly updated the File plugin to do the local file uri stuff in
>> resolveLocalFileSystemURI in the background using [self.commandDelegate
>> runInBackground:^{}].
>>
>
> Dev or master?
>
I made the change in master. Dev looks way awesomer. When do you think
you will release?
>
>>
>> It works and allows my app interface to respond while the FS calls are
>> resolving. Is this approach crazy or obviously broken in some way?
>>
>
> Probably not crazy -- depending on how you've implemented it :) It's
> basically what I'm doing in my branch as well.
>
> Currently, I have CDVFile using that pattern, [self.commandDelegate
> runInBackground:], to call the actual implementation method in
> CDVLocalFilesystem or CDVAssetLibraryFilesystem. CDVFile passes the
> implementation methods a callback function that sends the actual plugin
> response when the operation is finished. (Keeping all of the
> "Cordova-plugin-y" bits in CDVFile, and just having the raw file operations
> in the file system implementation classes.
>
> You can see an example of what I've done in the implementation of [CDVFile
> readAsText:] and in [CDVLocalFilesystem readFileAtURL:start:end:callback:]
> in the dev branch.
>
> Ian
>
Re: File plugin threading on iOS
Posted by Ian Clelland <ic...@chromium.org>.
On Tue, Dec 10, 2013 at 4:40 PM, Michael Gauthier <mi...@silverorange.com>wrote:
> I quickly updated the File plugin to do the local file uri stuff in
> resolveLocalFileSystemURI in the background using [self.commandDelegate
> runInBackground:^{}].
>
Dev or master?
>
> It works and allows my app interface to respond while the FS calls are
> resolving. Is this approach crazy or obviously broken in some way?
>
Probably not crazy -- depending on how you've implemented it :) It's
basically what I'm doing in my branch as well.
Currently, I have CDVFile using that pattern, [self.commandDelegate
runInBackground:], to call the actual implementation method in
CDVLocalFilesystem or CDVAssetLibraryFilesystem. CDVFile passes the
implementation methods a callback function that sends the actual plugin
response when the operation is finished. (Keeping all of the
"Cordova-plugin-y" bits in CDVFile, and just having the raw file operations
in the file system implementation classes.
You can see an example of what I've done in the implementation of [CDVFile
readAsText:] and in [CDVLocalFilesystem readFileAtURL:start:end:callback:]
in the dev branch.
Ian
Re: File plugin threading on iOS
Posted by Michael Gauthier <mi...@silverorange.com>.
I quickly updated the File plugin to do the local file uri stuff in
resolveLocalFileSystemURI in the background using [self.commandDelegate
runInBackground:^{}].
It works and allows my app interface to respond while the FS calls are
resolving. Is this approach crazy or obviously broken in some way?
Cheers,
Mike
On 10/12/13 12:57 PM, Ian Clelland wrote:
> Unfortunately, except in a few cases (accessing asset-library urls and
> actually reading and writing files) it is blocking.
>
> Creating, finding, deleting and renaming regular files are all currently
> synchronous operations on iOS. Reading and writing contents are async, and
> shouldn't block anything.
>
> Once I've pushed up the last changes to the File plugin, it's on my list of
> things to tackle.
>
> Ian
>
>
> On Tue, Dec 10, 2013 at 11:45 AM, Michael Gauthier <mi...@silverorange.com>wrote:
>
>> When using the File plugin on iOS I get a lot of "THREAD WARNING Plugin
>> should use a background thread" messages. Is the iOS plugin actually using
>> blocking filesystem calls internally?
>>
>> Cheers,
>> Mike
>>
>
Re: File plugin threading on iOS
Posted by Ian Clelland <ic...@chromium.org>.
Unfortunately, except in a few cases (accessing asset-library urls and
actually reading and writing files) it is blocking.
Creating, finding, deleting and renaming regular files are all currently
synchronous operations on iOS. Reading and writing contents are async, and
shouldn't block anything.
Once I've pushed up the last changes to the File plugin, it's on my list of
things to tackle.
Ian
On Tue, Dec 10, 2013 at 11:45 AM, Michael Gauthier <mi...@silverorange.com>wrote:
> When using the File plugin on iOS I get a lot of "THREAD WARNING Plugin
> should use a background thread" messages. Is the iOS plugin actually using
> blocking filesystem calls internally?
>
> Cheers,
> Mike
>