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

Bug fixes: robust release of media streams + memoization of audio/video constraints #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Tiberiu02
Copy link

@Tiberiu02 Tiberiu02 commented Mar 4, 2024

First, due to the getMediaStream function being asynchronous, streams might not be released properly by the cleanup function of the main useEffect. This leads to media streams that keep running even after the ReactMediaRecorder is unmounted, causing performance and privacy issues. The new architecture ensures that there is only one media stream running at every time and stops it when the component unmounts.

Second, the video and audio media constraints are passed to the useEffect depedency list as objects, but the React dependency list compares objects by reference, not value. If the video and audio media constaints objects are created inside the same component that is calling the hook, their reference will be different every time. This would cause the useEffect to be called on every render, resulting in infinite re-renderings. This PR also fixes that by memoizing the video and audio constaints objects.

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