Make the screen preview disappear when its track ends
Listen for the LiveKit track lifecycle events your SDK exposes and remove or detach the displayed screen-share track when it is unpublished or unsubscribed. Also clear the view when the participant leaves or the room reconnects. Test each event path separately so a frozen last frame is not mistaken for a live screen.
What you need
For a product engineer or support-platform owner building consent-based on-screen help with LiveKit.
- A test room with a screen-sharing publisher and a separate viewer.
- The SDK-specific events and track source fields used by the application.
- Expected UI states for stopped sharing, unsubscribe, participant leave and reconnect.
Verify that a screen-share preview is removed when its track ends or is no longer available.
- Start a synthetic screen share and confirm the viewer displays the track identified as ScreenShare.
- Stop sharing using the browser or device UI and record which LiveKit event the viewer receives.
- Confirm the application detaches the media element and clears any preview or annotation layer tied to that track.
- Repeat by unsubscribing the viewer, ending the publisher session and forcing a test reconnect.
- Verify that the interface shows a clear stopped or reconnecting state and does not retain a frozen frame as though it were live.
A stopped track must not leave a fake live preview
Synthetic QA log; event names are illustrative and should be confirmed for the SDK version in use.
Scroll the table to see all columns.
| Action | Observed event | Expected UI | Decision |
|---|---|---|---|
| Viewer subscribes | TrackSubscribed; source ScreenShare | Show live preview | Pass |
| Publisher stops sharing | TrackUnpublished | Detach element; show 'sharing stopped' | Pass |
| Viewer unsubscribes | TrackUnsubscribed | Remove preview locally | Frozen frame remains; fail |
| Publisher leaves room | ParticipantDisconnected / left | Clear preview and owner label | Pass |
If the viewer keeps the last frame after TrackUnsubscribed, it is stale content. Detach the media element and clear overlays for that track before showing a stopped state.
What to hand over
A screen-share lifecycle test log linking each LiveKit event to the expected preview state and cleanup action.
Limitation. Event names and behavior differ by SDK and version; test the deployed client version and do not infer that a blank or frozen view proves the publisher stopped sharing.
Next step
Bring the SDK and client versions, a consent flow diagram and a test room. Review the expected stop and reconnect states before live use.