Fix #351 - #357
Open
NSExceptional wants to merge 1 commit into
Open
Conversation
NSExceptional
force-pushed
the
fix/351-crash-nonexistent-report-file
branch
from
August 7, 2026 00:28
4b1202a to
14c5bdc
Compare
NSExceptional
force-pushed
the
fix/351-crash-nonexistent-report-file
branch
from
August 7, 2026 00:31
14c5bdc to
d44a805
Compare
uroboro
previously approved these changes
Aug 7, 2026
marcantoineg
approved these changes
Aug 7, 2026
NSExceptional
dismissed stale reviews from uroboro and alexanderdibenedetto
August 7, 2026 21:36
The merge-base changed after approval.
TSKBackgroundReporter writes the JSON report to a temp file and then uploads it with -uploadTaskWithRequest:fromFile:. A write failure was only treated as fatal in DEBUG builds; in production the code fell through and still handed the non-existent file to the upload task. CFNetwork validates the file synchronously at task-creation time and throws an uncaught NSInvalidArgumentException ("Cannot read file at ..."), crashing the app.
Return early when the report file cannot be written so we never create an upload task for a file that does not exist.
Firebase appeared in the reported stack trace only because FirebasePerformance swizzles uploadTaskWithRequest:fromFile:; it was not the cause.
NSExceptional
force-pushed
the
fix/351-crash-nonexistent-report-file
branch
from
August 7, 2026 21:36
d44a805 to
4fe679f
Compare
alexanderdibenedetto
approved these changes
Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Crash
Root cause
-[TSKBackgroundReporter pinValidationFailedForHostname:...]writes the JSON pin-failure report to a temp file and then uploads it with-[NSURLSession uploadTaskWithRequest:fromFile:].If
writeToURL:options:error:fails (e.g. the device storage is full), the failure was only treated as fatal in DEBUG builds (see the#if DEBUGguard added for #32). In a production build, execution fell through and still calleduploadTaskWithRequest:fromFile:with a file that was never written. CFNetwork validates the file synchronously at task-creation time and throws an uncaughtNSInvalidArgumentException, crashing the app — exactly atTSKBackgroundReporter.m:218in the reported stack trace.FirebasePerformanceappears in the trace only because it swizzlesuploadTaskWithRequest:fromFile:; it is not the cause.Fix
Return early when the report file cannot be written, so the reporter never hands a non-existent file to the upload task. DEBUG builds still raise (unchanged), preserving the behavior from #32.