firebase / firebase-ios-sdk

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

App Crash from Firebase Remote Config #13193

Closed nik6018 closed 2 months ago

nik6018 commented 3 months ago

Description

The app is crashing immediately after opening, as indicated from Crashlytics as it's tagged under "Early crashes". The crash is happening randomly.

When the app starts up I have made sure that func fetch( withExpirationDuration expirationDuration: , completionHandler: ((RemoteConfigFetchStatus, ?) -> [Void])? = nil ) method is only invoked once to avoid any multiple calls

I am also using RemoteConfigRealTimeUpdate as well to fetch latest values whenever changes happen.

Can anyone provide me guidance on how I can resolve this crash as it's pointing to RCNConfigRealtime.m:449 and I have no insight on what's causing it

Reproducing the issue

Unable to reproduce the issue, as it's occurring on very rare instances on production

Firebase SDK Version

10.22.1

Xcode Version

15.3

Installation Method

Swift Package Manager

Firebase Product(s)

Crashlytics, DynamicLinks, Remote Config

Targeted Platforms

iOS

Relevant Log Output

Fatal Exception: NSGenericException
0  CoreFoundation                 0x83f20 __exceptionPreprocess
1  libobjc.A.dylib                0x16018 objc_exception_throw
2  CoreFoundation                 0x18220c -[__NSSingleObjectEnumerator init]
3  My App                         0x11c3b64 __53-[RCNConfigRealtime fetchLatestConfig:targetVersion:]_block_invoke_2 + 449 (RCNConfigRealtime.m:449)
4  libdispatch.dylib              0x213c _dispatch_call_block_and_release
5  libdispatch.dylib              0x3dd4 _dispatch_client_callout
6  libdispatch.dylib              0x125a4 _dispatch_main_queue_drain
7  libdispatch.dylib              0x121b8 _dispatch_main_queue_callback_4CF
8  CoreFoundation                 0x56710 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
9  CoreFoundation                 0x53914 __CFRunLoopRun
10 CoreFoundation                 0x52cd8 CFRunLoopRunSpecific
11 GraphicsServices               0x11a8 GSEventRunModal
12 UIKitCore                      0x40a90c -[UIApplication _run]
13 UIKitCore                      0x4be9d0 UIApplicationMain
14 My App                         0x4daa78 main + 28 (AppDelegate.swift:28)
15 ???                            0x1bbb35e4c (Missing)

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

Expand Package.resolved snippet
```json { "originHash" : "54c03b93d8f550adc63162122e1f1f93eb0a1b63d867541427cea29d6081b683", "pins" : [ { "identity" : "abseil-cpp-binary", "kind" : "remoteSourceControl", "location" : "https://github.com/google/abseil-cpp-binary.git", "state" : { "revision" : "df308b8b46607675f2b9ec8e569109008f9155ce", "version" : "1.2022062300.1" } }, { "identity" : "alamofire", "kind" : "remoteSourceControl", "location" : "https://github.com/Alamofire/Alamofire.git", "state" : { "revision" : "f455c2975872ccd2d9c81594c658af65716e9b9a", "version" : "5.9.1" } }, { "identity" : "app-check", "kind" : "remoteSourceControl", "location" : "https://github.com/google/app-check.git", "state" : { "revision" : "3b62f154d00019ae29a71e9738800bb6f18b236d", "version" : "10.19.2" } }, { "identity" : "firebase-ios-sdk", "kind" : "remoteSourceControl", "location" : "https://github.com/firebase/firebase-ios-sdk", "state" : { "revision" : "be49849dcba96f2b5ee550d4eceb2c0fa27dade4", "version" : "10.22.1" } }, { "identity" : "googleappmeasurement", "kind" : "remoteSourceControl", "location" : "https://github.com/google/GoogleAppMeasurement.git", "state" : { "revision" : "482cfa4e5880f0a29f66ecfd60c5a62af28bd1f0", "version" : "10.22.1" } }, { "identity" : "googledatatransport", "kind" : "remoteSourceControl", "location" : "https://github.com/google/GoogleDataTransport.git", "state" : { "revision" : "a637d318ae7ae246b02d7305121275bc75ed5565", "version" : "9.4.0" } }, { "identity" : "googleutilities", "kind" : "remoteSourceControl", "location" : "https://github.com/google/GoogleUtilities.git", "state" : { "revision" : "57a1d307f42df690fdef2637f3e5b776da02aad6", "version" : "7.13.3" } }, { "identity" : "grpc-binary", "kind" : "remoteSourceControl", "location" : "https://github.com/google/grpc-binary.git", "state" : { "revision" : "ea4cb5cc0c39c732b85386263116d2e2fdbbdc61", "version" : "1.49.2" } }, { "identity" : "gtm-session-fetcher", "kind" : "remoteSourceControl", "location" : "https://github.com/google/gtm-session-fetcher.git", "state" : { "revision" : "0382ca27f22fb3494cf657d8dc356dc282cd1193", "version" : "3.4.1" } }, { "identity" : "interop-ios-for-google-sdks", "kind" : "remoteSourceControl", "location" : "https://github.com/google/interop-ios-for-google-sdks.git", "state" : { "revision" : "2d12673670417654f08f5f90fdd62926dc3a2648", "version" : "100.0.0" } }, { "identity" : "kingfisher", "kind" : "remoteSourceControl", "location" : "https://github.com/onevcat/Kingfisher.git", "state" : { "revision" : "2ef543ee21d63734e1c004ad6c870255e8716c50", "version" : "7.12.0" } }, { "identity" : "leveldb", "kind" : "remoteSourceControl", "location" : "https://github.com/firebase/leveldb.git", "state" : { "revision" : "a0bc79961d7be727d258d33d5a6b2f1023270ba1", "version" : "1.22.5" } }, { "identity" : "libwebp-xcode", "kind" : "remoteSourceControl", "location" : "https://github.com/SDWebImage/libwebp-Xcode.git", "state" : { "revision" : "b2b1d20a90b14d11f6ef4241da6b81c1d3f171e4", "version" : "1.3.2" } }, { "identity" : "lottie-ios", "kind" : "remoteSourceControl", "location" : "https://github.com/airbnb/lottie-ios", "state" : { "revision" : "769b88d83a42ca8d5572b020c96f47e3690b3796", "version" : "4.4.3" } }, { "identity" : "nanopb", "kind" : "remoteSourceControl", "location" : "https://github.com/firebase/nanopb.git", "state" : { "revision" : "b7e1104502eca3a213b46303391ca4d3bc8ddec1", "version" : "2.30910.0" } }, { "identity" : "panmodal", "kind" : "remoteSourceControl", "location" : "https://github.com/slackhq/PanModal.git", "state" : { "revision" : "b012aecb6b67a8e46369227f893c12544846613f", "version" : "1.2.7" } }, { "identity" : "promises", "kind" : "remoteSourceControl", "location" : "https://github.com/google/promises.git", "state" : { "revision" : "540318ecedd63d883069ae7f1ed811a2df00b6ac", "version" : "2.4.0" } }, { "identity" : "reachability.swift", "kind" : "remoteSourceControl", "location" : "https://github.com/ashleymills/Reachability.swift", "state" : { "branch" : "master", "revision" : "7cbd73f46a7dfaeca079e18df7324c6de6d1834a" } }, { "identity" : "sdwebimage", "kind" : "remoteSourceControl", "location" : "https://github.com/SDWebImage/SDWebImage.git", "state" : { "revision" : "b8523c1642f3c142b06dd98443ea7c48343a4dfd", "version" : "5.19.3" } }, { "identity" : "sdwebimagewebpcoder", "kind" : "remoteSourceControl", "location" : "https://github.com/SDWebImage/SDWebImageWebPCoder.git", "state" : { "revision" : "f534cfe830a7807ecc3d0332127a502426cfa067", "version" : "0.14.6" } }, { "identity" : "skeletonview", "kind" : "remoteSourceControl", "location" : "https://github.com/Juanpe/SkeletonView.git", "state" : { "revision" : "2f5274827d310e32c09325dd3e0007120940988e", "version" : "1.31.0" } }, { "identity" : "snapshotkit", "kind" : "remoteSourceControl", "location" : "https://github.com/YK-Unit/SnapshotKit.git", "state" : { "revision" : "79452a8560f9caef218f46fecc46eb7615222b97", "version" : "0.3.2" } }, { "identity" : "swift-protobuf", "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-protobuf.git", "state" : { "revision" : "9f0c76544701845ad98716f3f6a774a892152bcb", "version" : "1.26.0" } }, { "identity" : "swiftygif", "kind" : "remoteSourceControl", "location" : "https://github.com/kirualex/SwiftyGif.git", "state" : { "revision" : "4430cbc148baa3907651d40562d96325426f409a", "version" : "5.4.5" } } ], "version" : 3 } ```

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
```yml Replace this line with the contents of your Podfile.lock! ```
nik6018 commented 3 months ago

@rizafran I apologise as I wasn't able to follow up on the similar issue I opend last time, as the crash died down significantly.

But now with the updated release, the crashes have increased

I have tried to use the atos command using the memory address but it's not helpful, as it gives the same text as the crash report.

paulb777 commented 3 months ago

@nik6018 Does the listener get called? Does modifying it make any difference?

nik6018 commented 3 months ago

Yes the listener is called and data is fetched from Remote Config, whenever we change values on the Dashboard. That flow is working is perfectly.

We're seeing lots of non fatals For RemoteConfigRealTime that we have logged when the listener error's out. Though this error is mostly triggered when internet connectivity is very low.

Non-fatal: Error
0  My App                        0x15555a4 FIRCLSUserLoggingRecordError + 393 (FIRCLSUserLogging.m:393)
1  My App                        0x60ed84 closure #1 in RemoteConfigRealTimeUpdateManager.startListening() + 95 (RemoteConfigRealTimeUpdateManager.swift:95)
2  My App                         0x60f2a4 thunk for @escaping @callee_guaranteed (@guaranteed FIRRemoteConfigUpdate?, @guaranteed Error?) -> () (<compiler-generated>)
3  My App                          0x11c688c __37-[RCNConfigRealtime propogateErrors:]_block_invoke + 161 (RCNConfigRealtime.m:161)
4  libdispatch.dylib              0x26a8 _dispatch_call_block_and_release
5  libdispatch.dylib              0x4300 _dispatch_client_callout
6  libdispatch.dylib              0xb894 _dispatch_lane_serial_drain
7  libdispatch.dylib              0xc3c4 _dispatch_lane_invoke
8  libdispatch.dylib              0x17004 _dispatch_root_queue_drain_deferred_wlh
9  libdispatch.dylib              0x16878 _dispatch_workloop_worker_thread
10 libsystem_pthread.dylib        0x1964 _pthread_wqthread
11 libsystem_pthread.dylib        0x1a04 start_wqthread
paulb777 commented 3 months ago

Can you share the listener implementation?

nik6018 commented 2 months ago

Here is the implementation:

func startListening() {

        self.configListner = self.remoteConfig.addOnConfigUpdateListener { configUpdate, error in
            guard let configUpdate, error == nil else {
                print("Error listening for config updates: \(error)")

                // Log the Non-fatal crash
                let userInfo: [String: Any] = ["userId": usercontext.userId,
                                               "error": error!.localizedDescription]

                let err = NSError.init(domain: "Firebase.RemoteConfig.RealTimeUpdate", code: -1, userInfo: userInfo)
                Crashlytics.crashlytics().record(error: err)
                Crashlytics.crashlytics().setUserID(usercontext.userId)

                return
            }

            // To log which keys have been updated
            let updatedKeysString = configUpdate.updatedKeys.reduce(into: "") { partialResult, nextElement in
                partialResult += nextElement
            }

            self.fetchData() // Fetch the actual data from Remote Config
        }
 }
google-oss-bot commented 2 months ago

Hey @nik6018. 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!

cohen72 commented 2 months ago

We are also seeing this crash randomly occuring. We are simply calling addOnConfigUpdateListener on app launch.

Crashed: com.google.GoogleConfigService.FIRRemoteConfig
0  libobjc.A.dylib                0x1b60 objc_release_x0 + 16
1  libobjc.A.dylib                0x1b60 objc_release + 16
2  CoreFoundation                 0x5d474 -[__NSSingleObjectArrayI dealloc] + 64
3  CoreFoundation                 0x2b9d8 __CFBasicHashReplaceValue + 432
4  CoreFoundation                 0x2a2e4 CFDictionarySetValue + 208
5  CFNetwork                      0x9028 CFURLResponseGetExpectedContentLength + 644
6  CFNetwork                      0x8e98 CFURLResponseGetExpectedContentLength + 244
7  CFNetwork                      0x8240 CFURLRequestSetHTTPHeaderFieldValue + 136
8  Nanit                          0x169d5dc -[RCNConfigRealtime createRequestBody] + 309 (RCNConfigRealtime.m:309)
9  Nanit                          0x169ed54 __40-[RCNConfigRealtime beginRealtimeStream]_block_invoke + 667 (RCNConfigRealtime.m:667)
10 libdispatch.dylib              0x213c _dispatch_call_block_and_release + 32
11 libdispatch.dylib              0x3dd4 _dispatch_client_callout + 20
12 libdispatch.dylib              0xb400 _dispatch_lane_serial_drain + 748
13 libdispatch.dylib              0xbf30 _dispatch_lane_invoke + 380
14 libdispatch.dylib              0x16cb4 _dispatch_root_queue_drain_deferred_wlh + 288
15 libdispatch.dylib              0x16528 _dispatch_workloop_worker_thread + 404
16 libsystem_pthread.dylib        0x4934 _pthread_wqthread + 288
17 libsystem_pthread.dylib        0x10cc start_wqthread + 8

So far it has happened for 4 of our users out of 34,000

nik6018 commented 2 months ago

We have reviewed the crashes again and it seems that the crashes are triggered whenever RealTime Remote Config is fetched Remote Config values when anything on the dashboard changes

ncooke3 commented 2 months ago

Hi all, I was not able to reproduce these crashes but I did identify some potential causes that I aimed to address in https://github.com/firebase/firebase-ios-sdk/pull/13275. These changes will be released in the next release, Firebase 11.0.0, which is scheduled to release later this month.