Skip to content

FirebaseUI / FirebaseAuth Crash on phone number validation #476

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

Closed
gelosi opened this issue Jul 11, 2018 · 17 comments
Closed

FirebaseUI / FirebaseAuth Crash on phone number validation #476

gelosi opened this issue Jul 11, 2018 · 17 comments
Assignees
Labels

Comments

@gelosi
Copy link

gelosi commented Jul 11, 2018

Welcome to FirebaseUI and thanks for submitting an issue!

✅ Please take a look at open issues, as well as resolved issues, to see if your issue is either already being addressed, or has been solved by someone else.

✅ If your issue concerns the CocoaPods error, "...transitive dependencies that include static binaries", please take a look at any of the following issues and see if your problem is solved: #48, #47, #46, #34, #23.

If not, please feel free to fill in the following info so we can help faster!

Step 1: Are you in the right place?

  • I'm in the right place * ✅

  • For issues or feature requests related to the code in this repository file a GitHub issue.

  • For general technical questions, post a question on StackOverflow tagged appropriately.

  • For general Firebase discussion, use the firebase-talk google group

  • For help troubleshooting your application that does not fall under one of the above categories, reach out to the personalized Firebase support channel

Step 2: Describe your environment

  • Objective C
  • iOS version: 11.4
  • Firebase SDK version: 5.0.2
  • FirebaseUI version: 5.0.1
  • CocoaPods Version: 1.5.3

Step 3: Describe the problem:

Getting a crash inside Firebase components logic. (right after typing in phone number and taping 'Verify')

I understand it can be wrong use of GTMSessionFetcher in the Firebase Auth code, but also, crash happens inside this code: GTMSessionFetcherService fetcherDidBeginFetching:

Maybe you can suggest at least correct configuration for session fetcher to work properly?

Steps to reproduce:

  1. open Firebase Phone login page (see code example below)
  2. input your phone number
  3. press "Verify'
    💥

Observed Results:

Fatal Exception: NSInvalidArgumentException-[GTMSessionFetcher setFetcher:forTask:]: unrecognized selector sent to instance 0x10e429360 Raw Text
--
0 | CoreFoundation | __exceptionPreprocess
4 | CoreFoundation | _CF_forwarding_prep_0
5 | GTMSessionFetcher | GTMSessionFetcherService.m line 441-[GTMSessionFetcherService fetcherDidBeginFetching:]
6 | GTMSessionFetcher | GTMSessionFetcher.m line 894-[GTMSessionFetcher beginFetchMayDelay:mayAuthorize:]
7 | - | FIRAuthBackend.m line 545-[FIRAuthBackendRPCIssuerImplementation asyncPostToURLWithRequestConfiguration:URL:body:contentType:completionHandler:]
8 | - | FIRAuthBackend.m line 809-[FIRAuthBackendRPCImplementation postWithRequest:response:callback:]
9 | - | FIRAuthBackend.m line 701-[FIRAuthBackendRPCImplementation sendVerificationCode:callback:]
10 | - | FIRAuthBackend.m line 469+[FIRAuthBackend sendVerificationCode:callback:]
11 | - | FIRPhoneAuthProvider.m line 401__110-[FIRPhoneAuthProvider verifyClientAndSendVerificationCodeToPhoneNumber:retryOnInvalidAppCredential:callback:]_block_invoke.205
12 | - | FIRPhoneAuthProvider.m line 410-[FIRPhoneAuthProvider verifyClientWithCompletion:]
13 | - | FIRPhoneAuthProvider.m line 402-[FIRPhoneAuthProvider verifyClientAndSendVerificationCodeToPhoneNumber:retryOnInvalidAppCredential:callback:]
14 | - | FIRPhoneAuthProvider.m line 340__61-[FIRPhoneAuthProvider internalVerifyPhoneNumber:completion:]_block_invoke
15 | - | FIRAuthNotificationManager.m line 173-[FIRAuthNotificationManager callBack]
16 | - | FIRAuthNotificationManager.m line 146-[FIRAuthNotificationManager canHandleNotification:]
17 | - | FIRAuth.m line 1412__33-[FIRAuth canHandleNotification:]_block_invoke

Expected Results:

  • Would like to proceed to the SMS code entry page

Relevant Code:

Here's how I'm using FirebaseAuth

FUIAuth *authUI = [FUIAuth defaultAuthUI];
  authUI.signInWithEmailHidden = YES;
  authUI.delegate = self;
  
  FUIPhoneAuth *provider = [[FUIPhoneAuth alloc] initWithAuthUI:authUI];
  authUI.providers = @[provider];
  [provider signInWithPresentingViewController:vc phoneNumber:mobileNumber];
@morganchen12
Copy link
Contributor

Can you try adding the -ObjC linker flag to your build settings and running it again?

@gelosi
Copy link
Author

gelosi commented Jul 11, 2018

@morganchen12 it's there, I'm using a lot of ObjC stuff from pods... Was checking before submitting, actually.

@morganchen12
Copy link
Contributor

Can you share your project?

@morganchen12 morganchen12 self-assigned this Jul 13, 2018
@gelosi
Copy link
Author

gelosi commented Jul 14, 2018

Hello @morganchen12 - want to save your eyes from bleeding, and my ass from infringement,
I'm happy to give you some part of data, let's start from OTHER_LDFLAGS :

grep "OTHER_LDFLAGS" -R . | grep GTM

./Pods/Target Support Files/GTMSessionFetcher/GTMSessionFetcher.xcconfig:OTHER_LDFLAGS = -framework "Security"

grep "OTHER_LDFLAGS" -R . | grep Firebase

./Pods/Target Support Files/FirebaseCore/FirebaseCore.xcconfig:OTHER_LDFLAGS = -framework "Foundation" -framework "SystemConfiguration" ./Pods/Target Support Files/FirebaseAuth/FirebaseAuth.xcconfig:OTHER_LDFLAGS = -framework "Security" ./Pods/Target Support Files/FirebaseUI/FirebaseUI.xcconfig:OTHER_LDFLAGS = -framework "UIKit"

Meanwhile, main project configured that way:

./Pods/Target Support Files/Pods-☣️-dev/Pods-☣️-dev.release.xcconfig:OTHER_LDFLAGS = $(inherited) -ObjC -l"CardIO" -l"GoogleAnalytics" -l"c++" -l"opencv_core" -l"opencv_imgproc" -l"sqlite3" -l"z" -framework "AFNetworking" -framework "AVFoundation" -framework "Accelerate" -framework "AudioToolbox" -framework "Bolts" -framework "CMPopTipView" -framework "CRToast" -framework "CoreData" -framework "CoreGraphics" -framework "CoreLocation" -framework "CoreMedia" -framework "CoreVideo" -framework "Crashlytics" -framework "FBSDKCoreKit" -framework "Fabric" -framework "FirebaseAuth" -framework "FirebaseCore" -framework "FirebaseUI" -framework "Foundation" -framework "GTMSessionFetcher" -framework "GoogleMapsBase" -framework "GooglePlaces" -framework "GoogleToolboxForMac" -framework "MessageThrottle" -framework "MobileCoreServices" -framework "NKJWT" -framework "OpenGLES" -framework "QuartzCore" -framework "SCLAlertView_Objective_C" -framework "Security" -framework "Stripe" -framework "SystemConfiguration" -framework "Toast" -framework "TrustKit" -framework "UICKeyChainStore" -framework "UIKit" -framework "☣️Core" -framework "libPhoneNumber_iOS"

@gelosi
Copy link
Author

gelosi commented Jul 14, 2018

Actually, I see now where's -ObjC is missing...

@morganchen12
Copy link
Contributor

Your comment seems to be missing the flags for your main app target (shows only Pod targets, unless I'm mistaken). Were you able to solve this?

@NickolaySheika
Copy link

@gelosi hi, i'm having the same issue. Did you manage to fix it? Could you please provide more details?

@NickolaySheika
Copy link

My issue was resolved only by moving back to FirebaseAuth 4.6.1 (version that I previously used) instead of the latest 5.0.4 atm.

@gelosi
Copy link
Author

gelosi commented Oct 5, 2018

@morganchen12 @hawk-ukr hi there. I’ts a while since I’ve opened this ticket. Having crazy time now :/
Here’s insights I have:

  1. swizzzzlinggg — if you also using something like TrustKit from Twitter — your url session delegate can be double swizzled.
  2. Firebase might re—use url session object — and at some point — It’s a problem — maybe object is deallocated at some point (this I’m not completely sure, need a good piece of time to build a trap for that bug)
    Hope it helps

@thetminko
Copy link

How is this issue fixed?

@morganchen12
Copy link
Contributor

@thetminko please open a new issue with your project configuration and the crash stack trace.

@gelosi
Copy link
Author

gelosi commented Aug 27, 2019

@thetminko issue is inside another dependency: google session fetcher

there's approved MR solving the issue; make sure you're on the latest pods, then you should be fine; or it's something new :)

https://github.com/google/gtm-session-fetcher/pull/142/files

@thetminko
Copy link

thetminko commented Aug 28, 2019

@gelosi I was using pod version 1.7.5.
This is my Podfile.lock
FirebaseAuth (6.1.2):
FirebaseAuthInterop (> 1.0)
FirebaseCore (
> 6.0)
GoogleUtilities/AppDelegateSwizzler (> 6.2)
GoogleUtilities/Environment (
> 6.2)
GTMSessionFetcher/Core (~> 1.1)

Is it because FirebaseAuth was using GTMSessionFetcher 1.1? I saw the fix is in 1.2.2.

This is my env. If there is no mistake, I will log a new issue.
-- 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 Fixed issue w/ already registered cells. #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.dylibpthread_kill$VARIANT$armv81 + 296
    frame Firebaseui 0.2.0 #2: 0x000000019394fea8 libsystem_c.dylibabort + 140 frame #3: 0x000000019301c788 libc++abi.dylibabort_message + 132
    frame 0.2.3 Release Candidate #4: 0x000000019301c934 libc++abi.dylibdefault_terminate_handler() + 308 frame #5: 0x0000000193033e00 libobjc.A.dylib_objc_terminate() + 124
    frame OSX Support #6: 0x0000000193028838 libc++abi.dylibstd::__terminate(void (*)()) + 16 frame #7: 0x00000001930288c4 libc++abi.dylibstd::terminate() + 84
    frame Ability to have sections in FirebaseTableViewDataSource #8: 0x0000000193033d5c libobjc.A.dylibobjc_terminate + 12 frame #9: 0x000000010627cc8c libdispatch.dylib_dispatch_client_callout + 36
    frame NSSortDescriptors #10: 0x000000010628b480 libdispatch.dylib`_dispatch_lane_barrier_sync_invoke_and_complete + 124
    • frame XCode 7 Issue! #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 Sectioning #13: 0x0000000193e62010 CoreFoundation__invoking___ + 144 frame #14: 0x0000000193d43be0 CoreFoundation-[NSInvocation invoke] + 292
      frame return receipt observeEventType who receive my message !  #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 Add -initWithQuery:(FQuery *) to Firebase*DataSource #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 Pull request #13 sections crash #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 [0.3 RC] Adding Authentication to FirebaseUI #21: 0x000000010627cc78 libdispatch.dylib_dispatch_client_callout + 16 frame #22: 0x000000010628a6fc libdispatch.dylib_dispatch_main_queue_callback_4CF + 1360
      frame Error about transitive dependencies that include static binaries #23: 0x0000000193dec32c CoreFoundation__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 frame #24: 0x0000000193de7264 CoreFoundation__CFRunLoopRun + 1924
      frame Upgrade to Google Sign In Button (rather than G+ button) #25: 0x0000000193de67c0 CoreFoundationCFRunLoopRunSpecific + 436 frame #26: 0x0000000195fe779c GraphicsServicesGSEventRunModal + 104
      frame setup.sh does not correctly extract GoogleSignIn #27: 0x00000001c08e5c38 UIKitCoreUIApplicationMain + 212 frame #28: 0x00000001041aa418 PABmain(argc=2, argv=0x000000016bc5b7d8) at main.m:14:13
      frame RESTful fallback for large datasets #29: 0x00000001938aa8e0 libdyld.dylib`start + 4

@gelosi
Copy link
Author

gelosi commented Aug 28, 2019

@thetminko Yepp, try to update GTMSessionFetcher pod

@thetminko
Copy link

@gelosi,
I tried using
Pod 'Firebase/Auth' instead of specifying the version.
This installed 6.7.0 version.
It is still crashing.

This is my Podfile.lock

  • Firebase/Auth (6.7.0):
    • Firebase/CoreOnly
    • FirebaseAuth (~> 6.2.3)
  • Firebase/CoreOnly (6.7.0):
    • FirebaseCore (= 6.2.1)
  • FirebaseAuth (6.2.3):
    • FirebaseAuthInterop (~> 1.0)
    • FirebaseCore (~> 6.2)
    • GoogleUtilities/AppDelegateSwizzler (~> 6.2)
    • GoogleUtilities/Environment (~> 6.2)
    • GTMSessionFetcher/Core (~> 1.1)
  • FirebaseAuthInterop (1.0.0)

@gelosi
Copy link
Author

gelosi commented Aug 28, 2019

well, yepp, looking at firebase's dependencies:
https://github.com/firebase/firebase-ios-sdk/blob/5fd5ed2131730bf8806b405410d1dd8ddda37ecf/FirebaseAuth.podspec#L68

we can tell, it's still using buggy version of fetcher ¯_(ツ)_/¯

maybe you can try cloning firebase, updating dependency and use it for yourself now,
also – if it fixes your problem – you can send back MR

@thetminko
Copy link

@gelosi Thanks and appreciate for helping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants