launchdarkly / ios-client-sdk

LaunchDarkly Client-side SDK for iOS (Swift and Obj-C)
https://docs.launchdarkly.com/sdk/client-side/ios
Other
69 stars 84 forks source link

Crash in FlagsUnchangedObserver #226

Closed NikolajMosbaek closed 3 years ago

NikolajMosbaek commented 3 years ago

A portion of the sessions crash in FlagsUnchangedObserver. I am unable to recreate the crash but it has happened on iOS 12, 13 & 14 for LaunchDarkly 5.1.0. The stack trace is as follows:

0 libdispatch.dylib     dispatch_group_leave$VARIANT$mp.cold.1
1 libdispatch.dylib     dispatch_group_leave$VARIANT$mp
2 LaunchDarkly          closure #2 () -> () in LaunchDarkly.LDClient.(go in _14C52C04C80D938C2FE76924F7908AD1)(online: Swift.Bool, reasonOnlineUnavailable: Swift.String, completion: () -> ()?) -> () LDClient.swift:143
3 LaunchDarkly          partial apply forwarder for closure #1 () -> () in closure #1 (LaunchDarkly.FlagsUnchangedObserver) -> () in closure #1 () -> () in LaunchDarkly.FlagChangeNotifier.notifyObservers(user: LaunchDarkly.LDUser, oldFlags: [Swift.String : LaunchDarkly.FeatureFlag]) -> () FlagChangeNotifier.swift:94
4 LaunchDarkly          reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_unowned @convention(block) () -> () <compiler-generated>:0
5 libdispatch.dylib     _dispatch_call_block_and_release
torchhound commented 3 years ago

Hi @NikolajMosbaek thanks for reporting this issue.

Filed internally as 91704.

torchhound commented 3 years ago

Hi @NikolajMosbaek would you please provide some additional context? Anything you can share (that isn't private or proprietary) about your SDK version, client configuration, or what code or part of your app's lifecycle is executing when the error happens. If additional context is private or proprietary information please reach out to our support staff to share it.

NikolajMosbaek commented 3 years ago

Hi @torchhound. I'm runnung version 5.1.0 on iOS. Since there's no reference to my app in the stack trace and the app has been running for various amounts of time it's hard for me to guess where in the app's lifecycle the crash occurs. I don't know which part of my LaunchDarkly setup that's relevant to be shared. Before running version 5.1.0 I was running the same setup on version 4.7.0 without any problems.

NikolajMosbaek commented 3 years ago

@torchhound Please let me know if there's anything in particular you need from me to get to the bottom of this. This issue is my most often occurring crash at the moment.

torchhound commented 3 years ago

@NikolajMosbaek Are you rapidly calling identify? Or perhaps calling identify quickly after SDK initialization or before/after your app going into the foreground/background?

NikolajMosbaek commented 3 years ago

@torchhound I cannot see any scenario in my code where identify would be rapidly called. I do, however, call it in the completion closure of LDClient.start. Do you believe that could be the issue? I will refactor my code so that is no longer the case and monitor whether it affect the crash.

NikolajMosbaek commented 3 years ago

It seems that did the trick, so I'll close this issue. Thanks to @torchhound!

torchhound commented 3 years ago

Thanks for bringing this to our attention @NikolajMosbaek! Glad you found a fix. We will try and patch this.