Skip to content

Conversation

@paulb777
Copy link
Member

@paulb777 paulb777 commented Nov 28, 2025

Analysis from @ncooke3:

I'm pretty confident that this PR is valid code cleanup, but won't actually fix the crash.

Here's the order of events:

  • Background task is created (line 134)
  • App is backgrounded and the system starts a 30 second timer to complete in-progress background tasks
  • 30 second timer runs out, warning is issued if unfinished background tasks exist
  • A grace period is given (non-deterministic, few seconds long) before the system kills the app (because the app is backgrounded, the user will experience a fresh app launch)

Gemini's summary:

Summary

The expirationHandler for the background task was attempting to cancel a non-existent currentTask property. This meant that if an upload task timed out, the operation would never be cancelled, and the background task identifier would never be released, leading to a warning from the OS and potential termination of the app.

The fix replaces the incorrect call with [self cancel], which correctly triggers the NSOperation's cancellation mechanism. This ensures that the operation terminates gracefully, allowing its promise chain to clean up and properly end the background task.

The CHANGELOG.md has also been updated to reflect this fix.

@google-oss-bot
Copy link

google-oss-bot commented Nov 29, 2025

@paulb777 paulb777 requested a review from ncooke3 December 1, 2025 14:09
@ncooke3
Copy link
Member

ncooke3 commented Dec 1, 2025

firebase/firebase-ios-sdk#15129 is a different background task so this doesn't fix that one.

@ncooke3
Copy link
Member

ncooke3 commented Dec 1, 2025

Will come back to this. Looks like the dead property was created in #3.

@85n5z5y7kw-commits

This comment was marked as off-topic.

@85n5z5y7kw-commits

This comment was marked as off-topic.

paulb777 and others added 2 commits December 8, 2025 14:29
Co-authored-by: Nick Cooke <36927374+ncooke3@users.noreply.github.com>
@paulb777 paulb777 merged commit 17eb3cb into main Dec 8, 2025
8 checks passed
@paulb777 paulb777 deleted the pb-fix-crash3 branch December 8, 2025 22:53
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

Successfully merging this pull request may close these issues.

4 participants