-
Notifications
You must be signed in to change notification settings - Fork 83
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
roomOptions
changes are not applied to room
#730
Comments
Could you elaborate a bit on what you'd expect to happen in that case (a reconnect?) and what the use case is for changing options mid-session? |
Sure. Before that change(PR), with each change in room options, a new room with the same The benefit of using this(remote configs) is when there are many users using the app or there is a disruption in the Internet network, you can make changes in room options (for example in |
That makes sense. The reason why we did make that change was that we cannot stringify the options object anymore, as the end-to-end encryption options are too complex for that. cc @Ocupe for thoughts on this |
Thanks for clarifying that. In React.useEffect(() => {
setRoom(passedRoom ?? new Room(options));
}, [passedRoom, useDeepCompare(options)]); Definition of type Value = Readonly<unknown>;
export const useDeepCompare = (value: Value): number => {
const valueRef = React.useRef(value);
const signalRef = React.useRef<number>(0);
//* A function like lodash.isEqual or any custom or third party DeepCompare function.
if (!isEqual(value, valueRef.current)) {
valueRef.current = value;
signalRef.current += 1;
}
//* return deps signal for `useEffect`
return signalRef.current;
}; In this solution, whenever a re-render happens, it deep compares the last options and the new options, and if they are not the same, it increments the |
thanks for the suggestion. I'd like to avoid deep comparing whenever possible as it will run every render cycle of react and that adds up quickly in performance impact. |
Yeah you're right. So It seems there is no other way than putting |
Select which package(s) are affected
@livekit/components-react
Describe the bug
In a running meet, if we want to make changes in the room options at the moment (such as changing the codec or changing the audio and video bitrate by using remote configs), those changes will not be applied. I searched through previous PRs and found that the following change in the useEffect dependencies in the
useLiveKitRoom
hook caused this to happen:The PR link
Describe the proposed solution
I think reverting this change can fix the problem.
Reproduction
Consider this code:
If
meetOptions
changes due to a server update (or other methods of changing the options), the room will not change.Logs
No response
System Info
Severity
blocking an upgrade
Additional Information
No response
The text was updated successfully, but these errors were encountered: