firebase-ios-sdk: Crash in APMMeasurement with a dependency

  • Xcode version: 12.4
  • Firebase SDK version: 7.6.0
  • Installation method: `CocoaPods
  • Firebase Component: Core

I integrate Firebase in my app, and when I run the app it crash. It’s something related with measurement and with a dependency in my app (EthereumKit.swift), if I remove this dependency the app not crash.

Steps to reproduce:

Create a blank app with the following dependencies

pod 'Firebase/Crashlytics'
pod 'Firebase/Core'
pod 'EthereumKit.swift'

Add a GoogleService-Info.plist and add call to FirebaseApp.configure() in AppDelegate Run the app and you receive the following crash

Crashed: com.google.fira.worker
0  EthereumKit                    0x10fe7c0f0 load_descriptor_values + 64
1  EthereumKit                    0x10fe7c0a4 pb_field_iter_begin + 84
2  EthereumKit                    0x10fe87375 pb_encode + 53
3  Wallet                         0x10e3cb453 nano_two_pass_encoding + 62
4  Wallet                         0x10e3a891f apmpb_encode_measurement_bundle + 93
5  Wallet                         0x10e3b2c8a -[APMPBMeasurementBundle protoBuffer] + 33
6  Wallet                         0x10e3527c3 -[APMDatabase insertIfNotExistsRawEventMetadata:error:] + 68
7  Wallet                         0x10e3889e6 -[APMMeasurement(Event) writeEvent:isPublicEvent:isRealtime:] + 1248
8  Wallet                         0x10e385f04 __49-[APMMeasurement(Event) writeEventOnWorkerQueue:]_block_invoke + 668
9  Wallet                         0x10e3c6d42 -[APMSqliteStore performTransactionWithError:block:] + 188
10 Wallet                         0x10e3517ec -[APMDatabase performTransaction:] + 48
11 Wallet                         0x10e385b89 -[APMMeasurement(Event) writeEventOnWorkerQueue:] + 833
12 Wallet                         0x10e3856a3 -[APMMeasurement(Event) handleEventOnWorkerQueue:] + 559
13 Wallet                         0x10e39489c -[APMMeasurement logEventOnWorkerQueue:notifyEventListeners:] + 72
14 Wallet                         0x10e3947e5 -[APMMeasurement logEventOnWorkerQueueWithOrigin:isPublicEvent:name:parameters:timestamp:enabled:ignoreEnabled:ignoreInterceptor:interceptor:addedScreenParameters:] + 673
15 Wallet                         0x10e3944a1 __151-[APMMeasurement logEventWithOrigin:isPublicEvent:name:parameters:timestamp:enabled:ignoreEnabled:ignoreInterceptor:interceptor:addedScreenParameters:]_block_invoke + 76
16 Wallet                         0x10e3bad35 __51-[APMScheduler scheduleOnWorkerQueueBlockID:block:]_block_invoke + 29
17 libdispatch.dylib              0x7fff2010532f _dispatch_call_block_and_release + 12
18 libdispatch.dylib              0x7fff20106508 _dispatch_client_callout + 8
19 libdispatch.dylib              0x7fff2010c3f9 _dispatch_lane_serial_drain + 715
20 libdispatch.dylib              0x7fff2010cf74 _dispatch_lane_invoke + 403
21 libdispatch.dylib              0x7fff20117577 _dispatch_workloop_worker_thread + 782
22 libsystem_pthread.dylib        0x7fff61167499 _pthread_wqthread + 314
23 libsystem_pthread.dylib        0x7fff61166467 start_wqthread + 15

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (9 by maintainers)

Most upvoted comments

Ah ok, you have the settings in the podspec instead of xcframework, fair enough 😃 Thanks!

@jimon Understood, and that is why we use package managers to enforce one copy of any framework. The package manager should enforce that only one copy gets used. If any client uses nanopb on its own, it should rename the symbols to avoid the collisions.

There is additional complexity for binary distributions. For source distributions, everything can be rebuilt with consistent flags by the app. For prebuilt binary distributions, like GoogleAppMeasurement and presumably EthereumKit.swift’s libIncubed.a, there is no good solution for the app developers since there is a conflict between the library providers’ assumptions.

nanopb also has additional complexities beyond most libraries, because it is not a pure library, but requires clients to be built differently based on how it is built itself. Therefore it is not sufficient for clients to depend on the same package distribution, they also need to be built with the same options, which is why the Firebase podspecs specify https://github.com/firebase/firebase-ios-sdk/blob/master/FirebaseCoreDiagnostics.podspec#L44

Good catch @jimon. Thanks for sharing.

Yes this problem could be related to two incompatible nanopb builds and it is important to use the same flags.

It looks like EthereumKit.swift/EthereumKit/Libraries/lib/libIncubed.a includes a binary version of pb_encode that is intercepting the version from the nanopb CocoaPod that the GoogleAppMeasurement CocoaPod expect to use.

Firebase nanopb libraries should be built with the options PB_FIELD_32BIT=1 PB_NO_PACKED_STRUCTS=1 PB_ENABLE_MALLOC=1.

If the EthereumKit.swift library doesn’t use the CocoaPods version of nanopb, it should rename the symbols in its binary version to avoid the conflict.

It looks like one of the pod dependencies of EthereumKit.swift - GRDB.swift - has an internal sqlite3 implementation that is interfering with the FirebaseAnalytics system sqlite3 dependency.