WebRTC icon indicating copy to clipboard operation
WebRTC copied to clipboard

Poor playback performance on iOS since 3.6.1

Open ktims opened this issue 4 months ago • 16 comments

Since upgrading to 3.6.1 I am experiencing extremely poor playback performance (0.5-1fps) on all the iOS devices I have access to (17 & 18), including in the HA Companion app and Safari. It continues to work perfectly in the Android companion and all the other web browsers I've tried (Linux & Android x Firefox & Chrome).

I am fairly sure that the streams are loading, since I see a playhead and buffer state (I guess that's what the playback progress reflects, anyway), and I do see a moving image, but playback performance is terrible. Reverting back to 3.6.0 and reloading the frontend solved the problem immediately.

I checked the server logs and client logs and didn't see anything related.

My camera is a Reolink E1 Pro, discovered in HA by the ONVIF addon.

My 'production' setup is more complicated but I was able to pare the configuration down to just the camera entity and it still reproduces for me:

type: custom:webrtc-camera
streams:
  - entity: camera.baby_monitor_profile000_mainstream

ktims avatar Aug 22 '25 06:08 ktims

You need to provide more debugging information. Stream info from go2rtc WebUI from the old and new integration versions.

AlexxIT avatar Aug 23 '25 08:08 AlexxIT

@ktims same for me. I added media: video and that drastically improved the stream. Seems maybe there's an audio encoding issue?

mnoah66 avatar Aug 23 '25 12:08 mnoah66

In order not to guess, it needs at least some understanding of what is happening. Stream info will already tell a lot.

AlexxIT avatar Aug 23 '25 13:08 AlexxIT

Reolink RLC-520A. Not using the Reolink integration. Just RTSP to the WebRTC card.

  "producers": [
    {
      "id": 25,
      "format_name": "rtsp",
      "protocol": "rtsp+tcp",
      "remote_addr": "192.168.1.56:554",
      "url": "rtsp://admin:[email protected]/Preview_01_main",
      "sdp": "v=0\r\no=- 3412964738030 1 IN IP4 192.168.1.56\r\ns=Session streamed by \"preview\"\r\nt=0 0\r\na=tool:BC Streaming Media v202210012022.10.01\r\na=type:broadcast\r\na=control:*\r\na=range:npt=now-\r\na=x-qt-text-nam:Session streamed by \"preview\"\r\nm=video 0 RTP/AVP 96\r\nc=IN IP4 0.0.0.0\r\nb=AS:8192\r\na=rtpmap:96 H264/90000\r\na=fmtp:96 packetization-mode=1;profile-level-id=640032;sprop-parameter-sets=Z2QAMqzSAKADxoQAAA+kAAOqcBA=,aOqPLA==\r\na=recvonly\r\na=control:track1\r\nm=audio 0 RTP/AVP 97\r\nc=IN IP4 0.0.0.0\r\nb=AS:8192\r\na=rtpmap:97 MPEG4-GENERIC/16000\r\na=fmtp:97 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1408\r\na=recvonly\r\na=control:track2\r\n",
      "user_agent": "go2rtc/1.9.9",
      "medias": [
        "video, recvonly, H264",
        "audio, recvonly, MPEG4-GENERIC/16000"
      ],
      "receivers": [
        {
          "id": 27,
          "codec": {
            "codec_name": "h264",
            "codec_type": "video",
            "level": 50,
            "profile": "High"
          },
          "childs": [
            28
          ],
          "bytes": 73568537,
          "packets": 52950
        },
        {
          "id": 30,
          "codec": {
            "codec_name": "aac",
            "codec_type": "audio",
            "sample_rate": 16000
          },
          "childs": [
            31
          ],
          "bytes": 488657,
          "packets": 1815
        }
      ],
      "bytes_recv": 74716630
    }
  ],
  "consumers": [
    {
      "id": 24,
      "format_name": "mse/fmp4",
      "protocol": "ws",
      "remote_addr": "192.168.1.38:59094",
      "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 Edg/139.0.0.0",
      "medias": [
        "video, sendonly, H264",
        "audio, sendonly, MPEG4-GENERIC, PCMA, PCMU, L16, PCML, OPUS"
      ],
      "senders": [
        {
          "id": 28,
          "codec": {
            "codec_name": "h264",
            "codec_type": "video",
            "level": 50,
            "profile": "High"
          },
          "parent": 27,
          "bytes": 73568537,
          "packets": 52950
        },
        {
          "id": 31,
          "codec": {
            "codec_name": "aac",
            "codec_type": "audio",
            "sample_rate": 16000
          },
          "parent": 30,
          "bytes": 488657,
          "packets": 1815
        }
      ]
    }
  ]
}

mnoah66 avatar Aug 23 '25 13:08 mnoah66

@mnoah66 Do you have "poor performance" for this stream? I can see that you watching video from Windows Edge browser via MSE technology.

Possibly "poor performance" this is the adaptive speed for MSE video. Which wasn't there before. And which was actually added in the new version. It tries to keep about 1 second delay from real time. And if the network bandwidth is poor, the problems described above may indeed occur.

But earlier, without this logic, the stream simply hung, waiting for a new portion of media data.

AlexxIT avatar Aug 23 '25 14:08 AlexxIT

I’m sorry. Perhaps I need to access the go2rtc webGUI stream info when I have the stream active in the companion app on iOS. I will remove the media: video line from my card and re-upload the steam info here.

mnoah66 avatar Aug 23 '25 14:08 mnoah66

See updated stream info from the companion app on iOS. Jittery stream and similar to what OP said about .5/1.0 fps

{
  "producers": [
    {
      "id": 52,
      "format_name": "rtsp",
      "protocol": "rtsp+tcp",
      "remote_addr": "192.168.1.56:554",
      "url": "rtsp://admin:[email protected]/Preview_01_main",
      "sdp": "v=0\r\no=- 3412964738030 1 IN IP4 192.168.1.56\r\ns=Session streamed by \"preview\"\r\nt=0 0\r\na=tool:BC Streaming Media v202210012022.10.01\r\na=type:broadcast\r\na=control:*\r\na=range:npt=now-\r\na=x-qt-text-nam:Session streamed by \"preview\"\r\nm=video 0 RTP/AVP 96\r\nc=IN IP4 0.0.0.0\r\nb=AS:8192\r\na=rtpmap:96 H264/90000\r\na=fmtp:96 packetization-mode=1;profile-level-id=640032;sprop-parameter-sets=Z2QAMqzSAKADxoQAAA+kAAOqcBA=,aOqPLA==\r\na=recvonly\r\na=control:track1\r\nm=audio 0 RTP/AVP 97\r\nc=IN IP4 0.0.0.0\r\nb=AS:8192\r\na=rtpmap:97 MPEG4-GENERIC/16000\r\na=fmtp:97 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1408\r\na=recvonly\r\na=control:track2\r\n",
      "user_agent": "go2rtc/1.9.9",
      "medias": [
        "video, recvonly, H264",
        "audio, recvonly, MPEG4-GENERIC/16000"
      ],
      "receivers": [
        {
          "id": 54,
          "codec": {
            "codec_name": "h264",
            "codec_type": "video",
            "level": 50,
            "profile": "High"
          },
          "childs": [
            97
          ],
          "bytes": 26382387,
          "packets": 18966
        },
        {
          "id": 86,
          "codec": {
            "codec_name": "aac",
            "codec_type": "audio",
            "sample_rate": 16000
          },
          "childs": [
            99
          ],
          "bytes": 94038,
          "packets": 350
        }
      ],
      "bytes_recv": 26708889
    }
  ],
  "consumers": [
    {
      "id": 96,
      "format_name": "mse/fmp4",
      "protocol": "ws",
      "remote_addr": "[::1]:41766 forwarded 192.168.1.31",
      "user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Home Assistant/2025.7.2 (io.robbie.HomeAssistant; build:2025.1356; iOS 18.5.0) Mobile/HomeAssistant, like Safari",
      "medias": [
        "video, sendonly, H264, H265",
        "audio, sendonly, MPEG4-GENERIC"
      ],
      "senders": [
        {
          "id": 97,
          "codec": {
            "codec_name": "h264",
            "codec_type": "video",
            "level": 50,
            "profile": "High"
          },
          "parent": 54,
          "bytes": 14399720,
          "packets": 10351
        },
        {
          "id": 99,
          "codec": {
            "codec_name": "aac",
            "codec_type": "audio",
            "sample_rate": 16000
          },
          "parent": 86,
          "bytes": 94038,
          "packets": 350
        }
      ],
      "bytes_send": 14584894
    }
  ]
}

mnoah66 avatar Aug 23 '25 14:08 mnoah66

What about Windows? Do you have problems only on iOS inside companion app? What about default iOS browser?

AlexxIT avatar Aug 23 '25 14:08 AlexxIT

@AlexxIT just the HA companion app and safari on iOS. Windows devices seem to work fine

mnoah66 avatar Aug 23 '25 14:08 mnoah66

@AlexxIT

I also affect these problem on windows machine (in chrome browser) with MSE stream. (HEVC video ) with 3.6.0 are OK, but since 3.6.1 stream are constantly buffering.

vampywiz17 avatar Aug 28 '25 20:08 vampywiz17

I'm facing the same behavior with the HA Companion App 2025.8.10 on Android 15 phone, WebRTC 3.6.1 with MSE stream from RTSP Reolink RLC-823A. The stream delay/buffer happens even if I'm connected from LAN so I guess latency and bandwidth aren't involved at this stage. Streaming from a Linux and Windows PC with Firefox both LAN or WAN just works perfect. Reverting to version 3.6.0 fixes everything on the companion app.

sna696 avatar Sep 01 '25 14:09 sna696

I'm also facing the same behavior, Confirming revert to 3.6.0 fixes the issue on all my iOS devices. Let me know if you need more info to debug/solve it, thank you!!

ofirsnb avatar Sep 30 '25 09:09 ofirsnb

Today i test it to send stream (MSE) to chromecast ultra. 3.6.1 also stop stream about 5 sec after start. (when mentioned before, i affect these on PC also)

If i switch back 3.6.0, on PC and chromecast ultra, de MSE stream work well!

I think also important info that these broblem not depends on go2rtc version.

vampywiz17 avatar Oct 09 '25 23:10 vampywiz17

I had submitted #891 and got redirected here (its indeed the same issue). I would like to report a few more details:

The problem occurs with my reolink doorbell camera which is connected via ethernet. So its certainly not a problem cause by missing bandwith or larger lag. The problem does not happen on my linux laptop. But it happens on my android devices (using chrome and the Home Assistant app) and on my NestHub device.

The camera has two stream modes: normal and high quality. Interestringly, the high quality stream plays fluently without any issues. The lower quality however, permanently stutters. The stuttering happens very frequently. Like 1-2 times per second. I can see that it is permanently, in a very minimal way, running out of buffer. The higher quality stream however, has always a minimal buffer available and thus plays smoothly. Below two videos which show the remaining buffer at hand of the video progress bar.

High quality (smooth): https://github.com/user-attachments/assets/2972a88d-af53-4d3d-87ae-8aab23f69ff9 Low quality (stutters): https://github.com/user-attachments/assets/81e7e454-6a8f-4155-91d9-00f4ff7e5749

Below the stream infos of both streams:

High quality:

{
  "producers": [
    {
      "id": 369,
      "format_name": "rtsp",
      "protocol": "rtsp+tcp",
      "remote_addr": "192.168.2.55:554",
      "url": "rtsp://admin:[email protected]:554/h264Preview_01_main",
      "sdp": "v=0\r\no=- 1759622459640163 1 IN IP4 192.168.2.55\r\ns=Session streamed by \"preview\"\r\ni=reolink rtsp stream\r\nt=0 0\r\na=tool:Reolink Streaming Media 2024.12.11\r\na=type:broadcast\r\na=control:*\r\na=range:npt=now-\r\na=x-qt-text-nam:Session streamed by \"preview\"\r\nm=video 0 RTP/AVP 96\r\nc=IN IP4 0.0.0.0\r\nb=AS:8192\r\na=rtpmap:96 H264/90000\r\na=fmtp:96 packetization-mode=1;profile-level-id=640033;sprop-parameter-sets=Z2QAM6wVFKAoAPGQ,aO48sA==\r\na=recvonly\r\na=control:track1\r\nm=audio 0 RTP/AVP 97\r\nc=IN IP4 0.0.0.0\r\nb=AS:8192\r\na=rtpmap:97 MPEG4-GENERIC/16000\r\na=fmtp:97 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1408\r\na=recvonly\r\na=control:track2\r\nm=audio 0 RTP/AVP 0\r\na=control:track3\r\na=rtpmap:0 PCMU/8000\r\na=sendonly",
      "user_agent": "go2rtc/1.9.9",
      "medias": [
        "video, recvonly, H264",
        "audio, recvonly, MPEG4-GENERIC/16000",
        "audio, sendonly, PCMU/8000"
      ],
      "receivers": [
        {
          "id": 371,
          "codec": {
            "codec_name": "h264",
            "codec_type": "video",
            "level": 51,
            "profile": "High"
          },
          "childs": [
            373
          ],
          "bytes": 5227236,
          "packets": 3700
        },
        {
          "id": 374,
          "codec": {
            "codec_name": "aac",
            "codec_type": "audio",
            "sample_rate": 16000
          },
          "childs": [
            375
          ],
          "bytes": 39462,
          "packets": 156
        }
      ],
      "bytes_recv": 5313258
    }
  ],
  "consumers": [
    {
      "id": 368,
      "format_name": "mse/fmp4",
      "protocol": "ws",
      "remote_addr": "[::1]:48622 forwarded 192.168.2.59",
      "user_agent": "Mozilla/5.0 (Linux; Android 15; SM-S901B Build/AP3A.240905.015.A2; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/141.0.7390.43 Mobile Safari/537.36 Home Assistant/2025.8.7-17352 (Android 15; SM-S901B)",
      "medias": [
        "video, sendonly, H264, H265",
        "audio, sendonly, MPEG4-GENERIC, PCMA, PCMU, L16, PCML"
      ],
      "senders": [
        {
          "id": 373,
          "codec": {
            "codec_name": "h264",
            "codec_type": "video",
            "level": 51,
            "profile": "High"
          },
          "parent": 371,
          "bytes": 5227236,
          "packets": 3700
        },
        {
          "id": 375,
          "codec": {
            "codec_name": "aac",
            "codec_type": "audio",
            "sample_rate": 16000
          },
          "parent": 374,
          "bytes": 39462,
          "packets": 156
        }
      ],
      "bytes_send": 5281119
    }
  ]
}

Low quality:

{
  "producers": [
    {
      "id": 378,
      "format_name": "rtsp",
      "protocol": "rtsp+tcp",
      "remote_addr": "192.168.2.55:554",
      "url": "rtsp://admin:[email protected]:554/h264Preview_01_sub",
      "sdp": "v=0\r\no=- 1759622459754936 1 IN IP4 192.168.2.55\r\ns=Session streamed by \"preview\"\r\ni=reolink rtsp stream\r\nt=0 0\r\na=tool:Reolink Streaming Media 2024.12.11\r\na=type:broadcast\r\na=control:*\r\na=range:npt=now-\r\na=x-qt-text-nam:Session streamed by \"preview\"\r\nm=video 0 RTP/AVP 96\r\nc=IN IP4 0.0.0.0\r\nb=AS:8192\r\na=rtpmap:96 H264/90000\r\na=fmtp:96 packetization-mode=1;profile-level-id=640033;sprop-parameter-sets=Z2QAM6wVFKCgPZA=,aO48sA==\r\na=recvonly\r\na=control:track1\r\nm=audio 0 RTP/AVP 97\r\nc=IN IP4 0.0.0.0\r\nb=AS:8192\r\na=rtpmap:97 MPEG4-GENERIC/16000\r\na=fmtp:97 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1408\r\na=recvonly\r\na=control:track2\r\nm=audio 0 RTP/AVP 0\r\na=control:track3\r\na=rtpmap:0 PCMU/8000\r\na=sendonly",
      "user_agent": "go2rtc/1.9.9",
      "medias": [
        "video, recvonly, H264",
        "audio, recvonly, MPEG4-GENERIC/16000",
        "audio, sendonly, PCMU/8000"
      ],
      "receivers": [
        {
          "id": 380,
          "codec": {
            "codec_name": "h264",
            "codec_type": "video",
            "level": 51,
            "profile": "High"
          },
          "childs": [
            382
          ],
          "bytes": 388664,
          "packets": 320
        },
        {
          "id": 383,
          "codec": {
            "codec_name": "aac",
            "codec_type": "audio",
            "sample_rate": 16000
          },
          "childs": [
            384
          ],
          "bytes": 23525,
          "packets": 93
        }
      ],
      "bytes_recv": 417385
    }
  ],
  "consumers": [
    {
      "id": 377,
      "format_name": "mse/fmp4",
      "protocol": "ws",
      "remote_addr": "[::1]:40768 forwarded 192.168.2.59",
      "user_agent": "Mozilla/5.0 (Linux; Android 15; SM-S901B Build/AP3A.240905.015.A2; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/141.0.7390.43 Mobile Safari/537.36 Home Assistant/2025.8.7-17352 (Android 15; SM-S901B)",
      "medias": [
        "video, sendonly, H264, H265",
        "audio, sendonly, MPEG4-GENERIC, PCMA, PCMU, L16, PCML"
      ],
      "senders": [
        {
          "id": 382,
          "codec": {
            "codec_name": "h264",
            "codec_type": "video",
            "level": 51,
            "profile": "High"
          },
          "parent": 380,
          "bytes": 388664,
          "packets": 320
        },
        {
          "id": 384,
          "codec": {
            "codec_name": "aac",
            "codec_type": "audio",
            "sample_rate": 16000
          },
          "parent": 383,
          "bytes": 23525,
          "packets": 93
        }
      ],
      "bytes_send": 429316
    }
  ]
}

Lamarqe avatar Oct 11 '25 18:10 Lamarqe

@Lamarqe You're using MSE technology, which means the problem is similar. Until this is fixed, you can use the old version of the integration.

AlexxIT avatar Oct 12 '25 11:10 AlexxIT

Yes, I am aware. I just try to provide more information (not sure if you already know what the root cause of the problem is).

One more information: Reolink cameras support rtmp and rtsp protocol. There is no difference here for both protocols: high quality is flluent, low quality stutters.

Lamarqe avatar Oct 12 '25 11:10 Lamarqe