Skip to content

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.

  1. Start a synthetic screen share and confirm the viewer displays the track identified as ScreenShare.
  2. Stop sharing using the browser or device UI and record which LiveKit event the viewer receives.
  3. Confirm the application detaches the media element and clears any preview or annotation layer tied to that track.
  4. Repeat by unsubscribing the viewer, ending the publisher session and forcing a test reconnect.
  5. 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.

Screen-share teardown checks
ActionObserved eventExpected UIDecision
Viewer subscribesTrackSubscribed; source ScreenShareShow live previewPass
Publisher stops sharingTrackUnpublishedDetach element; show 'sharing stopped'Pass
Viewer unsubscribesTrackUnsubscribedRemove preview locallyFrozen frame remains; fail
Publisher leaves roomParticipantDisconnected / leftClear preview and owner labelPass

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.

Discuss LiveKit on-screen assistance

Sources