Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

App may be killed in iOS if task is long #4

Open
aarani opened this issue Oct 15, 2020 · 3 comments
Open

App may be killed in iOS if task is long #4

aarani opened this issue Oct 15, 2020 · 3 comments

Comments

@aarani
Copy link

aarani commented Oct 15, 2020

MSDN describes how to use Background Tasks in here

The registration process pairs a task with a unique identifier, taskID, and then wraps it in matching BeginBackgroundTask and EndBackgroundTask calls. To generate the identifier, we make a call to the BeginBackgroundTask method on the UIApplication object, and then start the long-running task, usually on a new thread. When the task is complete, we call EndBackgroundTask and pass in the same identifier. This is important because iOS will terminate the application if a BeginBackgroundTask call does not have a matching EndBackgroundTask.

Steps To Reproduce:

  • Run a while (1) inside a background task or just a long Task.Delay or just any long task (more than 3 minutes?)

Potential bad results:

  • App gets terminated

Expected results:

  • Background task should get cancelled
  • App remain working untouched
@knocte
Copy link
Member

knocte commented Oct 15, 2020

MSDN describes how to use Background Tasks in here

This info is not related to the bug either. It's part of the potential solution. Please post in a comment.

No End Background Task called in iOS Platform

Title should not mention info about a potential solution, please rename to "App may be killed in iOS if task is long"

@aarani aarani changed the title No End Background Task called in iOS Platform App may be killed in iOS if task is long Oct 15, 2020
@aarani
Copy link
Author

aarani commented Oct 15, 2020

MSDN describes how to use Background Tasks in here

This info is not related to the bug either. It's part of the potential solution. Please post in a comment.

It is not, I'm describing why I'm guessing this may happen even though I could not test it myself.
I think when I'm claiming something might be broken I have to have a reason for it.

@knocte
Copy link
Member

knocte commented Oct 15, 2020

as far as best practice goes I think we need to call EndBackgroundTask in Stop function and after our tasks are done, implementation example located here

Please post a WIP/DRAFT PR next week, thanks!

It is not, I'm describing why I'm guessing this may happen

Kinda good point, but still it's a speculation. Anyway let's leave it like this.

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

No branches or pull requests

2 participants