obsproject / obs-studio

OBS Studio - Free and open source software for live streaming and screen recording
https://obsproject.com
GNU General Public License v2.0
58.91k stars 7.84k forks source link

[macOS]: Twitch frame judder when OBS is hidden #11281

Open jshier opened 5 days ago

jshier commented 5 days ago

Operating System Info

macOS 14

Other OS

No response

OBS Studio Version

30.2.3

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/msO6lZ5uXO5hjBN9

OBS Studio Crash Log URL

No response

Expected Behavior

When hidden, OBS should perform normally. If it is unable to, some indication should be visible, like dropped frames or another indicator of GPU instability.

Current Behavior

When hidden OBS experiences rendering lag, as seen in the above log, which causes odd frame judder on Twitch without any corresponding dropped frames in either OBS or Twitch's video player. For instance this time mark in a recent stream of mine. You can see later in that same video that the judder is gone once I realized it was due to being hidden. Perhaps this is due to macOS' App Nap or related tech? (Disable App Nap.

Steps to Reproduce

  1. Start stream, ideally a game for GPU resource usage.
  2. With OBS foreground, observe the smoothness of the stream.
  3. Hide OBS (Command - H).
  4. Observe stream's frame judder. Observe no dropped frames from OBS or Twitch.

Anything else we should know?

Hardware is a Mac Studio M1 Ultra, macOS 14.6.1, 128GB RAM.

RytoEX commented 5 days ago

Incidentally, we already use beginActivityWithOptions:NSActivityUserInitiated, which the post you linked suggests for inhibiting both AppNap and sleep. However, on macOS we only use it for x264. If you wanted to confirm that it works for x264, you could try that encoder instead.

PatTheMav commented 5 days ago

If I read the log right, then the output resolution is 5K (5120x2880), which is far too high for the built-in H.264 encoder, especially as the settings also expect the encoding process to downscale to 1080p at the same time.

Reduce the output resolution in OBS itself to 1080p (which will downscale the output on the GPU before sending it to the encoder) and try again.

(I'm specifically asking for this as I'm not entirely sure how well the rescaling in the encoder config is wired up for the macOS encoders and want to rule out the frame size by having it rescaled in the output settings).

jshier commented 5 days ago

@PatTheMav When not hidden the settings work just fine (can link a log for the unhidden version if you want). I had read that you should only resize once, on the output side, rather than the video side. Should I instead resize on the video side and disable scaling on the output side? (On a related note, what are my optimal resolutions here? I play WoW at 5K with 50% rendering, so that's my start point.)

@RytoEX I'll do some experiments when I stream tonight, but is there a particular reason why the setting isn't generally disabled for all streaming, not just x264? Hiding the app isn't really important, it just keeps it out of the way, so if this can't be disabled I'll just keep it unhidden, as using the Apple encoder is a nice optimization.

PatTheMav commented 5 days ago

@PatTheMav When not hidden the settings work just fine (can link a log for the unhidden version if you want). I had read that you should only resize once, on the output side, rather than the video side. Should I instead resize on the video side and disable scaling on the output side? (On a related note, what are my optimal resolutions here? I play WoW at 5K with 50% rendering, so that's my start point.)

Correct - it might not solve the issue, but I'd rather check this first to possibly rule it out as a cause for it.

jshier commented 5 days ago

@PatTheMav Changing where the resizing happens doesn't seem to make a difference.

@RytoEX Changing the encoder actually makes it worse. x264, medium, 6000k, high, and the stream would actually drop out occasionally while OBS was hidden. Log Seems like x264 while hidden has GPU and CPU issues. So the issue likely isn't App Nap but some other background behavior.

Anything else to try?