Skip to content

Fix intermittent CoreServices XPC crash in RCTBlobManager blob name derivation - #58172

Open
1337mus wants to merge 1 commit into
react:mainfrom
1337mus:fix-blobmanager-suggestedfilename-crash
Open

Fix intermittent CoreServices XPC crash in RCTBlobManager blob name derivation#58172
1337mus wants to merge 1 commit into
react:mainfrom
1337mus:fix-blobmanager-suggestedfilename-crash

Conversation

@1337mus

@1337mus 1337mus commented Aug 27, 2026

Copy link
Copy Markdown

Summary

The crash

-[NSURLResponse suggestedFilename] derives a filename from the response's MIME type. Under the hood, that call makes a CoreServices/UTType XPC round-trip, and that XPC call crashes intermittently when invoked off the main thread (NSXPCEncoder / objc_msgSend frames).

Why it fires on every request

RCTBlobManager.handleNetworkingResponse: calls suggestedFilename on the networking / TurboModule queue for every response it converts to a blob. Since whatwg-fetch reads every response body as a blob, the fragile call runs for every fetch() an app makes. Even a very low per-call crash rate becomes a steady stream of native crashes at scale.

We hit this in production at Phantom (millions of iOS users). Crash stacks consistently point into the UTType XPC machinery under suggestedFilename, always on the networking queue.

The fix

Derive the blob's name from the URL's last path component instead. No XPC involved.

// before
@"name" : RCTNullIfNil([response suggestedFilename]),

// after
@"name" : RCTNullIfNil(response.URL.lastPathComponent),

Tradeoff: filenames from a Content-Disposition header (or a MIME-derived extension) are no longer used. A response blob's name is rarely consumed; it only feeds Blob / File.name for response bodies. If you'd prefer to keep Content-Disposition support, parsing that header directly here would also avoid the XPC call. Happy to iterate.

Related: the same XPC fragility on the upload path was reported in #35096.

Changelog:

[IOS] [FIXED] - Fix intermittent native crash (CoreServices/UTType XPC) in RCTBlobManager when deriving blob names for network responses

Test Plan

  • This exact change has run in production at Phantom since May 2026 (applied as a patch). The crash class disappeared and stayed gone.
  • Fetch/blob flows (file and image downloads, uploads, WebSocket blobs) are covered by our device-farm e2e suites and are green with this change.
  • name is still populated from the URL path, and is empty when the URL has no path component, which matches one of suggestedFilename's own fallback tiers.

@meta-cla

meta-cla Bot commented Aug 27, 2026

Copy link
Copy Markdown

Hi @1337mus!

Thank you for your pull request.

We require contributors to sign our Contributor License Agreement, and yours needs attention.

You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@1337mus

1337mus commented Aug 27, 2026

Copy link
Copy Markdown
Author

@facebook-github-bot cla recheck

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 27, 2026
@meta-cla

meta-cla Bot commented Aug 27, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 27, 2026
@1337mus

1337mus commented Aug 27, 2026

Copy link
Copy Markdown
Author

@SamChou19815 @javache @cipolleschi mind taking a look at this one?

@meta-codesync

meta-codesync Bot commented Aug 28, 2026

Copy link
Copy Markdown

@christophpurrer has imported this pull request. If you are a Meta employee, you can view this in D117876442.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant