Fix intermittent CoreServices XPC crash in RCTBlobManager blob name derivation - #58172
Fix intermittent CoreServices XPC crash in RCTBlobManager blob name derivation#581721337mus wants to merge 1 commit into
Conversation
|
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. ProcessIn 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 If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
@facebook-github-bot cla recheck |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
@SamChou19815 @javache @cipolleschi mind taking a look at this one? |
|
@christophpurrer has imported this pull request. If you are a Meta employee, you can view this in D117876442. |
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_msgSendframes).Why it fires on every request
RCTBlobManager.handleNetworkingResponse:callssuggestedFilenameon the networking / TurboModule queue for every response it converts to a blob. Sincewhatwg-fetchreads every response body as a blob, the fragile call runs for everyfetch()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
namefrom the URL's last path component instead. No XPC involved.Tradeoff: filenames from a
Content-Dispositionheader (or a MIME-derived extension) are no longer used. A response blob'snameis rarely consumed; it only feedsBlob/File.namefor response bodies. If you'd prefer to keepContent-Dispositionsupport, 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
nameis still populated from the URL path, and is empty when the URL has no path component, which matches one ofsuggestedFilename's own fallback tiers.