Background uploads do not appear to work
I am a Flutter developer integrating TUSKit into our app and having difficulties getting background uploading to work.
So I am attempting to run the example app just to observe the background capability, but it looks like it only runs while the app is in the foreground.
Running the TUSKit Demo app using latest master. The log output below is the result of the following sequence:
- Select an image from the picker.
- Allow upload to begin.
- Immediately switch to another app.
- Upload halts (or seems to, log output stops anyways).
- Switch back to demo app.
- A timeout error is logged
- A
couldNotUploadFileerror is logged.
I'm really new to iOS native and Swift and so this could be the result of me just misunderstanding of the library. If that is the case, I would very much appreciate some guidance on applying background uploads with TUSKit.
For reference, I have been following this guide that describes some common pitfalls with developing background uploads.
2022-04-13 09:22:00.452918-0700 TUSKitExample[3564:1367287] [Picker] Showing picker unavailable UI (reason: still loading) with error: (null)
Received 1 images
TUSClient started upload, id is AF169ABE-0369-43FB-B9B1-CD5AA5EAC8DD
TUSClient remaining is 1
TUSClient single upload progress: 4864 / 1283879
TUSClient total upload progress: 0 of 1283879 bytes.
TUSClient single upload progress: 0 / 1283879
TUSClient total upload progress: 0 of 1283879 bytes.
TUSClient single upload progress: 486400 / 1283879
TUSClient total upload progress: 0 of 1283879 bytes.
TUSClient single upload progress: 512000 / 1283879
TUSClient total upload progress: 0 of 1283879 bytes.
TUSClient single upload progress: 512000 / 1283879
TUSClient total upload progress: 512000 of 1283879 bytes.
TUSClient single upload progress: 512000 / 1283879
TUSClient total upload progress: 512000 of 1283879 bytes.
TUSClient single upload progress: 998400 / 1283879
TUSClient total upload progress: 512000 of 1283879 bytes.
TUSClient single upload progress: 1024000 / 1283879
TUSClient total upload progress: 512000 of 1283879 bytes.
TUSClient single upload progress: 1026468 / 1283879
TUSClient total upload progress: 1024000 of 1283879 bytes.
TUSClient single upload progress: 1024000 / 1283879
TUSClient total upload progress: 1024000 of 1283879 bytes.
2022-04-13 09:22:10.397595-0700 TUSKitExample[3564:1369941] [connection] nw_read_request_report [C4] Receive failed with error "Software caused connection abort"
2022-04-13 09:22:10.401117-0700 TUSKitExample[3564:1369941] Task <31656C9F-C49B-4D8D-A1BE-122B37350C19>.<17> HTTP load failed, 260408/0 bytes (error code: -1005 [4:-4])
TUSClient single upload progress: 1270885 / 1283879
TUSClient total upload progress: 1024000 of 1283879 bytes.
2022-04-13 09:22:10.402273-0700 TUSKitExample[3564:1369971] Task <31656C9F-C49B-4D8D-A1BE-122B37350C19>.<17> finished with error [-1005] Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo={_kCFStreamErrorCodeKey=-4, NSUnderlyingError=0x281c4f630 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={NSErrorPeerAddressKey=<CFData 0x2831f3f70 [0x1fbe836d0]>{length = 16, capacity = 16, bytes = 0x100201bb3415e3a20000000000000000}, _kCFStreamErrorCodeKey=-4, _kCFStreamErrorDomainKey=4}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalUploadTask <31656C9F-C49B-4D8D-A1BE-122B37350C19>.<17>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalUploadTask <31656C9F-C49B-4D8D-A1BE-122B37350C19>.<17>"
), NSLocalizedDescription=The network connection was lost., NSErrorFailingURLStringKey=https://tusd.tusdemo.net/files/c9c23dcd1793ac8b297b6d35e0c1179b+IAoBKoX3r7J9hdg_IhmZD__79spDbbRe4hTqdQg.nfgSujmYkn4tzQ7Hsb5Y9TFwEZWG74hAwSmyxqgOjt5Rt5Wgj3CdGbml4q7Xr4Ziyq6fHO1KWRKAXRZ__KDDr.Zg, NSErrorFailingURLKey=https://tusd.tusdemo.net/files/c9c23dcd1793ac8b297b6d35e0c1179b+IAoBKoX3r7J9hdg_IhmZD__79spDbbRe4hTqdQg.nfgSujmYkn4tzQ7Hsb5Y9TFwEZWG74hAwSmyxqgOjt5Rt5Wgj3CdGbml4q7Xr4Ziyq6fHO1KWRKAXRZ__KDDr.Zg, _kCFStreamErrorDomainKey=4}
TUSClient single upload progress: 1026468 / 1283879
TUSClient total upload progress: 1024000 of 1283879 bytes.
TUSClient single upload progress: 1024000 / 1283879
TUSClient total upload progress: 1024000 of 1283879 bytes.
2022-04-13 09:22:10.860296-0700 TUSKitExample[3564:1369971] [tcp] tcp_input [C5.1:3] flags=[R] seq=2010685109, ack=4294967196, win=0 state=CLOSE_WAIT rcv_nxt=2010685871, snd_una=2624184247
TUSClient single upload progress: 1270885 / 1283879
TUSClient total upload progress: 1024000 of 1283879 bytes.
2022-04-13 09:22:41.364715-0700 TUSKitExample[3564:1369941] Task <0BB5EB6E-DC57-4FA4-B8E8-3EACD06133D2>.<18> finished with error [-1001] Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={_kCFStreamErrorCodeKey=-2102, NSUnderlyingError=0x281c4dbf0 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalUploadTask <0BB5EB6E-DC57-4FA4-B8E8-3EACD06133D2>.<18>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalUploadTask <0BB5EB6E-DC57-4FA4-B8E8-3EACD06133D2>.<18>"
), NSLocalizedDescription=The request timed out., NSErrorFailingURLStringKey=https://tusd.tusdemo.net/files/c9c23dcd1793ac8b297b6d35e0c1179b+IAoBKoX3r7J9hdg_IhmZD__79spDbbRe4hTqdQg.nfgSujmYkn4tzQ7Hsb5Y9TFwEZWG74hAwSmyxqgOjt5Rt5Wgj3CdGbml4q7Xr4Ziyq6fHO1KWRKAXRZ__KDDr.Zg, NSErrorFailingURLKey=https://tusd.tusdemo.net/files/c9c23dcd1793ac8b297b6d35e0c1179b+IAoBKoX3r7J9hdg_IhmZD__79spDbbRe4hTqdQg.nfgSujmYkn4tzQ7Hsb5Y9TFwEZWG74hAwSmyxqgOjt5Rt5Wgj3CdGbml4q7Xr4Ziyq6fHO1KWRKAXRZ__KDDr.Zg, _kCFStreamErrorDomainKey=4}
TUSClient single upload progress: 1026468 / 1283879
TUSClient total upload progress: 1024000 of 1283879 bytes.
TUSClient single upload progress: 1024000 / 1283879
TUSClient total upload progress: 1024000 of 1283879 bytes.
2022-04-13 09:22:41.931172-0700 TUSKitExample[3564:1370472] [tcp] tcp_input [C6.1:3] flags=[R] seq=3901238267, ack=4294967196, win=0 state=CLOSE_WAIT rcv_nxt=3901239029, snd_una=2220065410
TUSClient single upload progress: 1270885 / 1283879
TUSClient total upload progress: 1024000 of 1283879 bytes.
2022-04-13 09:23:12.388363-0700 TUSKitExample[3564:1370472] Task <D81179D5-2951-47C0-A13E-DE29E7A126C9>.<19> finished with error [-1001] Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={_kCFStreamErrorCodeKey=-2102, NSUnderlyingError=0x281ca3060 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalUploadTask <D81179D5-2951-47C0-A13E-DE29E7A126C9>.<19>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalUploadTask <D81179D5-2951-47C0-A13E-DE29E7A126C9>.<19>"
), NSLocalizedDescription=The request timed out., NSErrorFailingURLStringKey=https://tusd.tusdemo.net/files/c9c23dcd1793ac8b297b6d35e0c1179b+IAoBKoX3r7J9hdg_IhmZD__79spDbbRe4hTqdQg.nfgSujmYkn4tzQ7Hsb5Y9TFwEZWG74hAwSmyxqgOjt5Rt5Wgj3CdGbml4q7Xr4Ziyq6fHO1KWRKAXRZ__KDDr.Zg, NSErrorFailingURLKey=https://tusd.tusdemo.net/files/c9c23dcd1793ac8b297b6d35e0c1179b+IAoBKoX3r7J9hdg_IhmZD__79spDbbRe4hTqdQg.nfgSujmYkn4tzQ7Hsb5Y9TFwEZWG74hAwSmyxqgOjt5Rt5Wgj3CdGbml4q7Xr4Ziyq6fHO1KWRKAXRZ__KDDr.Zg, _kCFStreamErrorDomainKey=4}
TUSClient upload failed for AF169ABE-0369-43FB-B9B1-CD5AA5EAC8DD error couldNotUploadFile
2022-04-13 09:23:18.382887-0700 TUSKitExample[3564:1370472] [tcp] tcp_output [C6.1:3] flags=[R.] seq=2220101294, ack=3901239029, win=4096 state=CLOSED rcv_nxt=3901239029, snd_una=2220065410
2022-04-13 09:23:26.283814-0700 TUSKitExample[3564:1370472] [tcp] tcp_output [C5.1:3] flags=[R.] seq=2624221579, ack=2010685871, win=4096 state=CLOSED rcv_nxt=2010685871, snd_una=2624184247