Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: synchronize background filter canvas capturing #1334

Merged
merged 1 commit into from
May 2, 2024
Merged

Conversation

oliverlaz
Copy link
Member

Overview

Fixes a race condition in canvas.captureStream() and resolveFilter().

We were resolving the filter too early and discarding the <canvas> element too aggressively whenever the track dimensions changed (key prop). Upon discarding, the already captured stream was muted and hence, streaming nothing.

Now, these races are fixed by properly synchronizing the order of operations:

  1. Obtain the original video stream
  2. Render the stream inside a video element
  3. Take the correct stream dimensions once playback starts
  4. Render the element with correct size
  5. Resolve the filter promise and let the SDK publish the filtered video stream

@oliverlaz oliverlaz merged commit eaead81 into main May 2, 2024
14 checks passed
@oliverlaz oliverlaz deleted the bg-filter-race branch May 2, 2024 12:02
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.

None yet

2 participants