add timeout to datastream clear_buffer to avoid deadlock when missing playback finished event - #3917
Conversation
… playback finished event
| timeout, _on_timeout | ||
| ) | ||
|
|
||
| def _handle_playback_finished(self, data: rtc.RpcInvocationData) -> str: |
There was a problem hiding this comment.
QQ: Could there be a race condition here? If this function gets called after await self._room.local_participant.perform_rpc completes but before self._clear_buffer_timeout_handler = asyncio.get_event_loop().call_later( executes, would that trigger multiple on_playback_finished callbacks?
There was a problem hiding this comment.
nice catch! it could be if the playback finished received before clear buffer rpc done... will add a check in the timeout callback.
There was a problem hiding this comment.
checked the code, there is a check in on_playback_finished to ignore the redundant events, and ideally this shouldn't happen if avatar service handles the clear_buffer RPC before sending the playback finished event.
| timeout, _on_timeout | ||
| ) | ||
|
|
||
| def _handle_playback_finished(self, data: rtc.RpcInvocationData) -> str: |
when playback finished event is not received from the avatar service, the agent may hang forever to wait for the event. this usually happens during interruption due to some race conditions in the avatar service or network issues.
fix #3237 and #3434