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

Fix fireperf exception #12991

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions FirebasePerformance/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Unreleased
- Fix Crash from InstrumentUploadTaskWithStreamedRequest (#12983).

# 10.25.0
- [changed] Removed usages of user defaults API to eliminate required reason impact.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,15 @@ void InstrumentUploadTaskWithStreamedRequest(FPRNSURLSessionInstrument *instrume
if (!strongInstrument) {
ThrowExceptionBecauseInstrumentHasBeenDeallocated(selector, instrumentor.instrumentedClass);
}
typedef NSURLSessionUploadTask *(*OriginalImp)(id, SEL, NSURLRequest *);
NSURLSessionUploadTask *uploadTask = ((OriginalImp)currentIMP)(session, selector, request);
typedef NSURLSessionUploadTask *(*OriginalImp)(id, SEL, NSURLRequest *, NSData *);
// To avoid a runtime warning in Xcode 15, the given `URLRequest`
// should have a nil `HTTPBody`. To workaround this, the `HTTPBody` data is removed
// and requestData is replaced with it, if it bodyData was `nil`.
NSMutableURLRequest *requestWithoutHTTPBody = [request mutableCopy];
NSData *requestData = requestWithoutHTTPBody.HTTPBody;
requestWithoutHTTPBody.HTTPBody = nil;
NSURLSessionUploadTask *uploadTask =
((OriginalImp)currentIMP)(session, selector, request, requestData);
if (uploadTask.originalRequest) {
FPRNetworkTrace *trace =
[[FPRNetworkTrace alloc] initWithURLRequest:uploadTask.originalRequest];
Expand Down
Loading