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

Invalid task ids used for expiration handlers. #13

Closed
jaredsinclair opened this issue Jul 28, 2015 · 3 comments
Closed

Invalid task ids used for expiration handlers. #13

jaredsinclair opened this issue Jul 28, 2015 · 3 comments
Labels

Comments

@jaredsinclair
Copy link

The macro for beginning a background task looks like this:

UIBackgroundTaskIdentifier taskID = UIBackgroundTaskInvalid;
taskID = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
    [[UIApplication sharedApplication] endBackgroundTask:taskID]; 
}];

UIBackgroundTaskIdentifier is a value type, so when the block is created it captures taskID when it equals UIBackgroundTaskInvalid. It never captures the actual task identifier, so if the expiration handler pops the actual task isn't properly cancelled.

@garrettmoon
Copy link
Collaborator

Yup.

garrettmoon added a commit that referenced this issue Jul 28, 2015
This should fix two issues:
- Because taskID was being captured before being set, the expiration handler had an invalid taskID.
- If the expiration handler was called, and then PINCacheEndBackgroundTask was called, it would try to end a task that had already ended.
@garrettmoon
Copy link
Collaborator

@jaredsinclair Let me know what you think of #14

@jaredsinclair
Copy link
Author

lg™

garrettmoon added a commit that referenced this issue Jul 30, 2015
Invalid task ids used for expiration handlers. #13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants