statsig-io / android-sdk

Statsig's SDK for client-side Android applications written in Java or Kotlin
ISC License
9 stars 4 forks source link

If I use the method Statsig.shutdown() on android my app crashes because of the runBlocking #2

Closed tore-statsig closed 2 years ago

tore-statsig commented 2 years ago

Migrated from https://github.com/statsig-io/ruby-sdk/issues/3

tore-statsig commented 2 years ago

Which version of the SDK was this happening on? I think we already have a change pending which might fix this. Hang tight, gonna publish a new version

tore-statsig commented 2 years ago

Published v4.3.1 - I think this should address it. I suspect this is the key change:

https://github.com/statsig-io/android-sdk/blob/main/src/main/java/com/statsig/androidsdk/StatsigLogger.kt#L107

tore-statsig commented 2 years ago

If you're using kotlin, you could also try the shutdownSuspend method instead, and use your own coroutine logic for waiting (or not) for that to resolve

pablobaxter commented 2 years ago

@AndreNagem, do you have a stack trace for you crash?

AndreNagem commented 2 years ago

@tore-statsig I have tried to use v4.3.0, v4.2.4 and v4.2.2. None have worked Really good news is that shutdownSuspend worked for me, thank you very much !

@pablobaxter My app does not crash, with an fatal error it just stop responding, I believe it is because of the runBlocking that is used in .shutdown() method, therefore I could not retrieve any log or stack trace from this error, I have tried many things to catch any log, but could not get any

pablobaxter commented 2 years ago

Gotcha. Were you using a coroutine with the main dispatcher to call shutdown()?

tore-statsig commented 2 years ago

@AndreNagem - but did you try v4.3.1? Thats the only version that contains the potential fix I pointed out (which seems related to your app hanging and not exiting)

Glad shutdownSuspend is working, but that wont guarantee your logs are posted to Statsig servers before the app exits

tore-statsig commented 2 years ago

Closing this for lack of repro steps, and because there is a workaround. We've also updated the shutdown path and it should not crash