Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Longer downloads fail silently when app is backgrounded on iOS #353

Open
3 tasks done
bikubi opened this issue Nov 22, 2022 · 1 comment
Open
3 tasks done

Longer downloads fail silently when app is backgrounded on iOS #353

bikubi opened this issue Nov 22, 2022 · 1 comment

Comments

@bikubi
Copy link

bikubi commented Nov 22, 2022

Bug Report

Problem

Reproduce:

  • Start a download that runs approx. longer than 30s.
  • Background the app (i.e. home button, open other app)
  • Be on battery (no cable) for quicker fails. Also iPhones fail quicker than iPads. YMMV.

What is expected to happen?

  • The download continues until it's done

What does actually happen?

  • The download fails
  • The file is not created
  • neither success nor error handlers are called

Information

  • This seems to be a common issue for background tasks on cordova. Hence the existence of the background mode plugin, which doesn't work any more with modern OSes. See also Android doze.
  • I thought it might not apply because i see several references to backgroundTaskID etc. in the code, which the general docs about background execution talk about. But I'm too unfamiliar with iOS dev to really tell.
  • I thought the "background fetch" capability would solve this, but nope. Might need a specific implementation to work.
  • This is somewhat related to There's any way to resume downloads? #213, essentially a duplicate of the issue described in this comment, but its own issue -- resumable downloads could mitigate / work around, but not solve the core issue.
  • Seems not to affect Android, but I might have to test harder (longer downloads)
  • I will give https://github.com/sgrebnov/cordova-plugin-background-download a try, but I am not getting my hopes up
  • At the very least, the error callback should fire.
  • For now I guess I'll have to add a hint: "Please don't close the app while download is running"... (or remember that I had started a download, an then onforeground check if it is still running, check if the file is there... oof, heuristic headaches)

Environment, Platform, Device

I think only iOS, Android needs more testing.

Version information

  • cordova 11.0.0
  • cordova-ios 6.2.0
  • current dev version of this plugin 7ba6fa3 (but also 5ed73ae)
  • cordova-plugin-file 7.0.0 (but also 5.0.0)
  • Xcode 13.1
  • iOS 15.4.1, 16(.1 iirc), 12.3.1 (I think. It looks like that one has just trained itself for longer exec times, sigh)

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@bikubi
Copy link
Author

bikubi commented Nov 22, 2022

Could be a duplicate of #321 but note that this is primarily not about request time-outs (in the http or network sense) and not related to file size, only execution time.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant