Skip to content

Commit

Permalink
fix GoogleMaps compatibility crash (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
Augustyniak authored Sep 11, 2024
1 parent 5476645 commit 13e9400
Showing 1 changed file with 4 additions and 3 deletions.
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

0 comments on commit 13e9400

Please sign in to comment.