fluidd-core / fluidd

Fluidd, the klipper UI.
https://docs.fluidd.xyz
GNU General Public License v3.0
1.35k stars 410 forks source link

go2rtc/webrtc only ios/safari keeps disconencting #1258

Closed vajonam closed 8 months ago

vajonam commented 8 months ago

Fluidd Version

devlop

Browser

Safari

Device

Mobile device (Phone, Tablet or similar)

Operating System

iOS

What happened

the webrtc stream freezes periodically only on ios. iOS Safari V17

What did you expect to happen

no freeze :-)

How to reproduce

open up a stream on ios and just wait.

Additional information

Adding this to WebrtcGo2RtcCamera seems to fix the problem. For reference the .js code from https://github.com/AlexxIT/go2rtc/blob/master/www/video-rtc.js also does something similar and behaves in this way, when load up the stream.html in safari/chrome browser on iOS. Its not really dependent on browser on iOS as underlying webkit is the same.

...
   this.ws.onmessage = this.onWebSocketMessage
    this.ws.onclose = this.onWebSocketClose
    this.pc.onconnectionstatechange = this.pcStateChange
  }

  // TODO: do we need this iOS keeps disconnecting? 
  pcStateChange(ev: Event) {

    consola.debug('[WebrtcGo2RtcCamera] pcstate changes', ev)
    const peerConnection = ev.target as RTCPeerConnection;
    if (peerConnection && peerConnection.connectionState === "disconnected") {
      // Do something when connection is disconnected
      this.startPlayback();
    }
  }
...
vajonam commented 8 months ago

will manage this in the existing PR #1257