firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.41k stars 1.42k forks source link

Hang Risk warning on configure call #13081

Open tristan-warner-smith opened 3 weeks ago

tristan-warner-smith commented 3 weeks ago

Description

We have a SwiftUI app and we're occasionally seeing these Hang Risk warnings.

We initialise Firebase in our app Initialiser.

struct OurApp: App {
    init() {
        FirebaseApp.configure()
    }
}

The warning is: Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions

Here's the stack trace. image

Reproducing the issue

Create a SwiftUI app as above, configuring Firebase. Run the app in Xcode with the debugger attached. Sporadically, witness behaviour as described.

Firebase SDK Version

10.25

Xcode Version

15.4

Installation Method

Swift Package Manager

Firebase Product(s)

AB Testing, Analytics, Authentication, Crashlytics, DynamicLinks, Firestore, Functions, In-App Messaging, Performance, Remote Config, Storage

Targeted Platforms

iOS

Relevant Log Output

No response

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet
```json Replace this line with the contents of your Package.resolved. ```

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
```yml Replace this line with the contents of your Podfile.lock! ```
google-oss-bot commented 3 weeks ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

paulb777 commented 3 weeks ago

FirebaseDynamicLinks is deprecated and support will end in 2025.

We may not be able to address this and recommend that you transition the app away from Dynamic Links.

https://firebase.google.com/support/dynamic-links-faq

tristan-warner-smith commented 2 weeks ago

FirebaseDynamicLinks is deprecated and support will end in 2025.

We may not be able to address this and recommend that you transition the app away from Dynamic Links.

https://firebase.google.com/support/dynamic-links-faq

Hey Paul,

We use Dynamic Links purely for Firebase Authentication. The docs say "we will provide an update that will require a client- side update to ensure that email link auth continues working after the Firebase Dynamic Links service is shut down" but as far as I can see, this change has not been made yet.

paulb777 commented 2 weeks ago

@tristan-warner-smith It's true that the Firebase Auth Dynamic Links replacement is not yet available. However, Firebase Authentication only requires the Firebase Dynamics Links back end to be set up on the console. It does not need the SDK to be built into the app.

tristan-warner-smith commented 2 weeks ago

Firebase Auth isn't our only auth provider and we need to know for a given deeplink, whether it's been handled by Firebase Auth. We currently have the following for that, but if there's an alternative, that would be great.

func handle(url: URL, completion: ((URL?) -> Void)?) -> Bool {
        DynamicLinks.dynamicLinks().handleUniversalLink(url) { dynamicLink, _ in
            completion?(dynamicLink?.url)
        }
    }
paulb777 commented 2 weeks ago

Do you need the link processing that handleUniversalLink does? Versus directly calling the completion block?

 func handle(url: URL, completion: ((URL?) -> Void)?) -> Bool {
            completion?(url)
    }
tristan-warner-smith commented 2 weeks ago

We do, this code could definitely use a refactor but this is internally wrapped in:

func parseFirebase(url: URL) async -> Deeplink? {
        await withCheckedContinuation { continuation in
            _ = dynamicLinks.handle(url: url, completion: { _ in
                if let parsedDeeplink = Self.parseInternalNavigationDeeplink(from: url.relativePath) {
                    continuation.resume(returning: parsedDeeplink)
                } else {
                    continuation.resume(returning: nil)
                }
            })
        }
    }