aws / amazon-chime-sdk-component-library-react

Amazon Chime React Component Library with integrations with the Amazon Chime SDK.
Apache License 2.0
264 stars 159 forks source link

Camera Activation Timing Issue in VideoInputTransformControl Component #910

Open YehorChulkov opened 10 months ago

YehorChulkov commented 10 months ago

What are you trying to do? I'm working on integrating the Amazon Chime SDK React Component Library into our platform for video conferencing features. Specifically, I'm using the VideoInputTransformControl component to manage the local user's video input.

How can the documentation be improved to help your use case? The documentation could benefit from a section explaining how to handle timing issues related to enabling the camera, particularly when using the toggleVideo() function within useEffect. In my experience, calling toggleVideo() too soon after loading the component results in a blank video feed for the last connected user (the last connected user can see their own video stream while other users see a black screen). The issue occurs only using a real web camera, a virtual camera like OBS Virtual Cam doesn't cause such an effect.

For now, I have implemented a temporary workaround using setTimeout to delay the call to toggleVideo(). While this works, relying on a timer is not robust and could lead to issues with different hardware or network conditions.

Here's a snippet of my current workaround: useEffect(() => { let interval: NodeJS.Timeout | undefined; if (!isVideoEnabled) { interval = setTimeout(() => { toggleVideo(); }, 1000); } return () => { if (interval) { clearInterval(interval); } }; }, [isVideoEnabled]); What documentation have you looked at so far? README.md Amazon Chime SDK React Component Library Developer Guide Amazon Chime SDK JavaScript API Reference

gabriel-brito commented 1 week ago

Your snippet helped me a lot. Thanks.