launchdarkly / android-client-sdk

LaunchDarkly Client-side SDK for Android
Other
45 stars 23 forks source link

ANR onNetworkConnectivityChangeInstances #142

Closed dsuresh-ap closed 2 years ago

dsuresh-ap commented 2 years ago

Describe the bug We have a few reported ANRs in our Google Play console. It shows the main thread as being blocked.

To reproduce We were not able to reproduce this issue. We have a feeling this is related to static synchronized void onNetworkConnectivityChangeInstances(boolean network) being synchronized and public static synchronized LDClient init(Application application, LDConfig config, LDUser user, int startWaitSeconds) being synchronized as well causing a race-condition.

Expected behavior This ANR should not happen.

Logs

"main" prio=5 tid=1 Blocked
  at com.launchdarkly.android.LDClient.onNetworkConnectivityChangeInstances (LDClient.java)
  at com.launchdarkly.android.ConnectivityReceiver.onReceive (ConnectivityReceiver.java:29)
  at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args (LoadedApk.java:1706)
  at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run (lambda)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:264)
  at android.app.ActivityThread.main (ActivityThread.java:8262)
  at java.lang.reflect.Method.invoke (Native method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:632)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1049)

SDK version 2.12.0

Language version, developer tools Android Studio, Kotlin 1.5

OS/platform Android 11, Android 11 Reported devices: Google Pixel 3a, Redmi 9, Redmi Note 9s, Redmi Note 8 Pro, others

gwhelanLD commented 2 years ago

Hi @dsuresh-ap,

Thanks for reporting this issue, I've filed it internally to take a look at. Could you let us know if you have any information on whether these ANRs occurred when the application was in the background or in the foreground?

I'd also like to suggest updating your SDK to at least 2.14.2, and consider updating to 3.x. 2.12 has recently exceeded our EOL timeframe as per our end of life policy.

Thanks! @gwhelanLD

dsuresh-ap commented 2 years ago

Hi @gwhelanLD, the Google Play console does not show us any indication of the app's foreground state for these ANRs unfortunately.

Understood, will try updating the library.

dsuresh-ap commented 2 years ago

Hi @gwhelanLD, sorry for such a late reply but I forgot I filed an issue here. We have been on 3.1.2 for over a year and we still have the same ANRs from above. Looks like they are still only Android 11 devices, foreground, backgrounded. Any details or updates we should be looking out for?

cc @tcolligan

image

louis-launchdarkly commented 2 years ago

Hello @dsuresh-ap, thank you for reporting the issue. We will need to look into this more. Given this is not showing up in Android 12, I wonder is there some slower operation in Android 11 that pushed the network change call to be longer than the Android Not Responding time limit.

fparhat-rbi commented 2 years ago

Hi Team, We are seeing ANRs coming from Android when using the react-native SDK (6.2.0).

Based on the stack, it looks like it is the same issue as this one: https://github.com/launchdarkly/react-native-client-sdk/issues/144#issue-1301163082

louis-launchdarkly commented 2 years ago

Hello @dsuresh-ap, we just released Android 3.1.6 which should address the init and onConnectivityChange ANR problem. Please give that a try and let us know.

Hello @fparhat-rbi, we will do an RN release next to use this newer version of the Android SDK.

louis-launchdarkly commented 2 years ago

Several fixes in the 3.1.6 release were related to potential causes of ANRs. We're closing this issue due to a lack of further reports, but please feel free to open a new issue if you are still seeing similar behavior.