cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vladimir Kotikov (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CB-9936) iOS File Transfer not receiving Progress Event
Date Fri, 19 Aug 2016 10:00:27 GMT

    [ https://issues.apache.org/jira/browse/CB-9936?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15427932#comment-15427932
] 

Vladimir Kotikov edited comment on CB-9936 at 8/19/16 10:00 AM:
----------------------------------------------------------------

I wasn't able to reproduce w/ 1.3.0 version on iPhone 4s w/ iOS 8.3 and simulator w/ iOS 9.3
(cordova-ios 4.2.0). Here is the repro code I used: 
{noformat}
window.requestFileSystem(window.TEMPORARY,0, function(fs) {
    var fileTransfer = new FileTransfer();
    var uri = encodeURI("http://ovh.net/files/10Mio.dat");
    fs.root.getFile("test.dat", {create: true}, function(fileEntry) {
        fileTransfer.onprogress = function(progressEvent) {
            console.log("download percent");
            console.log(progressEvent.loaded/progressEvent.total*100);
        };
    
        fileTransfer.download(uri, fileEntry.nativeURL,
            function(entry) {
                console.log("download complete: " + entry.toURL());
            },
            function(error) {
                console.log(error);
            }
        );
    });
});
{noformat}

and here is the output:
!screenshot.png|width=800!


was (Author: vladimir.kotikov):
I wasn't able to reproduce w/ 1.3.0 version on iPhone 4s w/ iOS 8.3 (cordova-ios 4.2.0). Here
is the repro code I used: 
{noformat}
window.requestFileSystem(window.TEMPORARY,0, function(fs) {
    var fileTransfer = new FileTransfer();
    var uri = encodeURI("http://ovh.net/files/10Mio.dat");
    fs.root.getFile("test.dat", {create: true}, function(fileEntry) {
        fileTransfer.onprogress = function(progressEvent) {
            console.log("download percent");
            console.log(progressEvent.loaded/progressEvent.total*100);
        };
    
        fileTransfer.download(uri, fileEntry.nativeURL,
            function(entry) {
                console.log("download complete: " + entry.toURL());
            },
            function(error) {
                console.log(error);
            }
        );
    });
});
{noformat}

and here is the output:
!screenshot.png|width=800!

> iOS File Transfer not receiving Progress Event
> ----------------------------------------------
>
>                 Key: CB-9936
>                 URL: https://issues.apache.org/jira/browse/CB-9936
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin File Transfer
>    Affects Versions: 1.4.0
>         Environment: iOS
>            Reporter: Tony Leung
>            Priority: Minor
>              Labels: cannot-reproduce, triaged
>         Attachments: screenshot.png
>
>
> In CDVFileTransfer.m, download() method between line 447 to 462
> {noformat}
>     delegate.connection = [[NSURLConnection alloc] initWithRequest:req delegate:delegate
startImmediately:NO];
>     if (self.queue == nil) {
>         self.queue = [[NSOperationQueue alloc] init];
>     }
>     [delegate.connection setDelegateQueue:self.queue];
>     @synchronized (activeTransfers) {
>         activeTransfers[delegate.objectId] = delegate;
>     }
>     // Downloads can take time
>     // sending this to a new thread calling the download_async method
>     dispatch_async(
>                    dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, (unsigned
long)NULL),
>                    ^(void) { [delegate.connection start];}
>                    );
> {noformat}
> If I replaced it with the older version of the code, then it works.
> {noformat}
>     delegate.connection = [NSURLConnection connectionWithRequest:req delegate:delegate];
>     if (activeTransfers == nil) {
>         activeTransfers = [[NSMutableDictionary alloc] init];
>     }
>     [activeTransfers setObject:delegate forKey:delegate.objectId];
> {noformat}
> In summary, if we don't use GCD to start the NSURLConnection, it works.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message