livekit/client-sdk-react-native

Auto disconnect fails after screen lock/unlock

Opened this issue · 1 comments

Describe the bug

I am experiencing an issue when I lock the phone screen during an active live session and then unlock it to return to that session.

Steps to reproduce:

  • Open a live session as a viewer.
  • Lock the screen.
  • From another device as the host, close the session.
  • Unlock the screen.
  • At this point, the user should be disconnected automatically, but this does not happen despite the on.disconnect listener being implemented, which should trigger navigation.back.

I suspect that onDisconnect is not being called because the app is in a background at that point.
I am looking for any solution that would allow to identify the connection status after coming back to the app so I can take user from that screen.

useEffect(() => {
    const handleDisconnected = () => {
      router.back();
    };

    room.on('disconnected', handleDisconnected);

    return () => {
      room.off('disconnected', handleDisconnected);
    };
  }, [room, router]);

Screenshots

Device Info:

  • Device: iPhone 15 Pro
  • OS: 17.5.1

Dependencies Info (please reference your package-lock.json or yarn.lock file):

  • @livekit/react-native: 2.3.1
  • livekit-client: 2.0.10 (fetched by @livekit/react-native)
  • react-native-webrtc: 114.1.6

I would be really grateful for any help regarding this.