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

attempt at fixing crash with some 3rd parties #20

Merged
merged 2 commits into from
Aug 30, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,31 @@ extension URLSession {
// `cap_make(configuration:delegate:delegateQueue)` was used to replace the implementation of
// `URLSession.init(configuration:delegate:delegateQueue)` so the call below calls the original
// initializer.

if delegate != nil {
// Proxying delegates of some 3rd party frameworks leads to crashes. Disable proxying for
// problematic classes.
// Refer to the following GitHub comments for more details:
// * https://github.com/google/gtm-session-fetcher/issues/190#issuecomment-604205556
// * https://github.com/google/gtm-session-fetcher/issues/190#issuecomment-604757154
let disabledDelegateClassNames = [
"GMPx_GTMSessionFetcherService", // GooglePlaces
"GTMSessionFetcherService", // GTMSessionFetcher
]

let shouldDisableProxying = disabledDelegateClassNames
.compactMap { NSClassFromString($0) }
.contains { delegate?.isKind(of: $0) == true }

if shouldDisableProxying {
return Self.cap_makeSession(
configuration: configuration,
delegate: delegate,
delegateQueue: delegateQueue
)
}
}

let newDelegate: URLSessionDelegate?
if delegate?.isKind(of: ProxyURLSessionDelegate.self) == true {
newDelegate = delegate
Expand Down
Loading