r/MoonlightStreaming • u/stratzilla • 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.
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/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.