moonlight-stream / moonlight-android

GameStream client for Android
GNU General Public License v3.0
3.23k stars 512 forks source link

[Issue]: 30 ms decoding latency on Mediatek Dimensity 9000 #1241

Open ktm-91 opened 9 months ago

ktm-91 commented 9 months ago

Describe the bug

On my OnePlus Nord 3 5G (Mediatek Dimensity 9000 high-end SoC) I get around 30 ms of decoding latency with both H.264 and H.265. It's a lot, considering that on my Sony Android TV (also with a Mediatek SoC) I get around 3 ms. I already tried changing resolution, FPS and bitrate but it won't get better latencies.

Steps to reproduce

none

Affected games

any

Other Moonlight clients

PC

Moonlight adjusted settings

Yes

Moonlight adjusted settings (please complete the following information)

tried many combinations of resolution, FPS and bitrate

Moonlight default settings

Yes

Gamepad-related connection issue

Yes

Gamepad-related input issue

Yes

Gamepad-related streaming issue

Yes

Android version

13

Device model

OnePlus Nord 3 5G

Server PC OS version

Windows 10 22H2

Server PC GeForce Experience version

3.27.0.112

Server PC Nvidia GPU driver version

537.13

Server PC antivirus and firewall software

Windows Defender

Screenshots

Screenshot_2023-08-24-11-57-49-31_0ff5f4589442642967c97622a25eb61e

Relevant log output

No response

Additional context

No response

cgutman commented 9 months ago

I'd like to get some codec information to see if there's a way to reduce the latency.

  1. Please install https://play.google.com/store/apps/details?id=com.parseus.codecinfo
  2. Open Codec Info app and navigate to the Video tab
  3. Find "c2.mtk.hevc.decoder" in the list and take screenshots of the properties page for that codec
  4. Find "c2.mtk.avc.decoder" in the list and take screenshots of the properties page for that codec
  5. Attach the screenshots here.
ktm-91 commented 9 months ago

Sure, here they are:

AVC HEVC

dels95 commented 9 months ago

hey, i have same issue with my oneplus pad, when i use wifi im between 25-35ms but when i plug rj45 im between 13-20ms Screenshot_2023-08-25-23-32-33-82_0ff5f4589442642967c97622a25eb61e Screenshot_2023-08-25-23-31-25-14_0ff5f4589442642967c97622a25eb61e

cgutman commented 9 months ago

The only MediaFormat option I see that Steam Link sets and we don't is KEY_PRIORITY. I never saw any advantage for setting it on any of my non-MediaTek devices, but maybe it helps for your MediaTek devices.

Here is a test build you can try: https://drive.google.com/file/d/1BjsjTvQ-UZEznufincc2FTfph7FUQIQx/view?usp=sharing

ktm-91 commented 9 months ago

Unfortunately it doesn't get better. FYI I also tried Steam Link and I get the same 30 ms decoding delay. I can't believe that such a high end SoC can't do better than this :(

ktm-91 commented 9 months ago

Noob question: would it be possible to use the OMX.MTK.VIDEO.DECODER.HEVC decoder instead, as my TV does? Apparently it has way better latency performance

svishchev commented 9 months ago

Here is a test build you can try: https://drive.google.com/file/d/1BjsjTvQ-UZEznufincc2FTfph7FUQIQx/view?usp=sharing

Didn't work on my Infinix Note 12 2023 with Mediatek G99. Is it possible to see how this is implemented in Parces? There's a decoding delay of about 6-8ms on my device.

cgutman commented 9 months ago

@svishchev if you can collect adb logcat logs of Parsec and Moonlight streaming on your device, I could take a look at them and see if anything looks different between the two logs.

AceZero925 commented 8 months ago

I have the same issue as well with my phone xiaomi 11T non pro version using Dimensity 1200. Getting the same decoding latency of 15-20ms as well on Moonlight. If i use Parsec the decoding latency is much faster at around 5ms.

AceZero925 commented 8 months ago

@cgutman

This is my logcat file by using Parsec v3.150.085.00 and Moonlight v11.0 on Android 13 with my Xiaomi 11T running mediatek dimensity 1200 Hope it helps.

Logcat.zip

cgutman commented 8 months ago

Thanks, here's another build to try: https://drive.google.com/file/d/1f7YJpgtchqRuYwdhN2fFkwPeUiZaQlGM/view?usp=sharing

I tweaked a few things to be closer to what Parsec does.

Since Sunshine is variable frame rate, please also try moving the mouse around to get 60 FPS from the host and see if latency goes down.

AceZero925 commented 7 months ago

@cgutman Just tried with no luck at all, the result are still the same with both H.254 and HEVC. one more things i notice is that i can't choose AV1 as decoder it says AV1 decoder not found but my soc supports it. HVEC H 264

joemossjr16 commented 7 months ago

I am inface having the same issue with my oneplus pad. around 30ms decode time no matter what option i choose.

ZachShaw commented 7 months ago

Same with my Firestick 4K Max, anything between 20-30ms decoding latency regardless of bitrate, resolution, fps etc.

Getting 0-1ms on my Rog Ally so I know it's not anything Sunshine related.

bsdayo commented 6 months ago

My Redmi Pad (MediaTek G99) also encountered the same problem, the decoding latency fluctuated between 20ms-40ms, regardless of using HEVC or H.264.

peacepenguin commented 6 months ago

@ZachShaw Are you using the new 2023 Firestick 4K max? or the older one from 2021?

On my older 2021 Firestick 4k max, things work perfectly, 4-5ms decode time for HEVC.

Also for reference, the older stick is running fire os 7 (android 9), the newer one is fire os 8 (android 11).

The older one uses: OMX.MTK.VIDEO.DECODER.HEVC

It appears the new one uses: C2.MTK.HEVC.DECODER

I see in the logcat of the dimensity: "no c2 equivalents for vdec-lowlatency"

So might be that the 'magic' mediatek specific 'vdec-lowlatency' flag can no longer be used with the C2 decoder.

Android 11 introduced a 'standard' approach to signaling low latency video: MediaCodecInfo.CodecCapabilities.FEATURE_LowLatency

Perhaps mediatek or amazon in the case of the fire stick 4k max 2023, didn't implement the new feature, so now were stuck on these newer android versions until they fix the driver? Or maybe we can find another way to use the older OMX.MTK decoder on the newer android OS so we can continue to pass the old magic flag: vdec-lowlatency.

https://source.android.com/docs/core/media/low-latency-media

NoiSy-MaN commented 6 months ago

This shouldn't be happening, but I found out that wifi 6 goes around the issue, in my case at least.

With my wifi 5 router and 360mbps ftth, my Mi Mix 2 from 2017 with Snapdragon 835 was smooth sailing, while my current Xiaomi 13T with Dimensity 8200 Ultra was having connection issues.

I went to my gf's house with a 50mbps vdsl connection and lo and behold, no issues. The difference? Her router is wifi 6.

After that I bought a wifi 6 mesh system and even though the decoding latency is higher than the Snapdragon, I get no connection issues and it's super smooth.

AceZero925 commented 6 months ago

FYI, My Xiao Mi 11T non pro has AV1 decoder functions but on the newest version of moonlight 12.0.2 it shows that there are no AV1 decoder.

donlonW commented 6 months ago

So there is no solution yet? Just bought a cheap tablet that use Mediatek chip and want to use it strictly for streaming. And now I am doubting my life choice lul.

tristan-k commented 5 months ago

My Redmi Pad (MediaTek G99) also encountered the same problem, the decoding latency fluctuated between 20ms-40ms, regardless of using HEVC or H.264.

I'm considering buying a newly released Samsung Tab A9 (G99) for Moonlight but @bsdayo comments makes me hesitate.

donlonW commented 5 months ago

@tristan-k For 8inch-ish tablet, just go for a Lenvo Y700 (S870/ 8+1) instead ig. And here is an unlucky Galaxy Tab A9 user lul. I should do more research before pulling the trigger.

tristan-k commented 5 months ago

@donlonW For some reason the Lenvo Y700 isn't available in Germany and it's much more expensive. So my everlasting quest for a 8-9 Inch Tablet for moonlight streaming continues :(

donlonW commented 5 months ago

@tristan-k It still work OK in third-person game with the 20-30ms decoding latency if you have low internet latency(stably under 10ms). But can't really play any serious 2D platformer until this issue is solved.

The folks on Github are discussing and trying to solve the issue. https://github.com/moonlight-stream/moonlight-android/issues/1276

bassderek commented 5 months ago

Also experiencing high decode latency on mediatek D1200 (AYANEO Pocket Air/Android 12), around 20ms (h264, h265, and AV1 are all similar results). Happy to help test or provide any data related.

peacepenguin commented 5 months ago

@bassderek can you run parsec from and to the same devices and see what parsec reports for decode latency? with HEVC particularly?

bassderek commented 5 months ago

@peacepenguin I unfortunately don’t have access to the device anymore, but when I tested with parsec it was about 5ms. Overall worse stream quality than moonlight though other than latency being better.

auron2k commented 4 months ago

Just got a Helio G99 Android 13 tablet - I believe as per previous posters have also reported, I get approx 25ms decoding time shown in Moonlight for both H265 and H264. Parsec reports between 2 and 3ms. It's the C2.MTK.HEVC.DECODER (or C2.MTK.AVC.DECODER) in use on Moonlight.

Happy to try and help with any further information where I can.

Chrysostom83 commented 3 months ago

I have the same issue on my Iplay 50 mini pro, running the mediatek helios G99 cpu - around 35ms average decoding time, with much much less when using Parsec. Can also provide information or tests if you want.

ffffyyc commented 3 months ago

Same problem with mtk d1100. Hoping it will be fixed soon.

timharry commented 2 months ago

I have the same problem with MediaTek Kampanio 1300T in my Lenovo Tab P11 pro gen 2. Looks like it is also using the c2.mtk.hevc.decoder.

These are the latency times I tend to get:

1080p60fps - 16-20ms average decode time 1440p60fps - 30-32ms average decode time

I tested out 1080p60fps on Parsec on this device, and I was seeing around ~5ms on both AVC and HEVC decoders.

bassderek commented 2 months ago

So I actually bought another of the device I had before so I have a D1200 device again. Interestingly when I tested this a few days ago I am now getting ~11ms decode time when the device is in the "high performance" mode. Which is an improvement over the 20ms from before. I am not sure if this is due to an update in sunshine or moonlight, or something to do with a software update on the device.

This is pretty much the same across h264/h265/av1

Chriso132 commented 2 months ago

So I actually bought another of the device I had before so I have a D1200 device again. Interestingly when I tested this a few days ago I am now getting ~11ms decode time when the device is in the "high performance" mode. Which is an improvement over the 20ms from before. I am not sure if this is due to an update in sunshine or moonlight, or something to do with a software update on the device.

This is pretty much the same across h264/h265/av1

Is this running decent for you still ? Just bought a Helio g99 powered tablet for streaming and started having second thought when I seen this !

bassderek commented 2 months ago

So I actually bought another of the device I had before so I have a D1200 device again. Interestingly when I tested this a few days ago I am now getting ~11ms decode time when the device is in the "high performance" mode. Which is an improvement over the 20ms from before. I am not sure if this is due to an update in sunshine or moonlight, or something to do with a software update on the device. This is pretty much the same across h264/h265/av1

Is this running decent for you still ? Just bought a Helio g99 powered tablet for streaming and started having second thought when I seen this !

Yes, but I don't know if that's going to mean all mtk devices will fare the same.

Chriso132 commented 2 months ago

So I actually bought another of the device I had before so I have a D1200 device again. Interestingly when I tested this a few days ago I am now getting ~11ms decode time when the device is in the "high performance" mode. Which is an improvement over the 20ms from before. I am not sure if this is due to an update in sunshine or moonlight, or something to do with a software update on the device. This is pretty much the same across h264/h265/av1

Is this running decent for you still ? Just bought a Helio g99 powered tablet for streaming and started having second thought when I seen this !

Yes, but I don't know if that's going to mean all mtk devices will fare the same.

Yeah of course, my fingers are crossed. I’ve seen some reviews of the tablet I’m buying and one of the guys had the moonlight stats up and it was around 19-20ms. It does have a performance mode but not sure if that was activated. Im not sure if I’ll notice that latency anyway, otherwise I’ll use steamlink and hope that might achieve better results.

Chriso132 commented 2 months ago

@peacepenguin Hi mate. Just wondering if any fixes have been found yet for the low latency mode on the c2 codec ? My tablet is being delivered soon and the latency is already annoying me ! I’m not even sure how noticeable 20ms latency will be to me so may be worrying for nothing. Thank you :)

donlonW commented 2 months ago

@peacepenguin Hi mate. Just wondering if any fixes have been found yet for the low latency mode on the c2 codec ? My tablet is being delivered soon and the latency is already annoying me ! I’m not even sure how noticeable 20ms latency will be to me so may be worrying for nothing. Thank you :)

He moved on from this problem, the best way to solve it is staying away from any MediaTek SoC ig.

And 20ms decodeing latency with good internet latency is good enough for third-person casual 3d games, turn-based games. But not good enough for first-person shooters, 3d/2d platformers.

CapsizingShip commented 3 weeks ago

Writing this comment just hoping this persistent issue could be solved one day.

I recently bought iplay50 mini pro NFE with mediatek G99 solely for the purpose of moonlight streaming and found out this mediatek issue. But I realize that the latency is far higher than the 35ms as advertised when I compare side by side to my monitor and compare to the seamless streaming on my tab s9 and iphone 14 pro. 25ms difference in decoding latency equivalent to 1.5 frame delay in 60 fps shouldn't be so noticeable. There is no much differences between Parsec and Moonlight when comparing side by side, although Parsec advertised decoding time less than 4ms. There is something to do with the CPU in rendering streaming apps to tablet's screen rather than decoding, just like using high graphic usage apps on low end pc.

I have done some test below, caution that I am not a professional in doing these thing:

  1. tried to flash lineageOS 16 (android 9) and lineageOS 18 (android 11), hoping to force using OMX decoder instead of C2 decoder, but with no luck, both stucking in boot loop.
  2. lineageOS 19 and above are working perfectly for iplay50miniproNFE.
  3. overall smoothness when streaming is best on lineageOS 21 light (android 14), rooted, with no google play. I have also no idea why rooted with no google give a quite noticeable difference in smoothness. Using this OS also smoothen all other apps.
  4. using Kernel Adiutor to put the cpu in high performance mode, and overclock the cpu. There is no setting to put the cpu in high performance for iplay50 stock OS and lineageOS, root is needed. High performance mode significantly increase playability.

Now game streaming is very playable, although not as good as compare to tab s9 and iphone 14 pro, still having avg 20 to 22ms decoding latency when streaming horizon zero dawn in 1080p 60fps. It turned out that iplay50minipro stock OS is poorly designed for this cheap tablet, and the G99 CPU capability is not utilized at all.

next tested the total appearance latency by using the 60fps youtube clock under these setting, putting tablet next to monitor and capture ms differences using camera: https://www.youtube.com/watch?v=RJfAkfY2Ifo&t=1187s&ab_channel=CynicalCreator

moonlight on iplay50minipro : 66ms approximate 4 frames Parsec on iplay50minipro : 134ms approximate 8 frames both parsec and moonlight on tab s9 : lesser than 33ms approximate 1.5 to 2 frames

moonlight still better than parsec on iplay50minipro eventho decoding latency is lesser. There is obviously other causes driving the latency differences between iplay50minipro and tab s9.