A small preview screen connects to a frame source when the Activity starts and shows the last received text frame. After a recent PR, the behavior became unstable: when reopening the screen, updates are sometimes duplicated, and the connection indicator can remain active after leaving the screen.
PreviewActivity screen must start receiving frames only while the Activity is in a state no lower than STARTED.FrameSource must be properly released.TextView with id previewText must update with the latest frame.TextView with id statusText must show Connected when there is an active connection, and Idle when there is none.PreviewActivity.Connected.Home or navigate to another screen so that the Activity goes to onStop.Idle after leaving.statusText does not remain in Connected while the screen is already stopped.androidx.appcompat:appcompat:1.7.0androidx.core:core-ktx:1.13.1androidx.lifecycle:lifecycle-runtime-ktx:2.8.4org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1Activity, without ComposeFrameSource is an in-process source that invokes the callback on the main threadonStart / onStop lifecycle is sufficient; process recreation is not requiredUse line comments to explain the problem, its impact, the fix and how to test it.