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

Firebase auth crashes the app with: [GTMSessionFetcher setFetcher:forTask:]: unrecognized selector sent to instance #2512

Closed
eyalevy opened this issue Mar 11, 2019 · 18 comments
Assignees

Comments

@eyalevy
Copy link

eyalevy commented Mar 11, 2019

Describe your environment

  • Xcode version: 10.1
  • Firebase SDK version: 5.15.0
  • Firebase Component: Auth
  • Component version: 5.15.0

Describe the problem

the app crashes when using signInWithCustomToken. the error log is: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GTMSessionFetcher setFetcher:forTask:]: unrecognized selector sent to instance.
It seems there is a collision beetween firebase sdk and Trustkit (https://github.com/datatheorem/TrustKit).

Steps to reproduce:

Run the example app in this repository (react native, although it does not seem related...):
https://github.com/eyalevy/trustkit-firebase-sample

@morganchen12
Copy link
Contributor

morganchen12 commented Mar 11, 2019

This looks similar to crashes that can be caused by missing linker flags. Can you share the stack trace of the crash?

@eyalevy
Copy link
Author

eyalevy commented Mar 12, 2019

This is my linker flags: https://github.com/eyalevy/trustkit-firebase-sample/blob/e048d3d4ae630b3e97c814bcf2b1c42449d3a85d/ios/trustkitfirebasesample.xcodeproj/project.pbxproj#L1228
Am I missing something?

Also this is the stack trace:

(
	0   CoreFoundation                      0x000000010bd971bb __exceptionPreprocess + 331
	1   libobjc.A.dylib                     0x0000000109dc3735 objc_exception_throw + 48
	2   CoreFoundation                      0x000000010bdb5f44 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
	3   CoreFoundation                      0x000000010bd9bed6 ___forwarding___ + 1446
	4   CoreFoundation                      0x000000010bd9dda8 _CF_forwarding_prep_0 + 120
	5   trustkitfirebasesample              0x0000000107536372 -[GTMSessionFetcherService fetcherDidBeginFetching:] + 402
	6   trustkitfirebasesample              0x000000010751102b -[GTMSessionFetcher beginFetchMayDelay:mayAuthorize:] + 11099
	7   trustkitfirebasesample              0x000000010750d419 -[GTMSessionFetcher beginFetchWithCompletionHandler:] + 329
	8   trustkitfirebasesample              0x00000001073ec14f -[FIRAuthBackendRPCIssuerImplementation asyncPostToURLWithRequestConfiguration:URL:body:contentType:completionHandler:] + 1023
	9   trustkitfirebasesample              0x00000001073ef9ff -[FIRAuthBackendRPCImplementation postWithRequest:response:callback:] + 1087
	10  trustkitfirebasesample              0x00000001073ed33b -[FIRAuthBackendRPCImplementation verifyCustomToken:callback:] + 299
	11  trustkitfirebasesample              0x00000001073eb34b +[FIRAuthBackend verifyCustomToken:callback:] + 123
	12  trustkitfirebasesample              0x00000001073df93e -[FIRAuth internalSignInAndRetrieveDataWithCustomToken:completion:] + 286
	13  trustkitfirebasesample              0x00000001073d7c97 __44-[FIRAuth signInWithCustomToken:completion:]_block_invoke + 183
	14  libdispatch.dylib                   0x000000010dfa6595 _dispatch_call_block_and_release + 12
	15  libdispatch.dylib                   0x000000010dfa7602 _dispatch_client_callout + 8
	16  libdispatch.dylib                   0x000000010dfaeb0b _dispatch_lane_serial_drain + 791
	17  libdispatch.dylib                   0x000000010dfaf784 _dispatch_lane_invoke + 428
	18  libdispatch.dylib                   0x000000010dfb989a _dispatch_workloop_worker_thread + 733
	19  libsystem_pthread.dylib             0x000000010e378fd2 _pthread_wqthread + 980
	20  libsystem_pthread.dylib             0x000000010e378be9 start_wqthread + 13
)

@morganchen12
Copy link
Contributor

Linker flags look fine to me. @renkelvin can you take a look?

@renkelvin
Copy link
Contributor

Hi all, I believe it's not an issue with the Auth SDK. GTMSessionFetcher is our main entry point talking to backend. All requests would fail if GTMSessionFetcher is not properly linked. Could you try other apis to see if it's the same issue?

@paulb777
Copy link
Member

@eyalevy Please share the Podfile and Podfile.lock so we can check if there's something strange about the versions being used.

@eyalevy
Copy link
Author

eyalevy commented Mar 12, 2019

Sure, the links for Podfile and Podfile.lock:

I want to add that this issue happened when we upgrade Firebase SDK version from version 4.9 to version 5.15. when I downgrade Firebase SDK to version 4.9 the app is not crashing.

@eyalevy
Copy link
Author

eyalevy commented Mar 13, 2019

@renkelvin I tried to use firebase storage for getting a file and I succeed to read it.

@eyalevy
Copy link
Author

eyalevy commented Mar 19, 2019

@renkelvin @paulb777 did any of you experience this error?

@maksymmalyhin
Copy link
Contributor

@eyalevy I wonder, if you can reproduce the crash if you remove pod 'TrustKit'. From the first glance, TrustKit does method swizzling on NSURLSessionDelegate which could be a reason of the issue.

If we know this we may narrow down the issue search area. Thanks.

@eyalevy
Copy link
Author

eyalevy commented Mar 19, 2019

@maksymmalyhin when I disable swizzling or remove TrustKit completely the issue doesn't reproduce.

I want to add that we did not add TrustKit recently. The last change we did is to upgrade Firebase SDK from version 4.9 to version 5.15. With Firebase SDK v4.9 and TrustKit the issue doesn't reproduce as well.

@maksymmalyhin
Copy link
Contributor

@eyalevy Thank you for the quick response. We will investigate how we can fix it.

@maksymmalyhin
Copy link
Contributor

maksymmalyhin commented Mar 19, 2019

It looks like there is an open PR to fix the issue google/gtm-session-fetcher#130

@paulb777
Copy link
Member

It looks like the google/gtm-session-fetcher#130 creator stopped responding to the reviewer's questions months ago, so the discussion would need to be revived.

@eyalevy
Copy link
Author

eyalevy commented Mar 31, 2019

I commented in google/gtm-session-fetcher#130.
I hope the fix will be merged soon

@morganchen12
Copy link
Contributor

This should be fixed with google/gtm-session-fetcher#142. Please comment here if you run into the issue again.

@thetminko
Copy link

I am experiencing this issue.
How can I fix this issue?
I am using Firebase and Trustkit

@morganchen12
Copy link
Contributor

@thetminko can you share your stack trace and Firebase versions?

@thetminko
Copy link

thetminko commented Aug 27, 2019

@morganchen12 Thanks for replying. These are my env and logs.

--- Podfile ---
pod 'Firebase/Auth', '> 6.2.0'
pod 'Firebase/Core', '
> 6.2.0'
pod 'Firebase/Messaging', '> 6.2.0'
pod 'TrustKit', '
> 1.6.2'

--- Podfile.lock ---

  • Fabric (1.10.2)
  • Firebase/Auth (6.2.0):
    • Firebase/CoreOnly
    • FirebaseAuth (~> 6.1.1)
  • Firebase/Core (6.2.0):
    • Firebase/CoreOnly
    • FirebaseAnalytics (= 6.0.1)
  • Firebase/CoreOnly (6.2.0):
    • FirebaseCore (= 6.0.2)
  • Firebase/Messaging (6.2.0):
    • Firebase/CoreOnly
    • FirebaseMessaging (~> 4.0.2)
  • FirebaseAnalytics (6.0.1):
    • FirebaseCore (~> 6.0)
    • FirebaseInstanceID (~> 4.1)
    • GoogleAppMeasurement (= 6.0.1)
    • GoogleUtilities/AppDelegateSwizzler (~> 6.0)
    • GoogleUtilities/MethodSwizzler (~> 6.0)
    • GoogleUtilities/Network (~> 6.0)
    • "GoogleUtilities/NSData+zlib (~> 6.0)"
    • nanopb (~> 0.3)
  • FirebaseAnalyticsInterop (1.4.0)
  • FirebaseAuth (6.1.2):
    • FirebaseAuthInterop (~> 1.0)
    • FirebaseCore (~> 6.0)
    • GoogleUtilities/AppDelegateSwizzler (~> 6.2)
    • GoogleUtilities/Environment (~> 6.2)
    • GTMSessionFetcher/Core (~> 1.1)
  • FirebaseAuthInterop (1.0.0)
  • FirebaseCore (6.0.2):
    • GoogleUtilities/Environment (~> 6.0)
    • GoogleUtilities/Logger (~> 6.0)
  • FirebaseInstanceID (4.2.3):
    • FirebaseCore (~> 6.0)
    • GoogleUtilities/Environment (~> 6.0)
    • GoogleUtilities/UserDefaults (~> 6.0)
  • FirebaseMessaging (4.0.2):
    • FirebaseAnalyticsInterop (~> 1.1)
    • FirebaseCore (~> 6.0)
    • FirebaseInstanceID (~> 4.1)
    • GoogleUtilities/AppDelegateSwizzler (~> 6.2)
    • GoogleUtilities/Environment (~> 6.2)
    • GoogleUtilities/Reachability (~> 6.2)
    • GoogleUtilities/UserDefaults (~> 6.2)
    • Protobuf (~> 3.1)

--- Error Logs ---

2019-08-27 10:12:59.773214+0800 PAB[19389:4469184] === TrustKit: Proxy-ing NSURLSessionDelegate: GTMSessionFetcher
2019-08-27 10:12:59.773320+0800 PAB[19389:4469184] Fetcher delegate class: TSKNSURLSessionDelegateProxy
2019-08-27 10:12:59.773424+0800 PAB[19389:4469184] Fetcher made an extra session: GTMSessionFetcher 0x104c68b20 (https://www.googleapis.com/identitytoolkit/v3/relyingparty/sendVerificationCode?key=AIzaSyDOYUzUrIfsdJG92KwrPNTYdJWp6MrVF-U)
2019-08-27 10:12:59.773456+0800 PAB[19389:4469184] Couldn't assign delegate.
2019-08-27 10:12:59.773764+0800 PAB[19389:4469184] Fetcher delegate class: TSKNSURLSessionDelegateProxy
2019-08-27 10:12:59.773823+0800 PAB[19389:4469184] -[GTMSessionFetcher setFetcher:forTask:]: unrecognized selector sent to instance 0x104c68b20
2019-08-27 10:12:59.773998+0800 PAB[19389:4469184] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GTMSessionFetcher setFetcher:forTask:]: unrecognized selector sent to instance 0x104c68b20'
*** First throw call stack:
(0x193e5a98c 0x1930339f8 0x193d771c8 0x193e601d4 0x193e61e6c 0x1023ac4d4 0x10238a20c 0x102386a48 0x102277b20 0x10227a7e8 0x1022797bc 0x102277284 0x10229b428 0x10229b960 0x10229af74 0x10229ab88 0x102285650 0x1022852dc 0x10226e520 0x104868c78 0x104877480 0x10226e444 0x10226dfec 0x193e62010 0x193d43be0 0x1023e06b4 0x1023de918 0x193d463c8 0x1023de720 0x1023e0500 0x102284ff0 0x1048676f4 0x104868c78 0x1048766fc 0x193dec32c 0x193de7264 0x193de67c0 0x195fe779c 0x1c08e5c38 0x102246418 0x1938aa8e0)
libc++abi.dylib: terminating with uncaught exception of type NSException

--- Stacktrace ---

* thread #1, queue = 'com.google.firebase.auth.globalWorkQueue', stop reason = signal SIGABRT
    frame #0: 0x00000001939f70dc libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x0000000193a749b0 libsystem_pthread.dylib`pthread_kill$VARIANT$armv81 + 296
    frame #2: 0x000000019394fea8 libsystem_c.dylib`abort + 140
    frame #3: 0x000000019301c788 libc++abi.dylib`abort_message + 132
    frame #4: 0x000000019301c934 libc++abi.dylib`default_terminate_handler() + 308
    frame #5: 0x0000000193033e00 libobjc.A.dylib`_objc_terminate() + 124
    frame #6: 0x0000000193028838 libc++abi.dylib`std::__terminate(void (*)()) + 16
    frame #7: 0x00000001930288c4 libc++abi.dylib`std::terminate() + 84
    frame #8: 0x0000000193033d5c libobjc.A.dylib`objc_terminate + 12
    frame #9: 0x000000010627cc8c libdispatch.dylib`_dispatch_client_callout + 36
    frame #10: 0x000000010628b480 libdispatch.dylib`_dispatch_lane_barrier_sync_invoke_and_complete + 124
  * frame #11: 0x00000001041d2278 PAB`-[FIRAuth setAPNSToken:type:](self=0x0000000283a1d680, _cmd="setAPNSToken:type:", token=32 bytes, type=FIRAuthAPNSTokenTypeUnknown) at FIRAuth.m:1371:3
    frame #12: 0x00000001041d1d50 PAB`-[FIRAuth application:didRegisterForRemoteNotificationsWithDeviceToken:](self=0x0000000283a1d680, _cmd="application:didRegisterForRemoteNotificationsWithDeviceToken:", application=0x0000000106b07f90, deviceToken=32 bytes) at FIRAuth.m:1336:3
    frame #13: 0x0000000193e62010 CoreFoundation`__invoking___ + 144
    frame #14: 0x0000000193d43be0 CoreFoundation`-[NSInvocation invoke] + 292
    frame #15: 0x0000000104343cbc PAB`__93-[GULAppDelegateSwizzler application:donor_didRegisterForRemoteNotificationsWithDeviceToken:]_block_invoke(.block_descriptor=0x000000016bc5a780, interceptor=0x0000000283a1d680) at GULAppDelegateSwizzler.m:849:37
    frame #16: 0x0000000104342918 PAB`__72+[GULAppDelegateSwizzler notifyInterceptorsWithMethodSelector:callback:]_block_invoke(.block_descriptor=0x000000016bc5a6e0, key=@"GUL_0x283a1d680", obj=0x0000000280910e00, stop=NO) at GULAppDelegateSwizzler.m:680:7
    frame #17: 0x0000000193d463c8 CoreFoundation`-[__NSFrozenDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 176
    frame #18: 0x0000000104342720 PAB`+[GULAppDelegateSwizzler notifyInterceptorsWithMethodSelector:callback:](self=GULAppDelegateSwizzler, _cmd="notifyInterceptorsWithMethodSelector:callback:", methodSelector="application:didRegisterForRemoteNotificationsWithDeviceToken:", callback=0x0000000104343b9c) at GULAppDelegateSwizzler.m:667:3
    frame #19: 0x0000000104343b08 PAB`-[GULAppDelegateSwizzler application:donor_didRegisterForRemoteNotificationsWithDeviceToken:](self=0x0000000280b006c0, _cmd="application:didRegisterForRemoteNotificationsWithDeviceToken:", application=0x0000000106b07f90, deviceToken=32 bytes) at GULAppDelegateSwizzler.m:840:3
    frame #20: 0x000000010627b6f4 libdispatch.dylib`_dispatch_call_block_and_release + 24
    frame #21: 0x000000010627cc78 libdispatch.dylib`_dispatch_client_callout + 16
    frame #22: 0x000000010628a6fc libdispatch.dylib`_dispatch_main_queue_callback_4CF + 1360
    frame #23: 0x0000000193dec32c CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
    frame #24: 0x0000000193de7264 CoreFoundation`__CFRunLoopRun + 1924
    frame #25: 0x0000000193de67c0 CoreFoundation`CFRunLoopRunSpecific + 436
    frame #26: 0x0000000195fe779c GraphicsServices`GSEventRunModal + 104
    frame #27: 0x00000001c08e5c38 UIKitCore`UIApplicationMain + 212
    frame #28: 0x00000001041aa418 PAB`main(argc=2, argv=0x000000016bc5b7d8) at main.m:14:13
    frame #29: 0x00000001938aa8e0 libdyld.dylib`start + 4

@firebase firebase locked and limited conversation to collaborators Oct 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants