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

Complition handler InstanceID.instanceID().instanceID is not called after FirebaseApp.configure() #2445

Closed
MamuninaNV opened this issue Feb 26, 2019 · 21 comments

Comments

@MamuninaNV
Copy link

commented Feb 26, 2019

[READ] Step 1: Are you in the right place?

Yes

[REQUIRED] Step 2: Describe your environment

  • Xcode version: 10.1 (10B61)
  • Firebase SDK version: 5.17.0
  • Firebase Component: Core
  • Component version: 5.3.0

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

following is in my pod file of a new project

  pod 'Firebase/Core', '~> 5.17.0'

Relevant Code:

Completion handler NEVER get called. Nor result or error

import Firebase
import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        FirebaseApp.configure()
        InstanceID.instanceID().instanceID { (result, error) in
                // Not called
        }

        return true
    }
}

But if add delay, like that:

        DispatchQueue.main.asyncAfter(deadline: (.now() + 0.3)) {
            InstanceID.instanceID().instanceID { (result, error) in
                // Get called
            }
        }

All is work

@ryanwilson

This comment has been minimized.

Copy link
Member

commented Feb 26, 2019

Thanks for the report, I'll try to reproduce this shortly and report back here. cc @chliangGoogle

@paulb777 paulb777 removed the api: core label Feb 26, 2019

@ryanwilson

This comment has been minimized.

Copy link
Member

commented Feb 26, 2019

@MamuninaNV I'm unable to reproduce the issue. Are you able to add a print statement and share the logs from the console in Xcode? A project that I can drag my own GoogleService-Info.plist into would work as well.

@MamuninaNV

This comment has been minimized.

Copy link
Author

commented Feb 26, 2019

TestFirebase.zip
I'm uploading a project.
When you first time to launch the project on your device or simulator you can see the issue (only first time). If project is relaunch on device (or on simulator) you will not see the issue. This issue is occur in first launch on device (simulator)

@MamuninaNV

This comment has been minimized.

Copy link
Author

commented Feb 26, 2019

2019-02-26 19:25:49.060474+0300 TestFirebase[11218:529690]  - <AppMeasurement>[I-ACS036002] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
2019-02-26 19:25:49.093771+0300 TestFirebase[11218:529628] libMobileGestalt MobileGestalt.c:890: MGIsDeviceOneOfType is not supported on this platform.
2019-02-26 19:25:49.259003+0300 TestFirebase[11218:529692] 5.17.0 - [Firebase/Analytics][I-ACS023007] Analytics v.50600000 started
2019-02-26 19:25:49.259263+0300 TestFirebase[11218:529692] 5.17.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2019-02-26 19:25:49.461358+0300 TestFirebase[11218:529708] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x7fdf46402220] get output frames failed, state 8196
2019-02-26 19:25:49.461619+0300 TestFirebase[11218:529708] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x7fdf46402220] get output frames failed, state 8196
2019-02-26 19:25:49.462384+0300 TestFirebase[11218:529708] TIC Read Status [1:0x0]: 1:57
2019-02-26 19:25:49.462519+0300 TestFirebase[11218:529708] TIC Read Status [1:0x0]: 1:57
2019-02-26 19:26:04.115245+0300 TestFirebase[11218:529830] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C4.1:2][0x7fdf46409690] get output frames failed, state 8196
2019-02-26 19:26:04.115453+0300 TestFirebase[11218:529830] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C4.1:2][0x7fdf46409690] get output frames failed, state 8196
2019-02-26 19:26:04.115860+0300 TestFirebase[11218:529830] TIC Read Status [4:0x0]: 1:57
2019-02-26 19:26:04.115996+0300 TestFirebase[11218:529830] TIC Read Status [4:0x0]: 1:57
2019-02-26 19:26:04.240042+0300 TestFirebase[11218:529691] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C5.1:2][0x7fdf46413d50] get output frames failed, state 8196
2019-02-26 19:26:04.240221+0300 TestFirebase[11218:529691] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C5.1:2][0x7fdf46413d50] get output frames failed, state 8196
2019-02-26 19:26:04.240740+0300 TestFirebase[11218:529691] TIC Read Status [5:0x0]: 1:57
2019-02-26 19:26:04.240959+0300 TestFirebase[11218:529691] TIC Read Status [5:0x0]: 1:57
@ryanwilson

This comment has been minimized.

Copy link
Member

commented Feb 26, 2019

Ah got it, thanks! I found the reason why this is happening:

if (self.isFetchingDefaultToken || self.isDefaultTokenFetchScheduled) {

It looks like self.isFetchingDefaultToken is true because it's being fetched already as part of the startup of InstanceID when there's no token available. My first thought would be to check if this handler is the same as the one used previously and use both handlers that have registered, but that may be quite a large change and there could be something better.

@chliangGoogle can you please take a look?

Thanks again @MamuninaNV for catching this.

@chliangGoogle chliangGoogle self-assigned this Feb 26, 2019

@ryanwilson

This comment has been minimized.

Copy link
Member

commented Mar 12, 2019

Reassigning to @maksymmalyhin who has some more bandwidth to look at it.

maksymmalyhin added a commit that referenced this issue Mar 24, 2019
@maksymmalyhin

This comment has been minimized.

Copy link
Contributor

commented Mar 25, 2019

Fixed in #2559

@MamuninaNV

This comment has been minimized.

Copy link
Author

commented Mar 26, 2019

Thanks you all :)

@falipate

This comment has been minimized.

Copy link

commented Mar 28, 2019

@maksymmalyhin Would you happen to know when this will be released?

@maksymmalyhin

This comment has been minimized.

Copy link
Contributor

commented Mar 28, 2019

@falipate It should be available in the next version.

@paulb777 paulb777 added this to the 5.20.0 milestone Mar 28, 2019

@paulb777

This comment has been minimized.

Copy link
Member

commented Mar 28, 2019

Added to the 5.20.0 milestone.

@AmandineDB

This comment has been minimized.

Copy link

commented Apr 5, 2019

Hello,

do you know the version of the library that corrects this problem?
I still have this problem with the pod updated :

Using Firebase (5.20.1)
Using FirebaseABTesting (2.0.0)
Using FirebaseAnalytics (5.8.0)
Using FirebaseAnalyticsInterop (1.2.0)
Using FirebaseCore (5.4.1)
Using FirebaseInAppMessaging (0.13.0)
Using FirebaseInAppMessagingDisplay (0.13.1)
Using FirebaseInstanceID (3.8.1)
Using FirebaseMessaging (3.5.0)
Using FirebasePerformance (2.2.4)
Using FirebaseRemoteConfig (3.1.0)

thanks

@ahmedAlmasri

This comment has been minimized.

Copy link

commented Apr 18, 2019

Hello ,

I still have same issue my pod version

Using Firebase (5.20.1)
Using FirebaseAnalytics (5.8.0)
Using FirebaseAnalyticsInterop (1.2.0)
Using FirebaseCore (5.4.1)
Using FirebaseDynamicLinks (3.4.3)
Using FirebaseInstanceID (3.8.1)
Using FirebaseMessaging (3.5.0)

@AmandineDB

This comment has been minimized.

Copy link

commented Apr 18, 2019

@ahmedAlmasri I had have backup my pod file and i restore it on an older version

@maksymmalyhin

This comment has been minimized.

Copy link
Contributor

commented Apr 18, 2019

@ahmedAlmasri @AmandineDB I am not able to reproduce the issue with the originally provided test project and steps. Would you be able to provide updated ones please? If the steps are different, it may make sense to create a separate ticket. Thanks.

@ahmedAlmasri

This comment has been minimized.

Copy link

commented Apr 18, 2019

@maksymmalyhin The same steps , But do not occur every time

@AmandineDB

This comment has been minimized.

Copy link

commented Apr 23, 2019

hello @maksymmalyhin,

not exactly the same steps.

I call
FirebaseApp.configure() on my
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool

and after a login I ask to register for APNS

`func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Messaging.messaging().apnsToken = deviceToken

	InstanceID.instanceID().instanceID(handler: { (result, error) in

//not enter here
if let error = error {

				print("Error fetching remote instance ID: \(error)")

			} else if let result = result {

			}
		})

}`

so I had have backup my pod file and i restore it on an older version

and all is ok

Have a good day

@litianurazvan

This comment has been minimized.

Copy link

commented Apr 23, 2019

hi @AmandineDB. I'm experiencing the same issue as you. Could you please provide the version you rolled back to?

@AmandineDB

This comment has been minimized.

Copy link

commented Apr 23, 2019

this is an extract of my podfile.lock :

  • Firebase/Core (5.19.0):
    • Firebase/CoreOnly
    • FirebaseAnalytics (= 5.8.0)
    • Firebase/CoreOnly (5.19.0):
      • FirebaseCore (= 5.4.0)
    • Firebase/InAppMessagingDisplay (5.19.0):
      • Firebase/CoreOnly
      • FirebaseInAppMessagingDisplay (= 0.13.1)
    • Firebase/Messaging (5.19.0):
      • Firebase/CoreOnly
      • FirebaseMessaging (= 3.4.0)
    • Firebase/Performance (5.19.0):
      • Firebase/Core
      • FirebasePerformance (= 2.2.4)
    • FirebaseABTesting (2.0.0):
      • FirebaseCore (~> 5.0)
      • Protobuf (~> 3.5)
    • FirebaseAnalytics (5.8.0):
      • FirebaseCore (~> 5.4)
      • FirebaseInstanceID (~> 3.8)
      • GoogleAppMeasurement (= 5.8.0)
      • GoogleUtilities/AppDelegateSwizzler (~> 5.2)
      • GoogleUtilities/MethodSwizzler (~> 5.2)
      • GoogleUtilities/Network (~> 5.2)
      • "GoogleUtilities/NSData+zlib (~> 5.2)"
      • nanopb (~> 0.3)
    • FirebaseAnalyticsInterop (1.2.0)
    • FirebaseCore (5.4.0):
      • GoogleUtilities/Environment (~> 5.2)
      • GoogleUtilities/Logger (~> 5.2)
    • FirebaseInAppMessaging (0.13.0):
      • FirebaseAnalytics
      • FirebaseAnalyticsInterop
      • FirebaseCore
      • FirebaseInstanceID
    • FirebaseInAppMessagingDisplay (0.13.1):
      • FirebaseCore
      • FirebaseInAppMessaging (>= 0.12.0)
    • FirebaseInstanceID (3.8.0):
      • FirebaseCore (~> 5.2)
      • GoogleUtilities/Environment (~> 5.2)
      • GoogleUtilities/UserDefaults (~> 5.2)
    • FirebaseMessaging (3.4.0):
      • FirebaseAnalyticsInterop (~> 1.1)
      • FirebaseCore (~> 5.2)
      • FirebaseInstanceID (~> 3.6)
      • GoogleUtilities/Environment (~> 5.3)
      • GoogleUtilities/Reachability (~> 5.3)
      • GoogleUtilities/UserDefaults (~> 5.3)
      • Protobuf (~> 3.1)
    • FirebasePerformance (2.2.4):
      • FirebaseAnalytics (~> 5.8)
      • FirebaseInstanceID (~> 3.8)
      • FirebaseRemoteConfig (~> 3.1)
      • GoogleToolboxForMac/Logger (~> 2.1)
      • "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
      • GoogleUtilities/ISASwizzler (~> 5.2)
      • GoogleUtilities/MethodSwizzler (~> 5.2)
      • GTMSessionFetcher/Core (~> 1.1)
      • Protobuf (~> 3.5)
    • FirebaseRemoteConfig (3.1.0):
      • FirebaseABTesting (~> 2.0)
      • FirebaseAnalytics (~> 5.3)
      • FirebaseCore (~> 5.1)
      • FirebaseInstanceID (~> 3.3)
      • GoogleUtilities/Environment (~> 5.2)
      • "GoogleUtilities/NSData+zlib (~> 5.2)"
      • Protobuf (~> 3.5)
@litianurazvan

This comment has been minimized.

Copy link

commented Apr 23, 2019

Thanks for the response. It now works. I managed to set the version for each dependency and my Podfile look like this now.

pod 'Firebase/Core', '5.19.0'
pod 'FirebaseMessaging', '3.4.0'
pod 'FirebaseInstanceID', '3.8.0'

@maksymmalyhin

This comment has been minimized.

Copy link
Contributor

commented Apr 23, 2019

@AmandineDB thank you for the provided steps and the workaround. It looks like a new issue. Would you like to crate a separate ticket?

Also, I wonder, if you set the FirebaseAppDelegateProxyEnabled key to NO in your Info.plist so you have to call Messaging.messaging().apnsToken = deviceToken manually? If you don't, then you don't have to set apnsToken yourself (a bit more details here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
10 participants
You can’t perform that action at this time.