Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19334] iOS: URLSession - large file download in the background - some events are not fired and other issues.

GitHub Issuen/a
TypeBug
PriorityNone
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterShawn Lan
AssigneeUnknown
Created2015-07-16T02:15:55.000+0000
Updated2018-02-28T19:55:57.000+0000

Description

1. Events not fired. To re-produce, download a large file > 1GB, press "Home" to make the app go to the background. Once the download finishes, only "backgroundtransfer" is fired. The other events are not: sessioneventscompleted, downloadcompleted, etc. Without downloadcompleted, the file can't be saved. Without sessioneventscompleted, the app won't call endBackgroundHandler, and it will run over 30 seconds, eventually being terminated by the system. I think the problem is that after the download finishes, the file is "copied" instead of "moved" to the temp folder (see TIMOB-17502). Copying a large file can take longer than 30 seconds, so the system kills the app before it finishes copying. We should just "move" it to the temp location. This is also suggested in Apple's docs. 2. If the download fails, the partial file is still copied to the temp folder. I think it should copy only when a download is successful. First, the file is useless. Second, "downloadcompleted is not even called in this situation. The app can't get the handle of the partial file anyway. To re-produce, download a file. During the download, kill the app manually. Also, in the above test, sometimes "sessioncompleted" isn't fired right after force closing the app (sometimes it is). The app won't be able to mark the download as failed if this issue happens. Again, I think this happens because the partial file is being copied to the temp folder, and if the file is large enough, "sessioncompleted" won't get fired before the app exits. 3. When downloading a file (> 1GB) in the background, sometimes I got crash reports like the attached. I don't understand why the app was woken and running in the background over 3 minutes. Please investigate. 4. With a medium size download (2-300MB) in the background, calling endBackgroundHandler when sessioneventscompleted fired throws the following error, and the callback is failed to complete. The size of the file doesn't matter. Use files around 2-300MB so that you can re-produce the issue. I think the issue is endBackgroundHandler itself alone.
[WARN] :   ing: Application delegate received call to -application:handleEventsForBackgroundURLSession:completionHandler: but the completion handler was never called.
[WARN] :   assertion failed: 12H143: libxpc.dylib + 51923 [7FF71721-5624-3DDE-9615-146A4D8B7197]: 0x7d

Attachments

FileDateSize
FRCC 7-15-15, 12-07 PM.crash2015-07-16T17:53:34.000+000042950

Comments

No comments

JSON Source