firebase / firebase-ios-sdk

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

Memory leak in Firebase Performance on app launch #10855

Closed juniorsn1409 closed 1 year ago

juniorsn1409 commented 1 year ago

Description

The Xcode Instruments is reporting the following leak:

Captura de Tela 2023-02-22 às 08 38 59

When I run instrument, it shows leak. but if I comment the line FIRApp.configure()

Captura de Tela 2023-02-22 às 08 43 17

By the way, I'm using Xcode 14.0.1 and the app is running on iOS 15.3.1.

Any ideas on the possible source of this issue?

here in related issue: https://github.com/firebase/quickstart-ios/issues/239

Thanks in advance!

Reproducing the issue

starting the app already causes leaks.

Firebase SDK Version

10.4.0

Xcode Version

14.1

Installation Method

CocoaPods

Firebase Product(s)

Analytics, Crashlytics, Performance

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 PODS: - AppsFlyerFramework (6.9.2): - AppsFlyerFramework/Main (= 6.9.2) - AppsFlyerFramework/Main (6.9.2) - Charts (4.1.0): - Charts/Core (= 4.1.0) - Charts/Core (4.1.0): - SwiftAlgorithms (~> 1.0) - Firebase/Analytics (10.4.0): - Firebase/Core - Firebase/Core (10.4.0): - Firebase/CoreOnly - FirebaseAnalytics (~> 10.4.0) - Firebase/CoreOnly (10.4.0): - FirebaseCore (= 10.4.0) - Firebase/Crashlytics (10.4.0): - Firebase/CoreOnly - FirebaseCrashlytics (~> 10.4.0) - Firebase/Messaging (10.4.0): - Firebase/CoreOnly - FirebaseMessaging (~> 10.4.0) - Firebase/Performance (10.4.0): - Firebase/CoreOnly - FirebasePerformance (~> 10.4.0) - FirebaseABTesting (10.4.0): - FirebaseCore (~> 10.0) - FirebaseAnalytics (10.4.0): - FirebaseAnalytics/AdIdSupport (= 10.4.0) - FirebaseCore (~> 10.0) - FirebaseInstallations (~> 10.0) - GoogleUtilities/AppDelegateSwizzler (~> 7.8) - GoogleUtilities/MethodSwizzler (~> 7.8) - GoogleUtilities/Network (~> 7.8) - "GoogleUtilities/NSData+zlib (~> 7.8)" - nanopb (< 2.30910.0, >= 2.30908.0) - FirebaseAnalytics/AdIdSupport (10.4.0): - FirebaseCore (~> 10.0) - FirebaseInstallations (~> 10.0) - GoogleAppMeasurement (= 10.4.0) - GoogleUtilities/AppDelegateSwizzler (~> 7.8) - GoogleUtilities/MethodSwizzler (~> 7.8) - GoogleUtilities/Network (~> 7.8) - "GoogleUtilities/NSData+zlib (~> 7.8)" - nanopb (< 2.30910.0, >= 2.30908.0) - FirebaseCore (10.4.0): - FirebaseCoreInternal (~> 10.0) - GoogleUtilities/Environment (~> 7.8) - GoogleUtilities/Logger (~> 7.8) - FirebaseCoreInternal (10.4.0): - "GoogleUtilities/NSData+zlib (~> 7.8)" - FirebaseCrashlytics (10.4.0): - FirebaseCore (~> 10.0) - FirebaseInstallations (~> 10.0) - GoogleDataTransport (~> 9.2) - GoogleUtilities/Environment (~> 7.8) - nanopb (< 2.30910.0, >= 2.30908.0) - PromisesObjC (~> 2.1) - FirebaseInstallations (10.4.0): - FirebaseCore (~> 10.0) - GoogleUtilities/Environment (~> 7.8) - GoogleUtilities/UserDefaults (~> 7.8) - PromisesObjC (~> 2.1) - FirebaseMessaging (10.4.0): - FirebaseCore (~> 10.0) - FirebaseInstallations (~> 10.0) - GoogleDataTransport (~> 9.2) - GoogleUtilities/AppDelegateSwizzler (~> 7.8) - GoogleUtilities/Environment (~> 7.8) - GoogleUtilities/Reachability (~> 7.8) - GoogleUtilities/UserDefaults (~> 7.8) - nanopb (< 2.30910.0, >= 2.30908.0) - FirebasePerformance (10.4.0): - FirebaseCore (~> 10.0) - FirebaseInstallations (~> 10.0) - FirebaseRemoteConfig (~> 10.0) - GoogleDataTransport (~> 9.2) - GoogleUtilities/Environment (~> 7.8) - GoogleUtilities/ISASwizzler (~> 7.8) - GoogleUtilities/MethodSwizzler (~> 7.8) - nanopb (< 2.30910.0, >= 2.30908.0) - FirebaseRemoteConfig (10.4.0): - FirebaseABTesting (~> 10.0) - FirebaseCore (~> 10.0) - FirebaseInstallations (~> 10.0) - GoogleUtilities/Environment (~> 7.8) - "GoogleUtilities/NSData+zlib (~> 7.8)" - GDataXML-HTML (1.4.1) - GoogleAppMeasurement (10.4.0): - GoogleAppMeasurement/AdIdSupport (= 10.4.0) - GoogleUtilities/AppDelegateSwizzler (~> 7.8) - GoogleUtilities/MethodSwizzler (~> 7.8) - GoogleUtilities/Network (~> 7.8) - "GoogleUtilities/NSData+zlib (~> 7.8)" - nanopb (< 2.30910.0, >= 2.30908.0) - GoogleAppMeasurement/AdIdSupport (10.4.0): - GoogleAppMeasurement/WithoutAdIdSupport (= 10.4.0) - GoogleUtilities/AppDelegateSwizzler (~> 7.8) - GoogleUtilities/MethodSwizzler (~> 7.8) - GoogleUtilities/Network (~> 7.8) - "GoogleUtilities/NSData+zlib (~> 7.8)" - nanopb (< 2.30910.0, >= 2.30908.0) - GoogleAppMeasurement/WithoutAdIdSupport (10.4.0): - GoogleUtilities/AppDelegateSwizzler (~> 7.8) - GoogleUtilities/MethodSwizzler (~> 7.8) - GoogleUtilities/Network (~> 7.8) - "GoogleUtilities/NSData+zlib (~> 7.8)" - nanopb (< 2.30910.0, >= 2.30908.0) - GoogleDataTransport (9.2.1): - GoogleUtilities/Environment (~> 7.7) - nanopb (< 2.30910.0, >= 2.30908.0) - PromisesObjC (< 3.0, >= 1.2) - GoogleUtilities/AppDelegateSwizzler (7.11.0): - GoogleUtilities/Environment - GoogleUtilities/Logger - GoogleUtilities/Network - GoogleUtilities/Environment (7.11.0): - PromisesObjC (< 3.0, >= 1.2) - GoogleUtilities/ISASwizzler (7.11.0) - GoogleUtilities/Logger (7.11.0): - GoogleUtilities/Environment - GoogleUtilities/MethodSwizzler (7.11.0): - GoogleUtilities/Logger - GoogleUtilities/Network (7.11.0): - GoogleUtilities/Logger - "GoogleUtilities/NSData+zlib" - GoogleUtilities/Reachability - "GoogleUtilities/NSData+zlib (7.11.0)" - GoogleUtilities/Reachability (7.11.0): - GoogleUtilities/Logger - GoogleUtilities/UserDefaults (7.11.0): - GoogleUtilities/Logger - iOSSnapshotTestCase (8.0.0): - iOSSnapshotTestCase/SwiftSupport (= 8.0.0) - iOSSnapshotTestCase/Core (8.0.0) - iOSSnapshotTestCase/SwiftSupport (8.0.0): - iOSSnapshotTestCase/Core - IQKeyboardManagerSwift (6.5.11) - LaunchDarkly (8.0.0): - LaunchDarkly/Core (= 8.0.0) - LaunchDarkly/Core (8.0.0): - LDSwiftEventSource (= 3.0.0) - LDSwiftEventSource (3.0.0) - nanopb (2.30909.0): - nanopb/decode (= 2.30909.0) - nanopb/encode (= 2.30909.0) - nanopb/decode (2.30909.0) - nanopb/encode (2.30909.0) - OHHTTPStubs/Core (9.1.0) - OHHTTPStubs/Default (9.1.0): - OHHTTPStubs/Core - OHHTTPStubs/JSON - OHHTTPStubs/NSURLSession - OHHTTPStubs/OHPathHelpers - OHHTTPStubs/JSON (9.1.0): - OHHTTPStubs/Core - OHHTTPStubs/NSURLSession (9.1.0): - OHHTTPStubs/Core - OHHTTPStubs/OHPathHelpers (9.1.0) - OHHTTPStubs/Swift (9.1.0): - OHHTTPStubs/Default - PromiseKit (6.18.1): - PromiseKit/CorePromise (= 6.18.1) - PromiseKit/Foundation (= 6.18.1) - PromiseKit/UIKit (= 6.18.1) - PromiseKit/CorePromise (6.18.1) - PromiseKit/Foundation (6.18.1): - PromiseKit/CorePromise - PromiseKit/UIKit (6.18.1): - PromiseKit/CorePromise - PromisesObjC (2.1.1) - SQLCipher (4.5.3): - SQLCipher/standard (= 4.5.3) - SQLCipher/common (4.5.3) - SQLCipher/standard (4.5.3): - SQLCipher/common - SQLite.swift/SQLCipher (0.14.1): - SQLCipher (>= 4.0.0) - SwiftAlgorithms (1.0.0) - SwiftLint (0.50.3) - Swinject (2.8.2) DEPENDENCIES: - AppsFlyerFramework (= 6.9.2) - Charts (= 4.1.0) - Firebase/Analytics (= 10.4.0) - Firebase/Crashlytics (= 10.4.0) - Firebase/Messaging (= 10.4.0) - Firebase/Performance (= 10.4.0) - GDataXML-HTML (= 1.4.1) - iOSSnapshotTestCase (= 8.0.0) - IQKeyboardManagerSwift (= 6.5.11) - LaunchDarkly (= 8.0.0) - LDSwiftEventSource (= 3.0.0) - OHHTTPStubs/Swift (= 9.1.0) - PromiseKit (= 6.18.1) - SQLite.swift/SQLCipher (= 0.14.1) - SwiftAlgorithms (= 1.0.0) - SwiftLint (= 0.50.3) - Swinject (= 2.8.2) SPEC REPOS: https://github.com/CocoaPods/Specs.git: - AppsFlyerFramework - Charts - Firebase - FirebaseABTesting - FirebaseAnalytics - FirebaseCore - FirebaseCoreInternal - FirebaseCrashlytics - FirebaseInstallations - FirebaseMessaging - FirebasePerformance - FirebaseRemoteConfig - GDataXML-HTML - GoogleAppMeasurement - GoogleDataTransport - GoogleUtilities - iOSSnapshotTestCase - IQKeyboardManagerSwift - LaunchDarkly - LDSwiftEventSource - nanopb - OHHTTPStubs - PromiseKit - PromisesObjC - SQLCipher - SQLite.swift - SwiftAlgorithms - SwiftLint - Swinject SPEC CHECKSUMS: AppsFlyerFramework: 75e2e46970e520c88b0456dc6fae98c51b36163a Charts: 354f86803d11d9c35de280587fef50d1af063978 Firebase: ba3501b5142a57747eac74d27c96d2b313bdec90 FirebaseABTesting: ae3b32fe26e761fd54c68e37a632a0097b599c87 FirebaseAnalytics: 0be84b933ca3222bca03e8cccf020ad9b1c3c6ff FirebaseCore: b8697a177690b69b0dbce9d612b69b893be70469 FirebaseCoreInternal: e301297f4c15a17489e48ed722d733b1578e0c02 FirebaseCrashlytics: 52e821fd4d36eba20a251a53549c2778b455f360 FirebaseInstallations: 36b38c733fd37e50857e5e8d74138648f466f18c FirebaseMessaging: e7304d6ce5f83d9139f0a61383a2302beb99b111 FirebasePerformance: b157e90b0fb79c3eb64de3934cfc040d587c95ee FirebaseRemoteConfig: bf23f54161ebad4fb4acb1ac44ad7783a784f3ab GDataXML-HTML: a4f11079b48d9fe96ff1fe478943a317185227e2 GoogleAppMeasurement: 173fa22ce7d62c29332568e853b39b2525a0e584 GoogleDataTransport: ea169759df570f4e37bdee1623ec32a7e64e67c4 GoogleUtilities: c2bdc4cf2ce786c4d2e6b3bcfd599a25ca78f06f iOSSnapshotTestCase: a670511f9ee3829c2b9c23e6e68f315fd7b6790f IQKeyboardManagerSwift: c7955c0bdbf7b2eb29bb7daaa44e3d90f55a9a85 LaunchDarkly: e73c26ce2fc2b719730e0dd38c9abe761e33287a LDSwiftEventSource: 824ce51a4fa8e79498c9b67ae672bfa802bd7464 nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431 OHHTTPStubs: 90eac6d8f2c18317baeca36698523dc67c513831 PromiseKit: 49d70c53d5d20e346beaea4b276b5dd2ab446bb4 PromisesObjC: ab77feca74fa2823e7af4249b8326368e61014cb SQLCipher: 57fa9f863fa4a3ed9dd3c90ace52315db8c0fdca SQLite.swift: 2992550ebf3c5b268bf4352603e3df87d2a4ed72 SwiftAlgorithms: 38dda4731d19027fdeee1125f973111bf3386b53 SwiftLint: 77f7cb2b9bb81ab4a12fcc86448ba3f11afa50c6 Swinject: b4a11b31992e8668308dc594ba1cb9b3164a37ab PODFILE CHECKSUM: 7eb33633e0456025a2820c19eb8b0989591824ca COCOAPODS: 1.11.3 ```
google-oss-bot commented 1 year ago

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

andrewheard commented 1 year ago

Thank you for providing the screenshot and Podfile.lock details! I'll try to reproduce this shortly. Have you tried to see if it goes away if you remove FirebasePerformance? It seems like that's what Instruments is reporting as the responsible library in the screenshot.

Adding the api: performance tag in case the team has any insights.

juniorsn1409 commented 1 year ago

I disabled only FirebasePerformance with the code below and it stopped the leaks, so the problem is really FirebasePerformance.

        Performance.sharedInstance().isInstrumentationEnabled = false
        Performance.sharedInstance().isDataCollectionEnabled = false
visumickey commented 1 year ago

Thanks for bringing this to our attention. We tried reproducing this issue by running our sample apps under Instruments and we did not find any leak similar to what is referenced in the issue. We made many network requests/different type of APIs to make network requests to validate this scenario and we did not see anything leaking. Would you be able to provide us a simple sample app for us to reproduce the issue?

In addition to that, the following information might be of great help to narrow down the issue as well:

  1. What was the network API used which caused a memory leak (NSURLSession API with/without delegate, type of task)?
  2. What was the response code for the network request? If a network request goes to a timeout after a long wait, Instruments has a tendency to report that as a leak. We want to make this was not the case.

The version of Firebase Performance use is recent and we don't see anything concerning there.

google-oss-bot commented 1 year ago

Hey @juniorsn1409. 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 commented 1 year ago

Since there haven't been any recent updates here, I am going to close this issue.

@juniorsn1409 if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.