daily-co / daily-react

React hooks and components to get started with Daily
https://docs.daily.co/reference/daily-react
BSD 2-Clause "Simplified" License
53 stars 16 forks source link

BUG - isRecording value is not correct after leaving the room and joining again #13

Closed ssimonitch closed 1 year ago

ssimonitch commented 1 year ago

Expected behavior

I'm experiencing an issue similar to what I saw here: https://github.com/daily-co/daily-react/issues/9

This time the issue is with the isRecording value returned by the useRecording hook. I expect the isRecording value to accurately reflect whether or not there is a recording in progress for the current room.

Describe the bug (unexpected behavior)

When a user joins a room and starts a recording, the isRecording value is true. If that user then stops the recording and leaves the room, the isRecording value remains true. If the user rejoins the room, the isRecording value is still true even though there is no recording in progress.

During the above process, if there is another user in the room the isRecording value changes from true to false as expected.

Steps to reproduce

I have a modified version of our last code sandbox here: https://codesandbox.io/s/angry-driscoll-h0ouu6?file=/src/SessionIDDisplay.js

To reproduce:

  1. Open code sandbox in 2 separate windows
  2. In both windows, join the call
  3. In window A, click "start recording"
  4. After delay note that "is recording" is showing true for both users
  5. In window A, click "leave call"
  6. Note that "is recording" is showing true in window A and false in window B
  7. In window A, click "join call"
  8. Note that "is recording" is still showing true in window A and false in window B
67ideas commented 1 year ago

@Regaddi It seems like the problem is that recording state is purely a local thing -- is there any sort of server-side recording status we can hook into? Or maybe monitor participants updates and change recording state to false when the recording participant is no longer in the list?

Regaddi commented 1 year ago

Thanks @ssimonitch for the bug report, and @67ideas for your input!

In fact the issue is already being tracked internally and we have a PR open to fix it. The issue here is that useRecording doesn't maintain its state from a central component. Instead we rely on at least 1 instance of useRecording to be present, in order to handle all necessary events emitted by daily-js.

I'll try my best to get this wrapped up this week. useRecording is not the only hook being affected by this type of issue: the same issue applies to useLiveStreaming as well.

Regaddi commented 1 year ago

This issue has been fixed with 0.7.2!