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

GDTStorage background task running for more than 30s, causing app to be terminated by the system

Open mluisbrown opened this issue 9 months ago • 7 comments

Description

When running our app with SDK 11.15.0 we are seeing repeated instances of this message in the Xcode console log:

Background Task 4,617 ("GDTStorage"), was created over 30 seconds ago. 
In applications running in the background, this creates a risk of termination. 
Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.

This causes our app to frequently be terminated by the system, which appears to the user like a crash.

We are only using FirebaseCrashlytics, FirebasePerformance and FirebaseDynamicLinks. The only SDK calls we make are FirebaseApp.configure() and the following Crashlytics calls:

Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(true)
Crashlytics.crashlytics().setCustomValue(_:, forKey:)
Crashlytics.crashlytics().setUserID(_:)

This background task seems to be being created here: https://github.com/google/GoogleDataTransport/blob/398227941b1b83179d3241f72842e2b1e23663f4/GoogleDataTransport/GDTCORLibrary/GDTCORFlatFileStorage.m#L130

There is an issue in that repo related to this, which has so far been ignored.

Reproducing the issue

We just run the app and it happens after about 30 seconds, whilst the app is still running. When the app is put into background, the messages continue.

Firebase SDK Version

11.15.0 and 12.0.0

Xcode Version

16.4

Installation Method

Swift Package Manager

Firebase Product(s)

Crashlytics, Performance, DynamicLinks

Targeted Platforms

iOS

Relevant Log Output


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

I've only added the firebase and google repos, not the entire Package.resolved

Expand Package.resolved snippet

    {
      "identity" : "firebase-ios-sdk",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/firebase-ios-sdk.git",
      "state" : {
        "revision" : "fdc352fabaf5916e7faa1f96ad02b1957e93e5a5",
        "version" : "11.15.0"
      }
    },
    {
      "identity" : "leveldb",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/leveldb.git",
      "state" : {
        "revision" : "a0bc79961d7be727d258d33d5a6b2f1023270ba1",
        "version" : "1.22.5"
      }
    },
    {
      "identity" : "nanopb",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/nanopb.git",
      "state" : {
        "revision" : "b7e1104502eca3a213b46303391ca4d3bc8ddec1",
        "version" : "2.30910.0"
      }
    },
    {
      "identity" : "google-ads-on-device-conversion-ios-sdk",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/googleads/google-ads-on-device-conversion-ios-sdk",
      "state" : {
        "revision" : "428d8bb138e00f9a3f4f61cc6cd8863607524f65",
        "version" : "2.1.0"
      }
    },
    {
      "identity" : "googleappmeasurement",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/GoogleAppMeasurement.git",
      "state" : {
        "revision" : "45ce435e9406d3c674dd249a042b932bee006f60",
        "version" : "11.15.0"
      }
    },
    {
      "identity" : "googledatatransport",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/GoogleDataTransport.git",
      "state" : {
        "revision" : "617af071af9aa1d6a091d59a202910ac482128f9",
        "version" : "10.1.0"
      }
    },
    {
      "identity" : "googleutilities",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/GoogleUtilities.git",
      "state" : {
        "revision" : "60da361632d0de02786f709bdc0c4df340f7613e",
        "version" : "8.1.0"
      }
    },
    {
      "identity" : "grpc-binary",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/grpc-binary.git",
      "state" : {
        "revision" : "cc0001a0cf963aa40501d9c2b181e7fc9fd8ec71",
        "version" : "1.69.0"
      }
    },
    {
      "identity" : "gtm-session-fetcher",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/gtm-session-fetcher.git",
      "state" : {
        "revision" : "3cdb78efb79b4a5383c3911488d8025bfc545b5e",
        "version" : "4.3.0"
      }
    },
    {
      "identity" : "interop-ios-for-google-sdks",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/interop-ios-for-google-sdks.git",
      "state" : {
        "revision" : "040d087ac2267d2ddd4cca36c757d1c6a05fdbfe",
        "version" : "101.0.0"
      }
    },

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet

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

mluisbrown avatar Jul 18 '25 09:07 mluisbrown

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 Jul 18 '25 09:07 google-oss-bot

FYI I just tried with Firebase SDK version 12.0.0 (removing FirebaseDynamicLinks which is no longer supported) and the issue is still there.

mluisbrown avatar Jul 18 '25 10:07 mluisbrown

Thanks for the report.

Are you able to reproduce in a quickstart or other shareable repro example? Is it simulator and/or device? What iOS version?

paulb777 avatar Jul 18 '25 20:07 paulb777

I will see if I can reproduce in a quickstart. It happens on simulator and device. iOS 18.5.

mluisbrown avatar Jul 18 '25 21:07 mluisbrown

I think this is also related to the crashes we start seeing on our app after upgrading to 11.15.0. Here is the stack track from our crash

Crashlytics - Stack trace
Application: com.driivz.mobile.EVgo
Platform: apple
Date: Wed Jul 23 2025 06:08:30 GMT-0400 (Eastern Daylight Time)

Crashed: com.apple.main-thread
0  CoreFoundation                 0x3bd3c _CFXNotificationRegistrarAddObserver + 364
1  CoreFoundation                 0x27a04 CFXNotificationRegistrarAdd + 568
2  CoreFoundation                 0x271c8 _CFXNotificationRegisterObserver + 252
3  EVgoCharger                    0x918c44 __41-[FPRTraceBackgroundActivityTracker init]_block_invoke + 44 (FPRTraceBackgroundActivityTracker.m:44)
4  libdispatch.dylib              0x1aac _dispatch_call_block_and_release + 32
5  libdispatch.dylib              0x1b584 _dispatch_client_callout + 16
6  libdispatch.dylib              0x385a0 _dispatch_main_queue_drain.cold.5 + 812
7  libdispatch.dylib              0x10d30 _dispatch_main_queue_drain + 180
8  libdispatch.dylib              0x10c6c _dispatch_main_queue_callback_4CF + 44
9  CoreFoundation                 0x6cd90 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
10 CoreFoundation                 0x104f4 __CFRunLoopRun + 1980
11 CoreFoundation                 0x11c3c CFRunLoopRunSpecific + 572
12 GraphicsServices               0x1454 GSEventRunModal + 168
13 UIKitCore                      0x135274 -[UIApplication _run] + 816
14 UIKitCore                      0x100a28 UIApplicationMain + 336
15 EVgoCharger                    0x80e0 main + 6 (main.swift:6)
16 ???                            0x1b1507f08 (Missing)

sgharraph avatar Jul 23 '25 14:07 sgharraph

The crash is related to FirebasePerformance and likely a different issue.

paulb777 avatar Jul 23 '25 14:07 paulb777

ok I will open a new issue for this crash then. Thank you

sgharraph avatar Jul 23 '25 15:07 sgharraph