A small screen shows the state of the active session’s background “heartbeat”: whether monitoring is connected and how many signals have already been received. After a recent change, the behavior became unstable when leaving the screen and reopening it. You need to review the diff and find the causes of the regression.
SessionHeartbeatSource.HeartbeatActivity.Emit heartbeat several times and make sure the counter increases.finish() and open it again as a new instance.Emit heartbeat again.emit() from a background thread, for example like this:Thread {
HeartbeatRegistry.source.emit()
}.start()
emit() for the current screen.StateFlow for the UI must not depend on which thread the callback came from.org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.12.8.4ViewModel from androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.4Activityfinish(), and the process is not killed by the system between stepsSessionHeartbeatSource invokes the callback on the same thread from which emit() was calledUse line comments to explain the problem, its impact, the fix and how to test it.