obs-studio icon indicating copy to clipboard operation
obs-studio copied to clipboard

Enabling Hardware Decoding Causes Media Source to Freeze and Crash OBS on Exit (Intel Mac)

Open iamvlvt opened this issue 3 years ago • 2 comments

Operating System Info

macOS 13

Other OS

No response

OBS Studio Version

28.1.2

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/XpJQmNGjezSWcdJW

OBS Studio Crash Log URL

No response

Expected Behavior

Be able to use hardware decoding without resulting in a black screen.

Current Behavior

Enabling hardware decoding causes media source to freeze and crash OBS on exit

Steps to Reproduce

  1. Add Media Source
  2. Select .webm file
  3. Select Use hardware decoding when available
  4. Click OK
  5. Black screen appears

Anything else we should know?

No response

iamvlvt avatar Dec 22 '22 18:12 iamvlvt

Could you try this on the beta of OBS 29 as well? (This sounds like a dependency issue to me and we updated dependencies for 29). Also, could you attach the webm file you're using?

gxalpha avatar Dec 26 '22 13:12 gxalpha

Via the OBS Discord, last week I was asked to try it using the beta and I got the same result. I've attached a .webm file that I've tried to add to the scene collection.

Background Only.webm

iamvlvt avatar Dec 26 '22 14:12 iamvlvt

Confirmed in 29.0.2 that this still causes a crash on Intel mac.

Fenrirthviti avatar Mar 29 '23 19:03 Fenrirthviti

Looking into this bug, I was able to recreate it using the provided .webm file but instead of a black screen, my app would crash continuously upon restarting until I removed the file as a media source.

peternam1 avatar Apr 18 '23 23:04 peternam1

When testing the bug on an Apple Silicon (M2) Mac, there was no crash. Switching to an Intel Mac and taking the same steps to reproduce the bug does result in a crash after starting and stopping recording. Upon further inspection of the OBS Studio Log, a line mentions that "CBR support for VideoToolbox encoder requires Apple Silicon. Will use ABR instead." However, in the lines under, rate_control is set to CBR in the [VideoToolbox advanced_video_stream: 'h264']: settings, and CBR is set to on in the [CoreAudio AAC: 'Track1']: settings. Changing the rate_control variable in the encoder.c file leads to a change in behavior of the crash: the app no longer crashes after starting and stopping recording. Instead, the app freezes when exiting, and the user must force quit. Given the above statements, the bug is potentially connected to the fact that on Intel Macs, CBR is still being used rather than an alternative encoding method.

By default, selecting CBR in the VideoToolbox encoder results in this path: https://github.com/obsproject/obs-studio/blob/0fc3cb1962063d95666ce0bef5a46fd06e14c59f/plugins/mac-videotoolbox/encoder.c#L296-L299

That is ABR. You can see that the properties set are identical to if the user had explicitly selected ABR. https://github.com/obsproject/obs-studio/blob/0fc3cb1962063d95666ce0bef5a46fd06e14c59f/plugins/mac-videotoolbox/encoder.c#L326-L329

If on macOS 13+ and on Apple Silicon, this path runs: https://github.com/obsproject/obs-studio/blob/0fc3cb1962063d95666ce0bef5a46fd06e14c59f/plugins/mac-videotoolbox/encoder.c#L301-L310

That is CBR.

We simply don't change the logged value of rate_control.

That said, the Steps To Reproduce do not mention recording as a required step to crash, so I do not see how this is related.

RytoEX avatar Apr 20 '23 20:04 RytoEX

I have the exact same issue on an AMD GPU using Windows 11. When I use the nVidia GPU it works without any problems.

asc82 avatar Jun 16 '23 13:06 asc82