launchdarkly / ios-client-sdk

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

EXC_BAD_ACCESS FlagSynchronizer:63 #314

Open m1entus opened 8 months ago

m1entus commented 8 months ago

Describe the bug Crash (synchronization issue)

SDK version 9.1.1

OS/platform iOS

Additional context

Zrzut ekranu 2023-10-17 o 10 57 18

Seems this is retain cycle issue:

self.throttler.runThrottled {
      // since going online was throttled, check the last called setOnline value and whether we can go online
      self.go(online: goOnline && self.canGoOnline, reasonOnlineUnavailable: self.reasonOnlineUnavailable(goOnline: goOnline), completion: completion)
}

here you are capturing self inside throttler: LDClient -> throttler -> runQueue -> runThrottled -> self (LDClient)

this method should look like this:

self.throttler.runThrottled { [weak self] in
      guard let self else {
          completion?()
          return
      }
      // since going online was throttled, check the last called setOnline value and whether we can go online
      self.go(online: goOnline && self.canGoOnline, reasonOnlineUnavailable: self.reasonOnlineUnavailable(goOnline: goOnline), completion: completion)
}
tanderson-ld commented 8 months ago

Hi @m1entus , how frequently are you encountering this issue? Also, thank you for digging deeply and providing an option to fix the issue.

m1entus commented 8 months ago

Just got one crash in Sentry analitycs - so preety rare, but maybe this also can caouse because app is entering background and you are dosing some async action, hard to say really.

tanderson-ld commented 8 months ago

@m1entus , could you provide a rough estimate of number of sessions your customer base runs per day? That will help us evaluate the frequency in a relative percentage.

m1entus commented 8 months ago

@tanderson-ld To be honest it appears only once so far