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

Firebase significantly contributes to iOS app launch time

Open mkj-is opened this issue 1 year ago • 11 comments

Description

In Xcode Organizer in Xcode 16 beta we see Firebase is contributing 10 % to our app launch time, which is concerning.

Our custom measurements in production show the P90 for initialising Firebase SDK is 90 ms, P50 is 40 ms. We are using CocoaPods, but Firebase is statically linked.

These methods are responsible:

  • 3 %: FIRCLSContextInitialize + 876 (130 ms spent in this code path during a 1792 ms launch)
  • 2 %: __46+[APMAnalytics startWithAppID:origin:options:]_block_invoke + 1148 (90 ms spent in this code path during a 1220 ms launch)
  • 2 %: +[APMAEU appStoreRURL] + 160 (90 ms spent in this code path during a 3528 ms launch)
  • 1 %: -[APMUserDefaults objectForKey:] + 88 (90 ms spent in this code path during a 1186 ms launch)
  • 1 %: -[FIRInstallationsAPIService initWithAPIKey:projectID:heartbeatLogger:] + 92 (60 ms spent in this code path during a 1830 ms launch)
  • 1 %: APMIsScreenReportingEnabled + 28 (130 ms spent in this code path during a 2467 ms launch)

Might be related to https://github.com/firebase/firebase-ios-sdk/issues/13223.

Screenshot 2024-07-04 at 13 04 54 Screenshot 2024-07-04 at 13 05 01 Screenshot 2024-07-04 at 13 05 16 Screenshot 2024-07-04 at 13 05 31 Screenshot 2024-07-04 at 13 05 42 Screenshot 2024-07-04 at 13 07 33

Reproducing the issue

Open Xcode Organizer (Xcode 16 beta) Launch reports for any app with significant number of users and see the stats.

Firebase SDK Version

10.22

Xcode Version

16.0

Installation Method

CocoaPods

Firebase Product(s)

Crashlytics, Performance

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
  FirebaseABTesting: e6e3c3e0e35813874f571d1b7bdae2aab319dd38
  FirebaseAnalytics: 8d0ff929c63b7f72260f332b86ccf569776b75d3
  FirebaseCore: 0326ec9b05fbed8f8716cddbf0e36894a13837f7
  FirebaseCoreExtension: 8a47811d0b155501559ef05d089518152a0a1677
  FirebaseCoreInternal: 910a81992c33715fec9263ca7381d59ab3a750b7
  FirebaseCrashlytics: e568d68ce89117c80cddb04073ab9018725fbb8c
  FirebaseInstallations: 91950fe859846fff0fbd296180909dd273103b09
  FirebaseMessaging: 9f71037fd9db3376a4caa54e5a3949d1027b4b6e
  FirebasePerformance: 095debad1fc8d7d73148a835fcaec9e528946166
  FirebaseRemoteConfig: 9f3935cefecd85d5b312192117f444957de24a75
  FirebaseRemoteConfigInterop: b25018791b204c0d78a90e394d6c62d9b1f22da8
  FirebaseSessions: c0939656253a1fa0e94ecc266ccf770cc8b33732
  FirebaseSharedSwift: 0274086954b1b2d5fd7e829eccc587044d72a4ba

mkj-is avatar Jul 04 '24 11:07 mkj-is

10.27.0 addressed a startup time issue in Crashlytics that may be related to the top item in the list. Please update and let us know if the slowdown is still occurring.

paulb777 avatar Jul 09 '24 16:07 paulb777

Hey @mkj-is. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Jul 16 '24 01:07 google-oss-bot

We currently have 10.22.0 in production. When we tested the latest version (10.29.0) we were not able to see any improvements.

mkj-is avatar Jul 16 '24 07:07 mkj-is

There is a new strack trace since we updated to Firebase 10.29.0:

-[RCNConfigDBManager loadInternalMetadataTable] + 160 (130 ms spent in this code path during a 1986 ms launch)

Our metrics show the Firebase init increased by 30 ms on iOS and 100 ms on tvOS due to this update.

We are not using RemoteConfig, it is automatically included as a dependency of FirebasePerformance.

mkj-is avatar Aug 29 '24 09:08 mkj-is

@mkj-is Curious if you are still affected by this? And are you still using 10.29.0, or perhaps updated to 11.5.0 (current) and if the problem persists or not?

This problem appears to be similar to #13675 as well.

I'm investigating recent slowdowns in my app's launch time (we're shipping 11.4.0 and developing with 11.5.0), and while I'm still digging through Instruments data, it seems Firebase may be involved with the main thread in ways it maybe should not be (supported by @paulb777 's comment here: https://github.com/firebase/firebase-ios-sdk/issues/13675#issuecomment-2492143903 )

Anyways, curious if the problem persists for you or if you've had improvements. Thanks.

hsoi avatar Nov 25 '24 16:11 hsoi

@hsoi We are still on 10.29.0.

We did some app start optimizations on our side recently. Xcode Organizer Launch reports now show Firebase related stack traces are responsible for 56 % of slow app launches for our app, majority of it is FIRCLSContextInitialize call.

P90 for iOS and Apple TV Firebase configure call is around 180 ms.

mkj-is avatar Nov 26 '24 09:11 mkj-is

@hsoi Do we have any update on this?

sharanbasappa95 avatar Dec 03 '24 02:12 sharanbasappa95

@sharanbasappa95 I'm not sure what update you're looking for from me - I'm just a user (still) affected by this issue too. Could you please clarify what you're looking for?

hsoi avatar Dec 03 '24 10:12 hsoi

@hsoi wrongly tagged you instead of firebase team.

sharanbasappa95 avatar Dec 04 '24 15:12 sharanbasappa95

I'm using version 11.2.0, which still shows the Firebase SDK taking a lot of time to launch in xcode.

Has anyone tried using the latest version 11.6?

Desgard avatar Dec 31 '24 04:12 Desgard

@ncooke3 Any update on this? Are we fixing this any sooner. Please provide some timeline for clients. Thanks.

SuryakantRapido avatar Jan 15 '25 11:01 SuryakantRapido

Any update on this?

songzhiming avatar Feb 25 '25 02:02 songzhiming

11.9.0 that released this week included some launch time improvements, although not necessarily all of those referenced here.

paulb777 avatar Feb 27 '25 00:02 paulb777

@paulb777 Can you provide some data, such as how much it has been optimized?

songzhiming avatar Mar 19 '25 02:03 songzhiming

@songzhiming We weren't able to exactly reproduce the long launch time problems reported. We found and fixed some unnecessary synchronization in Firebase Analytics that could contribute to the problem. cc: @morganchen12

paulb777 avatar Mar 19 '25 04:03 paulb777

We weren't able to exactly reproduce the long launch time problems reported

Everyone else in the world is facing an issue but you are not able to reproduce 👎

SuryakantRapido avatar Mar 19 '25 13:03 SuryakantRapido

I am using Firebase SDK 11.9.0, but still facing the high launching time. Any suggestions here?

shilpa-bansal0401 avatar Apr 09 '25 08:04 shilpa-bansal0401

We profiled our app with Firebase 11.9.0, but most of the resource intensive stack traces are still there. We have not been able to see any meaningful improvements as of yet.

mkj-is avatar Apr 09 '25 12:04 mkj-is

Firebase 11.11.0 included a fix for a Firebase Analytics performance issue.

paulb777 avatar Apr 09 '25 15:04 paulb777

Firebase 11.11.0 included a fix for a Firebase Analytics performance issue.

Still has this issue in Firebase 11.11.0 😭

alflix avatar Apr 14 '25 07:04 alflix

Hey folks, we just made a change that should improve the startup time of Crashlytics. It'll be included in the next Firebase SDK release.

If you'd like to test it out early it's on this PR: https://github.com/firebase/firebase-ios-sdk/pull/14754.

samedson avatar May 01 '25 15:05 samedson

Closing since the fix is merged and is planned to release with 11.13.0 the week of May 15

paulb777 avatar May 01 '25 21:05 paulb777

Has anyone used version 11.13.0? Has the startup been optimized?

songzhiming avatar Jun 06 '25 03:06 songzhiming

Has anyone used version 11.13.0? Has the startup been optimized?

YES, version 11.13.0 confirm fix this problem

alflix avatar Jun 06 '25 03:06 alflix