Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RemoteConfig] Crash if initializing after app start #3344

Closed
tecbot opened this issue Jul 12, 2019 · 27 comments

Comments

@tecbot
Copy link

commented Jul 12, 2019

[REQUIRED] Step 2: Describe your environment

  • Xcode version: 10.2.1
  • Firebase SDK version: 6.4.0
  • Firebase Component: RemoteConfig
  • Component version: 4.2.0

[REQUIRED] Step 3: Describe the problem

Stack trace:

EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000fca8c6b30
-[RCNConfigExperiment initWithDBManager:]

Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x180d87530 objc_msgSend + 16
1  Runner                         0x10284c130 -[RCNConfigExperiment initWithDBManager:] + 4376871216
2  Runner                         0x102841920 -[FIRRemoteConfig initWithAppName:FIROptions:namespace:DBManager:configContent:] + 4376828192
3  Runner                         0x1028450e8 -[FIRRemoteConfigComponent remoteConfigForNamespace:] + 4376842472
4  Runner                         0x102841660 +[FIRRemoteConfig remoteConfigWithFIRNamespace:app:] + 4376827488
5  Runner                         0x102841720 +[FIRRemoteConfig remoteConfig] + 4376827680
6  Runner                         0x102905bec -[FirebaseRemoteConfigPlugin handleMethodCall:result:] + 39 (FirebaseRemoteConfigPlugin.m:39)
7  Flutter                        0x102f55ba8 (Missing)
8  Flutter                        0x102ef96a4 (Missing)
9  Flutter                        0x102f48ad0 (Missing)
10 Flutter                        0x102f04534 (Missing)
11 Flutter                        0x102f07cc8 (Missing)
12 CoreFoundation                 0x181b27650 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 28
13 CoreFoundation                 0x181b27380 __CFRunLoopDoTimer + 864
14 CoreFoundation                 0x181b26bb4 __CFRunLoopDoTimers + 248
15 CoreFoundation                 0x181b21b04 __CFRunLoopRun + 1844
16 CoreFoundation                 0x181b210b0 CFRunLoopRunSpecific + 436
17 GraphicsServices               0x183d2179c GSEventRunModal + 104
18 UIKitCore                      0x1ae38d978 UIApplicationMain + 212
19 Runner                         0x102601d48 main + 5 (AppDelegate.swift:5)
20 libdyld.dylib                  0x1815e68e0 start + 4

Steps to reproduce:

After upgrading Firebase dependencies from 6.3.0 to 6.4.0 and RemoteConfig from 4.1.0 to 4.2.0 we are getting crashes directly on app start. If the crash happen the next app starts are working. After some time (~1 hour) the crash happen again. We are using Firebase in a Flutter project.

Relevant Code:

Entry point: https://github.com/flutter/plugins/blob/master/packages/firebase_remote_config/ios/Classes/FirebaseRemoteConfigPlugin.m#L39

@ryanwilson

This comment has been minimized.

Copy link
Member

commented Jul 12, 2019

Hi @tecbot - looking into this right away. Some quick questions as I start investigating:

  • Does this happen on any specific iOS version, or all of them?
  • Does it happen on both device and simulator?
  • Can you enable Zombies in your application and see where it's failing? It looks like it's trying to access an already deallocated instance of something (based on KERN_INVALID_ADDRESS)

Thanks, and sorry for the troubles!

@ryanwilson

This comment has been minimized.

Copy link
Member

commented Jul 12, 2019

I haven't been able to reproduce this using a non-Flutter app, looking at setting up Flutter in order to try it out. If you have a plain reproduction (without GoogleService-Info.plist) you could share, it'd be very helpful 🙂

@mouness2020

This comment has been minimized.

Copy link

commented Jul 13, 2019

I have 2 crashes in same class in my apps :
first one
RCNConfigExperiment initWithDBManager
Fatal Exception: NSInvalidArgumentException-[__NSCFString setTimeZone:]: unrecognized selector sent to instance 0x2800f36f0

second one
-[RCNConfigExperiment initWithDBManager:]
Crashed: com.google.perf.FPREventsQueue
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x7265567733237863

com.test.app_issue_crash_f34c5ae3e6924654a8390f7336a46fd3_DNE_0_v2.txt
com.test.app_issue_crash_ed38c08906b044109d994521a23efeb5_DNE_0_v2.txt

 

@paulb777

This comment has been minimized.

Copy link
Member

commented Jul 13, 2019

@mouness2020 Thanks for the additional detail.

@ryanwilson, @dmandar I suspect a thread safety issue with the static variable assigned the NSDateFormatter. One thread is creating another instance while another thread is sending the setTimeZone: message.

@ryanwilson ryanwilson removed the needs-info label Jul 14, 2019

@ryanwilson

This comment has been minimized.

Copy link
Member

commented Jul 14, 2019

Thanks folks for the extra information - I have a pending fix internally at cl/258032937.

We still haven't been able to reproduce this, so if anyone can provide reproduction steps so we can verify the fix works properly, it would be greatly appreciated.

@paulb777 paulb777 added this to the M52 milestone Jul 15, 2019

@dmandar

This comment has been minimized.

Copy link
Collaborator

commented Jul 15, 2019

This crash should only happen if you are using FirePerf or if you have multiple active instances of RC (not common) in your app. Please let us know if it s not the case for you.

@mouness2020

This comment has been minimized.

Copy link

commented Jul 16, 2019

Yes that's true i'm using FirePef .. also i have two firebase projects
one for live api and second one for test api but one of them works at time

let firebasePlistFileName: String = typeURL != "api" ? "GoogleService-Info-test" : "GoogleService-Info"
        
        if let path = Bundle.main.path(forResource: firebasePlistFileName, ofType: "plist"),let firbaseOptions = FirebaseOptions(contentsOfFile: path){
            
            firbaseOptions.deepLinkURLScheme = self.customURLScheme
            
            FirebaseOptions.defaultOptions()?.deepLinkURLScheme =  self.customURLScheme
            FirebaseConfiguration.shared.setLoggerLevel(.min)
            FirebaseApp.configure(options: firbaseOptions)
            
            
        }
        
        Analytics.setAnalyticsCollectionEnabled(true)
        Performance.sharedInstance().isInstrumentationEnabled = true
        Performance.sharedInstance().isDataCollectionEnabled = true
      
@b-onc

This comment has been minimized.

Copy link

commented Jul 16, 2019

We also experience this crash, we have a single instance of RC and we do use Firebase Performance. The crash happens half of the times on a clean install. Removing Firebase Performance fixes this issue. In the meantime we downgraded to 6.3.0

@igiazlas

This comment has been minimized.

Copy link

commented Jul 17, 2019

I also have this issue. It happens on fresh installs and old ones.

My configuration on AppDelegate is

// Firebase

#if DEVELOP
    let firConfigFilename = "GoogleService-Info-Dev"
#else
    let firConfigFilename = "GoogleService-Info"
#endif

let firConfigPath = Bundle.main.path(forResource: firConfigFilename, ofType: "plist")!

FirebaseApp.configure(options: FirebaseOptions(contentsOfFile: firConfigPath)!)
FirebaseConfiguration.shared.setLoggerLevel(.min)

// Remote Config

let remoteConfig = RemoteConfig.remoteConfig()
remoteConfig.setDefaults(fromPlist: "RemoteConfigDefaults")
remoteConfig.fetchAndActivate()
@ryanwilson

This comment has been minimized.

Copy link
Member

commented Jul 17, 2019

@igiazlas thanks for the report. Is reproducible for you on a local test device? If so, what iOS version and what device / simulator are you using?

We have what we believe is a fix going into the next release that's being packaged and tested shortly, hopefully we can find a reliable repro to validate this issue goes away.

@igiazlas

This comment has been minimized.

Copy link

commented Jul 17, 2019

I can reproduce it on an iPhone X running 12.3.1, on a 5s running 12.4 beta but not on a 6s running 11.4.1 (see edit). Also in all the 12.3.1 simulators I checked. It is consistent if I leave the last 3 lines in AppDelegate. If I remove them, and don't put them anywhere else, it does not crash, at least not for the first 20-30 seconds that I let it run.

Edit: Before your last comment I downgraded to 6.3.0 and run the app on my devices with no problems. I upgraded again to make recheck the 11.4.1 6s and it didn't crash. The weird thing is that after I build for the other devices they also do not crash anymore. When I delete the app and rebuild it it starts crashing again. So on some old installs it does not crash but it does crash consistently on fresh installs (Delete, Build, Install) on all devices, including the 6s with 11.4.1.

Edit 2: I have about 50 keys on my default configuration about 70 in total, including many that I do not use as they are used by the Android app

Edit 3: It is not that consistent after all. In some cases, removing and reinstalling the app does not cause a crash.

@KevinLaRosa

This comment has been minimized.

Copy link

commented Jul 17, 2019

Hi there,
Same problem for me on my device iPhone X 12.3.1 after a pod update to 6.4.0.
I use Firebase with RemoteConfig and Performance and I have the same setup than @igiazlas except that I set my defaults from a dictionary and call fetch:withExpirationDuration and after activate.

As said before @b-onc, I suspect a conflict with Performance because I don't have the same problem after a migration of firebase on Carthage without performance.

@igiazlas

This comment has been minimized.

Copy link

commented Jul 17, 2019

I also use Firebase Performance as @KevinLaRosa. This is the Firebase values I have on the Podfile.lock

- Firebase/Analytics (6.4.0):
  - Firebase/Core
- Firebase/Auth (6.4.0):
  - Firebase/CoreOnly
  - FirebaseAuth (~> 6.2.0)
- Firebase/Core (6.4.0):
  - Firebase/CoreOnly
  - FirebaseAnalytics (= 6.0.3)
- Firebase/CoreOnly (6.4.0):
  - FirebaseCore (= 6.0.4)
- Firebase/Performance (6.4.0):
  - Firebase/CoreOnly
  - FirebasePerformance (~> 3.1.1)
- Firebase/RemoteConfig (6.4.0):
  - Firebase/CoreOnly
  - FirebaseRemoteConfig (~> 4.2.0)
- FirebaseABTesting (3.0.0):
  - FirebaseCore (~> 6.0)
  - Protobuf (~> 3.5)
- FirebaseAnalytics (6.0.3):
  - FirebaseCore (~> 6.0)
  - FirebaseInstanceID (~> 4.2)
  - GoogleAppMeasurement (= 6.0.3)
  - GoogleUtilities/AppDelegateSwizzler (~> 6.0)
  - GoogleUtilities/MethodSwizzler (~> 6.0)
  - GoogleUtilities/Network (~> 6.0)
  - "GoogleUtilities/NSData+zlib (~> 6.0)"
  - nanopb (~> 0.3)
- FirebaseAuth (6.2.0):
  - FirebaseAuthInterop (~> 1.0)
  - FirebaseCore (~> 6.0)
  - GoogleUtilities/AppDelegateSwizzler (~> 6.2)
  - GoogleUtilities/Environment (~> 6.2)
  - GTMSessionFetcher/Core (~> 1.1)
- FirebaseAuthInterop (1.0.0)
- FirebaseCore (6.0.4):
  - GoogleUtilities/Environment (~> 6.0)
  - GoogleUtilities/Logger (~> 6.0)
- FirebaseInstanceID (4.2.1):
  - FirebaseCore (~> 6.0)
  - GoogleUtilities/Environment (~> 6.0)
  - GoogleUtilities/UserDefaults (~> 6.0)
- FirebasePerformance (3.1.1):
  - FirebaseCore (~> 6.0)
  - FirebaseInstanceID (~> 4.2)
  - FirebaseRemoteConfig (~> 4.2)
  - GoogleToolboxForMac/Logger (~> 2.1)
  - "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
  - GoogleUtilities/Environment (~> 6.0)
  - GoogleUtilities/ISASwizzler (~> 6.0)
  - GoogleUtilities/MethodSwizzler (~> 6.0)
  - GTMSessionFetcher/Core (~> 1.1)
  - Protobuf (~> 3.5)
- FirebaseRemoteConfig (4.2.0):
  - FirebaseABTesting (~> 3.0)
  - FirebaseCore (~> 6.0)
  - FirebaseInstanceID (~> 4.2)
  - GoogleUtilities/Environment (~> 6.0)
  - "GoogleUtilities/NSData+zlib (~> 6.0)"
  - Protobuf (~> 3.5)
- FirebaseUI/Auth (8.0.4):
  - Firebase/Auth (~> 6.0)
  - GoogleUtilities/UserDefaults
- FirebaseUI/Facebook (8.0.4):
  - FBSDKLoginKit (~> 5.0)
  - FirebaseUI/Auth
- FirebaseUI/Google (8.0.4):
  - FirebaseUI/Auth
  - GoogleSignIn (~> 4.0)
@ryanwilson

This comment has been minimized.

Copy link
Member

commented Jul 17, 2019

@igiazlas can you verify which simulator versions you're using? As far as I'm aware there are no 12.3.1 simulators, only 12.2.

@KevinLaRosa

This comment has been minimized.

Copy link

commented Jul 17, 2019

I have half the time the crash on simulator 12.2.

2019-07-17 16:37:14.252544+0200 xxx [8058:366577] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSMallocBlock__ setLocale:]: unrecognized selector sent to instance 0x60000162e3a0'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000011999c1bb __exceptionPreprocess + 331
	1   libobjc.A.dylib                     0x0000000118f3a735 objc_exception_throw + 48
	2   CoreFoundation                      0x00000001199baf44 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
	3   CoreFoundation                      0x00000001199a0ed6 ___forwarding___ + 1446
	4   CoreFoundation                      0x00000001199a2da8 _CF_forwarding_prep_0 + 120
	5   xxxKit                       0x00000001188e3776 -[RCNConfigExperiment initWithDBManager:] + 379
	6   xxxKit                        0x00000001188d8bf2 -[FIRRemoteConfig initWithAppName:FIROptions:namespace:DBManager:configContent:] + 440
	7   xxxKit                        0x00000001188dc497 -[FIRRemoteConfigComponent remoteConfigForNamespace:] + 668
	8   xxx                      0x000000010eba6aa0 +[FIRRemoteConfig remoteConfigWithFIRNamespace:app:] + 133
	9   xxx                      0x000000010eb1da51 __38+[FPRRemoteConfigFlags sharedInstance]_block_invoke + 76
	10  libdispatch.dylib                   0x000000011b63f602 _dispatch_client_callout + 8
	11  libdispatch.dylib                   0x000000011b6410c4 _dispatch_once_callout + 66
	12  xxx                      0x000000010eb1da02 +[FPRRemoteConfigFlags sharedInstance] + 45
	13  xxx                      0x000000010eb1c896 -[FPRConfigurations setupRemoteConfigFlags] + 135
	14  xxx                     0x000000010eb1c7d7 -[FPRConfigurations update] + 125
	15  xxx                      0x000000010eb1fa15 __42-[FPRClient startWithConfiguration:error:]_block_invoke + 802
	16  libdispatch.dylib                   0x000000011b63e595 _dispatch_call_block_and_release + 12
	17  libdispatch.dylib                   0x000000011b63f602 _dispatch_client_callout + 8
	18  libdispatch.dylib                   0x000000011b646cad _dispatch_lane_serial_drain + 1209
	19  libdispatch.dylib                   0x000000011b647784 _dispatch_lane_invoke + 428
	20  libdispatch.dylib                   0x000000011b65189a _dispatch_workloop_worker_thread + 733
	21  libsystem_pthread.dylib             0x000000011ba2d611 _pthread_wqthread + 421
	22  libsystem_pthread.dylib             0x000000011ba2d3fd start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
@igiazlas

This comment has been minimized.

Copy link

commented Jul 17, 2019

@ryanwilson you are right, I meant to say the latest simulators which are 12.2

@dmandar

This comment has been minimized.

Copy link
Collaborator

commented Jul 17, 2019

Based on all your input, we have made a fix for a race that occurs if Perf and RC SDK are both included, which should be out soon. @igiazlas can you also confirm you are also using FirePerf? If not, please confirm if you have the same stack trace.

@igiazlas

This comment has been minimized.

Copy link

commented Jul 17, 2019

@dmandar yes, I also use FirePerf. I've posted my Podfile.lock above.

@kennic

This comment has been minimized.

Copy link

commented Jul 18, 2019

My app also crashes a lot because of this
Screen Shot 2019-07-18 at 12 41 35 PM
Screen Shot 2019-07-18 at 12 43 45 PM
Screen Shot 2019-07-18 at 12 44 06 PM

@bajtyngier

This comment has been minimized.

Copy link

commented Jul 18, 2019

Also experiencing the crash at times.
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000007b9678940
-[RCNConfigExperiment initWithDBManager:]

Not present in 6.3.0

@paulb777

This comment has been minimized.

Copy link
Member

commented Jul 18, 2019

Firebase 6.5.0 just released with a fix. We were never able to reproduce the issue internally so would appreciate confirmation from those who saw the issue.

@paulb777 paulb777 closed this Jul 18, 2019

@thomaslange

This comment has been minimized.

Copy link

commented Jul 19, 2019

@paulb777 I can confirm the fix. Thanks for your quick help!

@manishmittal79

This comment has been minimized.

Copy link

commented Aug 3, 2019

I was getting the similar crashes on app start during the UITests running on CI using Firebase 6.3. After upgrading to 6.5 today, and running couple of times I can no longer see this crash on startup. Thanks

@ppamorim

This comment has been minimized.

Copy link

commented Sep 10, 2019

Same crash happening on Firebase (6.7.0) and FirebaseCore (6.2.1).

@ryanwilson

This comment has been minimized.

Copy link
Member

commented Sep 10, 2019

@ppamorim can you please update to the latest version Firebase (6.8.1) and let us know if you're still seeing the crash?

@ppamorim

This comment has been minimized.

Copy link

commented Sep 11, 2019

@ryanwilson I will, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.