segmentio / analytics-kotlin

The hassle-free way to add Segment analytics to your Kotlin app (Android/JVM).

Repository from Github https://github.comsegmentio/analytics-kotlinRepository from Github https://github.comsegmentio/analytics-kotlin

Sporadic crash "queuedEvents.poll() must not be null"

peterplamenovpenchev opened this issue · comments

Description
We get sporadic crashes from time to time.

To Reproduce
Wasn't able to reproduce it locally.

Stack trace

Fatal Exception: java.lang.NullPointerException: queuedEvents.poll() must not be null
       at com.segment.analytics.kotlin.core.platform.plugins.StartupQueue.replayEvents(StartupQueue.kt:68)
       at com.segment.analytics.kotlin.core.platform.plugins.StartupQueue.runningUpdate(StartupQueue.kt:61)
       at com.segment.analytics.kotlin.core.platform.plugins.StartupQueue.access$runningUpdate(StartupQueue.kt:19)
       at com.segment.analytics.kotlin.core.platform.plugins.StartupQueue$setup$1$1.invokeSuspend$runningUpdate(StartupQueue.kt:35)
       at com.segment.analytics.kotlin.core.platform.plugins.StartupQueue$setup$1$1.access$invokeSuspend$runningUpdate(StartupQueue.kt)
       at com.segment.analytics.kotlin.core.platform.plugins.StartupQueue$setup$1$1$1.invoke(StartupQueue.kt:35)
       at com.segment.analytics.kotlin.core.platform.plugins.StartupQueue$setup$1$1$1.invoke(StartupQueue.kt:35)
       at sovran.kotlin.Store$notify$2.invokeSuspend(Store.kt:219)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
       at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.java:570)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

Platform:

  • Library Version in use: 1.8.0
  • Platform being tested: Android
  • Integrations in use: Mixpanel, Appcues

Additional context:

The crash happens within 1 sec of app start up.
Also it happens of various Android OS versions.

hey @peterplamenovpenchev thanks for reporting this issue. yeah. there is a race condition for this to happen. we will get this addressed.

Hey @peterplamenovpenchev, this has been fixed and is released:

https://github.com/segmentio/analytics-kotlin/releases/tag/1.9.2

Thanks for submitting the issue!