Skip to content

fix: invalidate stale video renderer attachments and respect ownership - #1222

Draft
bdlukaa wants to merge 5 commits into
livekit:mainfrom
totem-technologies:fix/web-video-renderer-lifecycle
Draft

bdlukaa wants to merge 5 commits into
livekit:mainfrom
totem-technologies:fix/web-video-renderer-lifecycle

Conversation

@bdlukaa

@bdlukaa bdlukaa commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem

VideoTrackRenderer can finish renderer initialization or listener replacement after its track has changed or its widget has been disposed. A stale async attachment can then install a listener for the wrong track or update a rendererthat no longer belongs to that widget State.

Reproduction

Delay renderer initialization or disposal of the current track listener. While it is pending, replace the track (including A → B → C) or unmount the widget.
The previous attachment has no validity check after its await.

Fix

  • Invalidate in-flight attachments when the track, renderer, effective render mode, or widget lifecycle changes.
  • Keep initialization work out of repeated builds and attach only for the current generation.
  • Guard stream and resize callbacks against stale generations.
  • Detach cached renderers without disposing caller-owned instances; dispose widget-owned renderers according to autoDisposeRenderer.

@bdlukaa
bdlukaa marked this pull request as ready for review September 24, 2026 20:57
devin-ai-integration[bot]

This comment was marked as resolved.

This comment was marked as resolved.

@bdlukaa
bdlukaa marked this pull request as draft September 24, 2026 22:31

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Comment thread lib/src/widgets/video_track_renderer_native.dart
@bdlukaa

bdlukaa commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

This is not a breaking change as the tests say. The API is the same.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants