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 GoogleMaps compatibility crash #38

Merged
merged 2 commits into from
Sep 11, 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 @@ -33,20 +33,21 @@ extension URLSession {
// `URLSession.init(configuration:delegate:delegateQueue)` so the call below calls the original
// initializer.

if delegate != nil {
if let delegate {
// 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_GTMSessionFetcherSessionDelegateDispatcher", // GooglePlaces SDK
"GTMSessionFetcherSessionDelegateDispatcher", // GoogleMaps/GTMSessionFetcher SDK
"GMSx_GTMSessionFetcherSessionDelegateDispatcher", // GoogleMaps SDK
"GTMSessionFetcherSessionDelegateDispatcher", // GTMSessionFetcher SDK
]

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

if shouldDisableProxying {
return Self.cap_makeSession(
Expand Down
Loading