obsproject / obs-browser

CEF-based OBS Studio browser plugin
GNU General Public License v2.0
776 stars 220 forks source link

OBS frequently crashes due to audio-io #328

Closed Durss closed 1 year ago

Durss commented 2 years ago

Operating System Info

Windows 10

Other OS

No response

OBS Studio Version

27.1.3

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/B5SjeoQF8xQUmqcX

OBS Studio Crash Log URL

No response

Expected Behavior

Not to crash

Current Behavior

OBS crashes

Steps to Reproduce

Even after months of more or less regular crashes I still have no precise steps to reproduce. But if I stream for at least 1 or 2 hours I almost always get a crash when switching to a specific scene.

That scene is my intro/break/outro. It contains a Browser source with some graphics and optional procedural ambient sounds (MP3 playing more or less randomly). I actually have the 3 browser sources with the same HTML page but different configs and I toggle their visibility.

The code for playing those sounds is rather simple, just this :

let audio = new Audio("path/to/file.mp3");
audio.play();

I do this on lots of other browser sources with no issue, but I do one more thing on this one, I change the sound panning to hear it more on the left or the right, like this :

    private panSound(sound:HTMLAudioElement):number {
        let ctx = new AudioContext();
        let src = ctx.createMediaElementSource(sound);
        let pan = ctx.createStereoPanner();
        pan.pan.value = Math.random()-Math.random();
        src.connect(pan);
        pan.connect(ctx.destination);
    }

This causes no major issue unless I check the control audio via OBS option on the browser source. Only in this case OBS crashes at almost every stream I do. But something strange is that it crashes even if the page actually plays no sound (I can disable them via a custom OBS panel). but maybe there's a glitch when switching to that scene which make the "intro" briefly play again before actually destroying it I don't really know.

Here are my browser sources configs :

Anything else we should know?

I've been having these crashes for a while, it's not due to a recent version of OBS specifically. I started streaming early march 2021, and I've been having these crashes since ~may 2021.

If that can help, I also have VBCables installed to get multiple audio sources so I can have a source dedicated to DMCA sensitive stuff.

I can't really send you the page that crashes OBS as it's in a very big project that manages everything on my stream which would be quite complicated for you to install and initialize. But I strongly believe the crashes reason is related to the code parts and configs I gave.

WizardCM commented 2 years ago

I've shifted this to the OBS Browser repo. The call stack seems to point to this section

https://github.com/obsproject/obs-browser/blob/b8543099091d1c3bef08ec3dc23313e00e1feb8e/obs-browser-source-audio.cpp#L19-L25

Now, this particular code seems to be limited to pre-83 versions of Chrome/CEF, which we currently are using CEF 75 on Windows. As mentioned in https://github.com/obsproject/obs-studio/discussions/3853 we're working hard on upgrading to CEF 95, which will mean this code path is no longer hit. I bet it'll likely solve this crash.

Durss commented 2 years ago

Thanks for that blazing fast answer and sorry for posting it on the wrong repo !

Durss commented 2 years ago

IN case that can help I made some tests on my latest streams disabling the sound panning and I got no more crash so the crashes are most probably linked to that specific part of code I wrote in my first message/

Warchamp7 commented 1 year ago

I'm doing some tidying up on the repo, please re-open this if it is still an issue as we have since upgraded CEF and Matt believed that would fix this.