firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

[APMMeasurement didInitializeComponments] main thread hangs

Open linziyiwj opened this issue 3 years ago • 13 comments

Description

Sdk version: Firebase 9.5.0 Google-Mobile-Ads-SDK 9.8.0 GoogleAppMeasurement: Firebase/GoogleAppMeasurement

We find the problems in hangs of Xcode 14.0 organizer, it hangs the main thread for a long time.

image

Reproducing the issue

No response

Firebase SDK Version

9.5.0

Xcode Version

13.4

Installation Method

CocoaPods

Firebase Product(s)

AB Testing, Analytics, Crashlytics, In-App Messaging, Performance, Remote Config

Targeted Platforms

iOS

Relevant Log Output

No response

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

Expand Package.resolved snippet

Replace this line with the contents of your Package.resolved.

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet

Replace this line with the contents of your Podfile.lock!

linziyiwj avatar Aug 30 '22 10:08 linziyiwj

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

google-oss-bot avatar Aug 30 '22 10:08 google-oss-bot

Thanks for reaching out, @linziyiwj. Could you provide the detailed steps in reproducing the issue as well as the complete stack trace?

rizafran avatar Aug 30 '22 17:08 rizafran

Looks like the lock is necessary for this initialization logic, but we could potentially speed it up by using os_unfair_lock.

morganchen12 avatar Aug 30 '22 18:08 morganchen12

Thanks for reaching out, @linziyiwj. Could you provide the detailed steps in reproducing the issue as well as the complete stack trace?

@rizafran Unfortunately I have not been able to reproduce this block yet. It is only reported in Xcode hangs. And only the above stack information

linziyiwj avatar Aug 31 '22 11:08 linziyiwj

Looks like the lock is necessary for this initialization logic, but we could potentially speed it up by using os_unfair_lock.

@morganchen12 Sorry, I don't quite understand it. Can you explain it in detail. Thank you very much!!!

linziyiwj avatar Aug 31 '22 11:08 linziyiwj

@linziyiwj I believe @morganchen12 was talking about a possible change in our internal implementation.

paulb777 avatar Sep 01 '22 03:09 paulb777

@linziyiwj I believe @morganchen12 was talking about a possible change in our internal implementation.

@paulb777 Please ask when will the version be updated to deal with this problem,Hope to have a solution as soon as possible

linziyiwj avatar Sep 01 '22 03:09 linziyiwj

cc: @htcgh

paulb777 avatar Sep 02 '22 22:09 paulb777

Hi @linziyiwj, could you please provide all stack traces, including all other threads? It would help us to know where our internal worker thread is blocked. Thanks.

tsunghung avatar Sep 03 '22 02:09 tsunghung

@linziyiwj Just want to be sure, it's not a dead lock, right? It's just that the main thread gets blocked for 1 second, right? Please correct me if I misunderstood. It seems that the worker thread holds the lock while initializing internal components, and the main thread is waiting for the initialization finished. One quick suggestion, you may want to call FirebaseApp.configure() as soon as possible to allow FirebaseAnalytics initialize earlier and unblock the main thread sooner.

tsunghung avatar Sep 03 '22 04:09 tsunghung

Hi @linziyiwj, could you please provide all stack traces, including all other threads? It would help us to know where our internal worker thread is blocked. Thanks.

@tsunghung Unfortunately I have not been able to reproduce this block yet. It is only reported in Xcode hangs. And only the above stack information

linziyiwj avatar Sep 04 '22 10:09 linziyiwj

@linziyiwj Just want to be sure, it's not a dead lock, right? It's just that the main thread gets blocked for 1 second, right? Please correct me if I misunderstood. It seems that the worker thread holds the lock while initializing internal components, and the main thread is waiting for the initialization finished. One quick suggestion, you may want to call FirebaseApp.configure() as soon as possible to allow FirebaseAnalytics initialize earlier and unblock the main thread sooner. @tsunghung yes, It's just that the main thread gets blocked for 1 second. And We called [FIRApp configure] when - (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey,id> *)launchOptions on the main thread , No lock held

@linziyiwj Author linziyiwj commented 7 minutes ago Hi @linziyiwj, could you please provide all stack traces, including all other threads? It would help us to know where our internal worker thread is blocked. Thanks.

@tsunghung Unfortunately I have not been able to reproduce this block yet. It is only reported in Xcode hangs. And only the above stack information

@linziyiwj

Add heading textAdd bold text, <Cmd+b>Add italic text, <Cmd+i>

linziyiwj avatar Sep 04 '22 10:09 linziyiwj

According to the call stack, we created a patch, which will be released in Firebase 10.0. Hopefully, it would fix this issue.

tsunghung avatar Sep 19 '22 03:09 tsunghung

Hi everyone, Firebase 10 has been released and should resolve this issue. Please don't hesitate to reach out if the issue persists.

ncooke3 avatar Oct 10 '22 17:10 ncooke3