UnityRenderStreaming icon indicating copy to clipboard operation
UnityRenderStreaming copied to clipboard

[BUG] Worse performance when using the Receiver scene compared to a web browser

Open ZeoWorks opened this issue 2 years ago • 14 comments

Hello again, It appears the stream is more intensive on the GPU when using the "receiver scene" as opposed to using a web browser (webserver video index). Furthermore, the stream doesn't stay at a consistent 60fps within the "receiver scene". It seems that streaming a video straight to Unity through webrtc has worse performance overall compared to the web browser. Latency is worse, it's more expensive on the GPU and you'll find micro stutters from time to time.

Thanks.

ZeoWorks avatar Oct 15 '21 11:10 ZeoWorks

@ZeoWorks Thanks for your feedback. This might be the same issue and the fix is already planned near future. https://github.com/Unity-Technologies/com.unity.webrtc/issues/205

karasusan avatar Oct 15 '21 13:10 karasusan

@karasusan Thanks, This actually occurs with software encoding as webRTC for windows standalone builds does not support hardware decoding.

ZeoWorks avatar Oct 15 '21 14:10 ZeoWorks

@karasusan More debugging done; There is an additional 50ms/90ms of latency when software decoding inside a Unity standalone/editor compared to software decoding within a web browser.

ZeoWorks avatar Oct 23 '21 01:10 ZeoWorks

@ZeoWorks Thanks for sharing details. We will focus to improve performance for the next WebRTC version.

I would like to know more detail.

  • Testing platform (Win/macOS)
  • Testing codecs (VP8 should be selected in default)

karasusan avatar Oct 23 '21 02:10 karasusan

Testing platform; Windows to Windows, Codec; VP8 (Also occurs with VP9), Latency in 'Receiver scene' VS web browser; -50/90ms (sometimes upwards of 100ms) -compared to 29ms in web browser FPS in 'Receiver scene' VS web browser; -35-48fps -compared to 60fps in web browser

ZeoWorks avatar Oct 23 '21 18:10 ZeoWorks

~~memo: URS-348~~ memo: WRS-165

karasusan avatar Nov 09 '21 02:11 karasusan

There is an additional 50ms/90ms of latency when software decoding inside a Unity standalone/editor compared to software decoding within a web browser.

I would add in general, compared to Moonlight, com.unity.webrtc has worse latency, closer to 40ms difference. Not 100% sure why. libwebrtc shouldn't be that bad to Chrome.

doctorpangloss avatar Nov 22 '21 05:11 doctorpangloss

@doctorpangloss

Looks like they implements libraries based on NVIDIA GameStream. https://github.com/moonlight-stream/moonlight-common-c

NVIDIA GameStream https://www.nvidia.com/en-us/shield/support/shield-tv/gamestream/

karasusan avatar Nov 24 '21 02:11 karasusan

Same principle as using the nvidia SDK actually. The main reason is that the SDK is not in "high performance low latency" mode.

But yes, the latency of software decoding inside Unity (standalone) is much higher than in web browser regardless.

ZeoWorks avatar Nov 24 '21 02:11 ZeoWorks

@ZeoWorks @doctorpangloss I had experiment to check the latency as you said and reproduced your issue.

Unity Editor : 2020.3.23f1 on Windows Google Chrome: M96 Video Codec: VP8

  • Win Unity Editor -> Chrome M96: 83ms
  • Win Unity Editor -> Win Runtime: 149ms

It is clear that the video receiver implementation has problem of latency. First I will add statistics viewer like webrtc-internal to measure the latency more detail.

karasusan avatar Nov 25 '21 08:11 karasusan

@ZeoWorks @doctorpangloss I had experiment to check the latency as you said and reproduced your issue.

Unity Editor : 2020.3.23f1 on Windows Google Chrome: M96 Video Codec: VP8

  • Win Unity Editor -> Chrome M96: 83ms
  • Win Unity Editor -> Win Runtime: 149ms

It is clear that the video receiver implementation has problem of latency. First I will add statistics viewer like webrtc-internal to measure the latency more detail.

Thank you for the update in regards to the situation. :) Best of luck sir, happy to help any way I can.

ZeoWorks avatar Nov 27 '21 23:11 ZeoWorks

I made the tool to measure latency between sender and receiver. https://github.com/Unity-Technologies/com.unity.webrtc/pull/586

We need to concern that the condition affecting results are FPS and video resolution.

karasusan avatar Jan 14 '22 02:01 karasusan

@ZeoWorks I measured latency using this tool, there was no problem. We will check the stats to measure performance for encoder/decoder.

karasusan avatar Jan 18 '22 02:01 karasusan

memo: WRS-205

karasusan avatar Jan 18 '22 06:01 karasusan