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: use worker to prevent timer throttling #1557

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

myandrienko
Copy link
Contributor

@myandrienko myandrienko commented Nov 5, 2024

Browsers start throttling timers (intervals, timeouts) in background tabs after a period of inactivity. We use timers to send health checks, and missing health checks cause participant to be disconnected.

An active WebRTC connection on a page usually means the page is never considered inactive by the browser, and therefore timers are not throttled. But it's still possible to be in a call and not have an active connection, e.g. if nobody is publishing neither audio nor video.

To handle situations like this, we move timers to a web worker, which are never throttled. Web worker then posts messages to the page on the specified intervals.

Web workers might not be available (banned by CSP, running on Node, etc), so there's also a fallback mode that uses regular timers on the page side.

@myandrienko myandrienko marked this pull request as ready for review November 6, 2024 12:14
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.

1 participant