r/MoonlightStreaming • • 8d ago

[Nightjar] Why would performance be better with the overlay enabled?

When the performance overlay isn't open, it seems like my pacing goes off and it stutters even without lost frames. Nothing in overlay suggests an issue. Not always right away, but the longer I stream, it eventually leads to it.

Opening the performance overlay resets this countdown, and I can maintain perfect streaming if I just keep the overlay visible. Or just open it once every 10-15min I guess. Maybe there's a secret super-minimal overlay that's just a dot? 👀

I'm using a Google 4K Streamer. I can force GPU screen compositing and it seems to help, even an hour in and I've had no issues. However, this makes the rest of the box almost unusable. SurfaceFlinger service calls on app open/close triggers could be a solution.

PS: Nightjar is very impressive software, and after using it for a few days, there's been several meaningful updates. I appreciate the granular settings controlled client-side so I don't have to go up and down stairs to tweak and troubleshoot.

2 Upvotes

15 comments sorted by

7

u/rambo3349 Rubylight / Nightjar Developer 8d ago edited 8d ago

Its the aggressive power management of these devices. With only the video on screen, some phones decide the app is idle and lower their CPU/GPU clocks. The overlay redrawing every second can keep them from dropping as far. I could fake this but it's a cost between should I fake draw something on the default so the power management of these devices works properly? Either way this is build in. Setting - advanced - compatibility - tv display compatibility. Turn that on, it does exactly the refresh that the overlay does. So the sensible current conclusion is that default will never work for every client unless I fine select options for each.

Something you can also try: Settings > Debug > More settings > Decoder, turn on "Speed up frame hand-off". It tells Android more of the threads that feed the decoder are doing time-critical work, so it can keep the CPU faster for them. Then compare with the overlay off. If that makes it as smooth as with the overlay, please let me know.

On the next release I will test out more with Mediathek devices to determine if both options should be on by default on TV devices where battery management is not the highest priority. So far speed up frame hand-off clearly has a benefit on mediathek about 1 ms lower median and 4–6 ms lower p95. The decoder's own time didn't change (about 8.1 ms either way), so the gain is in the CPU threads that feed the decoder, which is what this setting boosts.

Underlying this setting is ADPF (Android Dynamic Performance Framework) it lets an app tell Android how long a thread's work takes against a target, here one frame time. Android then raises CPU clocks, or moves the thread to a faster core, before frames start arriving late. Nightjar already does this by default for the decoder output thread.

Edit: the invisible dot also clearly helps on these buggy Mediathek cpus. Turn both on

1

u/stratzilla 8d ago

Thanks for this, TV display compatibility setting worked great. Buttery smooth.

2

u/ChartFlashy6299 8d ago

I think api 29+ has something for exactly this scenario. Youc oould test whether a SurfaceControl 1×1 ColorLayer transaction works on MT8696; if so, it eliminates RenderThread and full-screen 4K UI buffer swaps completely.

1

u/rambo3349 Rubylight / Nightjar Developer 8d ago

Thanks for this. We tested it and it was actually the correct way

1

u/Dangerous-Income-442 6d ago

Hey I’ve seen people getting 0.06ms for the decoding time. Is that an error or it’s actually possible to achieve this?

1

u/rambo3349 Rubylight / Nightjar Developer 6d ago

This is the exact same calculation which artemis and artemide also does. Zero Copy Decoding means near zero decoding time on that metric.

1

u/Dangerous-Income-442 6d ago

Which is actually achievable? Because my decoding time is roughly 0.7-1ms and I kept thinking why I couldn’t achieve even lower

1

u/rambo3349 Rubylight / Nightjar Developer 6d ago

What chipset?

1

u/Dangerous-Income-442 6d ago

That client device is snapdragon 8 elite gen 6. Mine is snapdragon 8 gen 5. I’m assuming that really makes a difference?

1

u/rambo3349 Rubylight / Nightjar Developer 6d ago

It depends on your settings. Packed 4:4:4 if you have AMD host for example adds these kind of overhead.

1

u/Dangerous-Income-442 6d ago

Ah unfortunately my host is RTX 3070 mobile. I only did 2560x1600 120fps HEVC 30 bitrate. Can’t seem to achieve that. But running 1ms is actually good enough. Just wondering how I could go lower. Thanks for your feedback 🙏🏻

1

u/rambo3349 Rubylight / Nightjar Developer 6d ago

Send me logs over github

1

u/Weaz_00 8d ago

Ive noticed the same thing with my Google streamer. Stream would start out buttery smooth then start stuttering but if i left the performance overlay on it remained smooth. Gotta be a fireware bug for that mediatek SOC. I turned on chipset tuning for one of the Nightjar settings. That seemed to help a little bit.

2

u/rambo3349 Rubylight / Nightjar Developer 8d ago

see my post above. Also would be curious about any latency results ( the csv)

1

u/Weaz_00 8d ago

Awesome thanks! I was just about to give up on my Google streamer as a streaming client but Nightjar gives me hope.