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

macOS Big Sur Known Issues (caused by CEF + Audio Monitoring)

Open Envo opened this issue 6 years ago • 137 comments

Nothing surprising, but I hope this report can help to make OBS available on the new macOS as soon as it's get's released.

Once you starts OBS on Big Sur, it's quit unexpectedly, here's the trace:

[Maintainer Edit] Snipped the crashlog and put it here as I was getting tired of having to scroll 8 pages to get to the discussion.

Envo avatar Jun 23 '20 09:06 Envo

In the future, please do not delete the report template.

I'll leave this open as it's something we'll need to address eventually, but it will likely be a while as this is a beta OS. A quick discussion in our Discord lead to concluding that crash appears to be related to CEF, and may require changes on their end to be compatible.

Fenrirthviti avatar Jun 23 '20 15:06 Fenrirthviti

I just deleted the whole settings folder from the ~/username/Library and now it works. Guess you're right and the problem was one of the streamlabs widget.

Sorry for the mess i made, I hope some way it can be a help.

Envo avatar Jun 23 '20 17:06 Envo

Is there any more details on why this is happening? Researching "Trace/BPT trap: 5", which is output by the terminal and listed as the termination signal, suggests this is failure at locating a dynamic library, and the OBS Log itself outputs:

os_dlopen(../obs-plugins/obs-browser->../obs-plugins/obs-browser.so): dlopen(../obs-plugins/obs-browser.so, 257): image not found

os_dlopen, or dlopen, is the system call for loading dynamic libraries, suggesting that this error has to do with loading the obs-browser. However, obs-browser.so exists in the application plugin directory, so I'm not sure why it's throwing a dlopen error, or even if the trap error is coincidence...

I have a stream this Saturday and can't afford to have OBS suddenly failing. It was working earlier today, with all my scenes, but trying to relaunch it an hour later results in this issue.

MisutaaAsriel avatar Oct 29 '20 04:10 MisutaaAsriel

If stream stability is a concern, I would recommend not running on untested beta operating systems.

Fenrirthviti avatar Oct 29 '20 05:10 Fenrirthviti

Gee, thanks for the advice. I'm aware I'm on a beta operating system. I'm an Appleseed beta tester.


Replacing Chromium Embedded Framework.framework in the Application's framework directory (e.g. /Applications/OBS.app/Contents/Frameworks/) with a copy from the CEF Automated Builds page, located within the Release folder of the downloaded archive, fixes the crash, but breaks OBS's browser. (tested: cef_binary_86.0.18+gd3ead8b+chromium-86.0.4240.111_macosx64 [Stable]).

It would seem the copy distributed with OBS is outdated, and unstable on Big Sur, but the latest version is not OBS compatible.


Additional information: I symlinked Plugins to obs-plugins, and this killed the os_dlopen(../obs-plugins/obs-browser->../obs-plugins/obs-browser.so): dlopen(../obs-plugins/obs-browser.so, 257): image not found error; this bit from the log would seem it was related to a renamed or incorrectly referenced plugins directory?


MisutaaAsriel avatar Oct 29 '20 05:10 MisutaaAsriel

Updating CEF is non-trivial, as we have very specific requirements and patches that were removed or deprecated in later versions. We are currently waiting on new OSR and audio support PRs to be addressed and merged, at which time we will be able to update CEF.

Fenrirthviti avatar Oct 29 '20 06:10 Fenrirthviti

Fair enough. Updating to macOS build 20B5012d seems to temporarily have remedied the issue. However, it's possible going forward that older versions of CEF may be unstable on newer versions of macOS, especially considering version 75.x is over a year old.

MisutaaAsriel avatar Oct 29 '20 07:10 MisutaaAsriel

I have a stream this Saturday and can't afford to have OBS suddenly failing.

Gee, thanks for the advice. I'm aware I'm on a beta operating system. I'm an Appleseed beta tester.

I'm having difficulty reconciling these two statements. Either you're aware you're beta testing, and are willing to live with the repercussions of that decision, or you have important things to stream that you can't afford to go wrong and stay on a stable operating system.

mufunyo avatar Oct 29 '20 11:10 mufunyo

To be fair, Apple Beta releases exist specifically for developers to update their software for the release, that's their raison d`être. That we don't have the resources to do so is an unfortunate situation, but "it's a macOS beta, don't expect it to work" is fine for a month or two after WWDC, but not this close to release. We should not accept this mentality and aim to do better.

Besides, this will affect all users upgrading to Big Sur of which there will be many and also everyone who got a new Mac over the holidays.

Regarding the error message os_dlopen(../obs-plugins/obs-browser->../obs-plugins/obs-browser.so): dlopen(../obs-plugins/obs-browser.so, 257): image not found, it is an unfortunate legacy issue that will pop up on every OBS launch and is "expected" (it's related to an older browser source plugin version iirc) - you will also find it in your logs when everything (including browser source) works as expected and not indicative of an issue.

PatTheMav avatar Oct 29 '20 13:10 PatTheMav

This response has been formatted with emboldened text for ease-of-access and speed reading.


I'm having difficulty reconciling these two statements. Either you're aware you're beta testing, and are willing to live with the repercussions of that decision, or you have important things to stream that you can't afford to go wrong and stay on a stable operating system.

I am aware of the repercussions of beta testing. That's part of the point. I'm here to detect issues with the operating system and application compatibility and report them.

The fact that I have to use Big Sur as my daily driver relates to the fact that I am not in a financial position to own a secondary Macintosh system; not all Mac owners are well off. 😐 — I recently got back in to streaming, and the lack of viable native alternatives, and the even greater instability of OBS variants and alternatives on even standard OS releases, means that I must rely on OBS for the time being.

My admitted sass was due to the response I received. Telling a beta tester, who is there to report issues with a beta, that maybe they shouldn't be using the beta, is a complete non-response and unhelpful. It's a method of "passing the buck" on issues involving (but not always caused by) betas that I've increasingly become agitated with receiving as of late, so I apologize if my attitude came across as abrasive. But @PatTheMav put it best:

"it's a macOS beta, don't expect it to work" is fine for a month or two after WWDC, but not this close to release. We should not accept this mentality and aim to do better.

OBS was also stable up until the other night, exception being only light crashing related to corrupted/broken audio configurations (which were remedied by removing them from the profile JSON). — The CEF crash was, as one might say, out of the blue, with no clear cause nor changes to the operating system or OBS configuration which may trigger it.


I would also like to note: browser engine development moves at an accelerated rate compared to standard application software_. — I know I'm not an OBS developer; and moving to a different engine or upgrading to a newer version that calls for complete rewriting of other components (or reduces the feature set) is never easy. — However, relying on a specific version of a browser engine, when that engine is over a year outdated and compatibility is not guaranteed, is detrimental to both application stability and user security. Frequently, browser engines are updated to patch major security flaws, or to improve serious performance detriments, which put a user's machine at risk of both security and performance losses. "Waiting around" for a newer version to get what you want, with no guarantee it'll happen, is not a serious development strategy.


On another note, as I mentioned previuosly, @PatTheMav, symlinking obs-plugins to the Plugins directory (within the application's root contents directory) completely silenced the error. — I am aware that there is no issue, now, but for those not familiar with OBS' inner workings, and the fact that both this error message and the CEF crash** at face value relate to the opening of a dynamic library, others, as I myself originally did, may incorrectly infer this error to be related to the issue at hand. — For the future, silencing this error may aid in more effective and accurate user-end troubleshooting. Erroneous errors aid no one.

If I should submit a separate issue ticket for this, including steps used to silence the error, please let me know.

MisutaaAsriel avatar Oct 29 '20 22:10 MisutaaAsriel

Nobody is questioning the issue or that this is something we should fix. I never said that you shouldn't be testing things. You claim that you understand what being on a beta OS means, but then come in to our issue report stating that "I have a stream this Saturday and can't afford to have OBS suddenly failing."

Perhaps there's a miscommunication here, but that kind of comment implies that you're asking us to drop everything and respond to your request in a timely manner. That starts the conversation off with a sense of entitlement from your end. People don't run betas in production where stability is a concern, no matter how close to release they are. Any veteran beta tester will know this, so making that comment in the first place is something you should know better to even add to an issue report.

Again, to clarify, this is an issue, and we should address it. My specific concern was the implication that we should fix it by Saturday for a stream for a single user where stability was a concern. My comment was perhaps a bit too harsh, and I apologize for that, but there is fault on both sides here.

Fenrirthviti avatar Oct 29 '20 22:10 Fenrirthviti

Perhaps there's a miscommunication here, but that kind of comment implies that you're asking us to drop everything and respond to your request in a timely manner. ... My comment was perhaps a bit too harsh, and I apologize for that, but there is fault on both sides here.

There definitely was a miscommunication then. My comment was not a request or demand that it be fixed in such an unreasonable time frame, but rather an expression of frustration, and a hope that, perhaps, someone else may have found a workaround, or temporary solution to the matter, as, as I stated, the occurrence of the issue was rather sudden and unexpected. — I have been running Big Sur since July, and have carried out a handful of streams using the software without this issue, including up until the other night.

My frustration was with a program that was working until it wasn't, with no clear explanation. The fact that it ran on the beta up to this point with no serious issue seemed to suggest that it wasn't the beta itself at fault; not entirely, anyways.

I struggle with communication, and sometimes I state things as matter-of-fact, that are [then] interpreted more as demands or other inaccurate inferences. It is a fact that I have a stream Saturday. It is a fact that it would cause problems for me if I were to miss it. It is also a fact that I myself have put myself into this "boat" by using a beta OS.

I made that statement to hopefully demonstrate the frustration this bug can cause. It is clear that I failed in that way. It was not a push for time, nor a demand that the entire OBS development team cater to me. I would never request such a thing. — If I was experienced in more than just Swift and Storyboards, I probably would have looked into trying to fix it myself, honestly.

Again, I do apologize for that.

MisutaaAsriel avatar Oct 29 '20 23:10 MisutaaAsriel

Side note - sounds like this was also reported here - https://github.com/obsproject/obs-browser/issues/235

As one of the people who keep an eye on CEF and our browser source closely, the fact that this crash exists is a concern. I personally can't think of a reason why this crash would only occur on Big Sur. I wonder if the hack in https://github.com/obsproject/obs-browser/commit/a4e05bc8b93393b47d52b1f7a3a58ba2ab19028c that's only enabled on Windows would fix this crash on macOS without having to upgrade CEF (could someone find out?).

I will also add my voice to mention that updating CEF in an official OBS capacity requires a fair bit of work. For any version of CEF 3904 (Chrome 78) and above, our existing audio mixing code is unnecessary. Additionally, around 3945 (Chrome 79) above the CEF Audio API was changed, and would require an OBS update to work properly. As a non-macOS user, I'd be curious which CEF version explicitly fixes the issue for you, and whether the fix would be something we could backport into 3770 or 3809 (Chrome 76). As it stands - if you update CEF in OBS to anything higher than 3809, it is unlikely that the "Control audio via OBS" setting in the browser source will function correctly.

I will continue to keep an close eye on CEF so that we can update to something newer ASAP, but as others have mentioned it likely won't be in time for Big Sur, and so I hope we can find a temporary solution that doesn't require users modify the OBS files themselves.

WizardCM avatar Oct 29 '20 23:10 WizardCM

I will continue to keep an close eye on CEF so that we can update to something newer ASAP, but as others have mentioned it likely won't be in time for Big Sur, and so I hope we can find a temporary solution that doesn't require users modify the OBS files themselves.

As it stands, even modifying the files does not work. It remedies the crash to replace CEF with a newer version, yes, but all browser content refuses to render, instead leaving a transparent square. I even tried CEF ver. 76.x (a single major revision up from OBS' 75.x), to no avail. — For users who have no reliance on browser content, this is a simple fix which would allow them to stream; but anyone who relies on browser content for widgets, media, or even graphical elements which OBS cannot provide (such as myself), this would be a non-option.

Replacing Chromium Embedded Framework.framework in the Application's framework directory ... with a copy from the CEF Automated Builds page ... fixes the crash, but breaks OBS's browser.


I know this may sound silly, coming from an inexperienced dev, but is there any reason OBS needs to use CEF on macOS? The system has a built in WebKit engine, including APIs for embedding webkit content such as WKWebView. WKWebView is also likely to be considerably less resource intensive over CEF, and provide great consistency with other system applications, and the system browser, Safari. — macOS isn't like Windows where, until recently, the included browser engine was a fork of IE (EdgeHTML), which whilst fairly standards compliant, had difficulty keeping up with WebKit & Blink.

It would require maintaining a macOS only fork, yes. Which is probably not ideal if you wish to maintain consistency between the macOS and Windows editions of OBS. However, it would guarantee increased compatibility with upcoming Apple Silicon Macs, as well as offer performance gains there too (by relying on the native system browser engine, rather than emulating CEF x86-64 via Rosetta 2, which would introduce overhead to an already performance heavy framework).

MisutaaAsriel avatar Oct 29 '20 23:10 MisutaaAsriel

Maintainability and someone putting in the effort are the primary reasons we don't. It's been discussed in the past, but nobody was really interested in doing the work, and there are limitations when it comes to a performance standpoint compared to CEF, IIRC. Those may have been resolved since it was last looked at, however, I am not sure offhand as it's been a while since we've looked at it.

Fenrirthviti avatar Oct 29 '20 23:10 Fenrirthviti

I know this may sound silly, coming from an inexperienced dev, but is there any reason OBS needs to use CEF on macOS?

We depend on 3 things at their core for the best performance (some of which are currently not available on CEF on macOS but there's a CEF PR I'm keeping an eye on):

  1. Audio routing (allows users to control browser source audio independently from system audio, including playing to a non-default device, or only sending it to the recording/stream)
  2. Off-screen rendering (this is used by browser sources & their Interact windows) and hardware acceleration
  3. Shared textures (allowing the ability to cut down resource usage when the Preview, Properties, Filters and Interact windows are displayed together)

Additionally, we don't have a big enough team (let alone anyone full-time) to actively maintain specific features for macOS. We're able to keep dependencies up to date and fix bugs quickly (where possible), but not write & maintain something as.. flexible and ever-changing as a browser component.

WizardCM avatar Oct 29 '20 23:10 WizardCM

Annnnnd it's crashing again.

Just to be clear, it was working again after moving to macOS build (20B5012d), but now, once again, with no clear reason and an arbitrary lapse in time from last launch, it is once again failing to launch.

As stated before, the method of termination being reported is Trace/BPT trap: 5, which the common consensus is a incorrectly referenced DYLIB. If this is accurate, and there was a way of knowing which library cannot be located, theoretically a terminal command is all it takes to tell macOS where it it actually located, or the library could be symlinked to the expected location.

Edit: Additionally, the behavior between launching OBS with CEF removed, and launching OBS with CEF replaced, is identical, suggesting OBS is rejecting other versions of CEF.

MisutaaAsriel avatar Oct 30 '20 00:10 MisutaaAsriel

I know this may sound silly, coming from an inexperienced dev, but is there any reason OBS needs to use CEF on macOS? The system has a built in WebKit engine, including APIs for embedding webkit content such as WKWebView.

Long story, short: There is no efficient way to generate a texture out of a WKWebView as WebKit’s out-of-process rendering was built to essentially disallow such shenanigans: https://developer.apple.com/forums/thread/129274?answerId=613174022#613174022

PatTheMav avatar Oct 30 '20 02:10 PatTheMav

Long story, short: There is no efficient way to generate a texture out of a WKWebView as WebKit’s out-of-process rendering was built to essentially disallow such shenanigans: https://developer.apple.com/forums/thread/129274?answerId=613174022#613174022

Forgive me again if this sounds stupid, but is it not possible to create a texture out of the WKWebView's parent? I'm not too familiar with macOS' method of drawing the UI, but on iOS, I was once able to draw a WKWebView as a texture on a 3D object in SceneKit by capturing a visual representation of the parent UIView which contained it. — I'm not sure how performant that was as a texture, however, admittedly. It may have been very slow. But I know in another project it performed equally to the actual display when displayed as a UIImage side-by-side. — If AppKit works any similar to UIKit, would it be possible to "wrap" the WKWebView in a parent object and use the wrapper as the texture instead?


I've tried building obs-browser with Chrome 77, to see if perhaps a slight version bump would remedy the issue. 77, as @WizardCM pointed out, 78 and above renders audio mixing unecessary. However, after getting dependencies, building CEF (as the binaries dont include libcef_dll_wrapper*), and patching everything up, I get Unknown CMake command "install_obs_plugin_with_data".. Not sure how to go from here as I am as unfamiliar with CMake as I am flavors of C (C# not withstanding).

And there hasn't been any separate binary releases for OBS-Browser in a while, with the latest being built on Chrome 40. That's... a tad out of date.


Edit: Dropping CEF 3865 (Chrome 77), and lower versions, in directly under the Frameworks folder loads (Launching from the terminal with DYLD_PRINT_LIBRARIES=1 DYLD_PRINT_INITIALIZERS=1 DYLD_PRINT_WARNINGS=1 shows that CEF is loaded and initialized, and no errors are returned as long as the version exceeds 75.1.16), but nothing displays in OBS, so the version OBS-Browser being built with Chrome 75 clearly does not work with even slightly newer versions.


~~Edit [2]: Is there any way of debugging exactly what it's crashing on? I don't have the DYSM file for 26.0.2, which would allow me to symbolicate the crash log to know what file and line it's crashing on. — Currently seeing if I can successfully build the entirety of OBS Studio using the 10.15 (Catalina) SDK on Big Sur in the meantime.~~

MisutaaAsriel avatar Oct 30 '20 03:10 MisutaaAsriel

Scroll down for important edits and information:


I wonder if the hack in obsproject/obs-browser@a4e05bc that's only enabled on Windows would fix this crash on macOS without having to upgrade CEF (could someone find out?).

I downloaded the source, @WizardCM, & commented out the correct portions, so it read:

//#ifdef _WIN32
	/* Massive (but amazing) hack to prevent chromium from modifying our
	 * process tokens and permissions, which caused us problems with winrt,
	 * used with window capture.  Note, the structure internally is just
	 * two pointers normally.  If it causes problems with future versions
	 * we'll just switch back to the static library but I doubt we'll need
	 * to. */
	uintptr_t zeroed_memory_lol[32] = {};
	CefInitialize(args, settings, app, zeroed_memory_lol);
//#else
//	CefInitialize(args, settings, app, nullptr);
//#endif

, and built the application using the CI script. — Attempts to build with Xcode throws errors, as cmake makes some errors in building that have to be corrected manually, so command line building has to do; but I can still attach the debugger through XCode none the less via custom scheme.


This is the error it throws with the Windows fix: Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

It points to this portion, "stepping in" to CEF, as containing the error (arrow where error is thrown):

0x1f5e645d <+141>: callq  0x1f5e8cca                ; symbol stub for: cef_initialize
->  0x1f5e6462 <+146>: movl   %eax, %ebx

With the "stock" configuration, no changes, this is the error it throws: Thread 1: EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)

Again, with a similar "root" cause stepping into CEF (arrow where error is thrown):

0x25d5c45d <+141>: callq  0x25d5ecca                ; symbol stub for: cef_initialize
->  0x25d5c462 <+146>: movl   %eax, %ebx

It would let me step further, except LLDB does not have the symbols for CEF loaded, and I personally wouldn't know how to load them as part of the debugging session of a "greater" program.


Edit: Using atos to symbolicate the crash log, it returns this for the relevant bits (ordered topmost to innermost):

atos -arch x86_64 -o [redacted]/Chromium\ Embedded\ Framework.dSYM/Contents/Resources/DWARF/Chromium\ Embedded\ Framework  -l 0x2850f000 0x000000002a99164c 0x000000002a991a18 0x000000002cf0a474 0x000000002acf4e3d 0x000000002ac390ed 0x000000002ac3a041

net_service::InputStreamReader::RunReadCallback(int) (in Chromium Embedded Framework) (stream_reader_url_loader.cc:411)

net_service::InputStreamReader::RunReadCallbackOnJobThread(int, base::OnceCallback<void (int)>) (in Chromium Embedded Framework) (stream_reader_url_loader.cc:431)

base::internal::Invoker<base::internal::BindState<void (DevToolsUIBindings::*)(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&), base::WeakPtr<DevToolsUIBindings>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, void (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)>::Run(base::internal::BindStateBase*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in Chromium Embedded Framework) (bind_internal.h:654)

EVP_des_ede3_cbc_init (in Chromium Embedded Framework) (e_des.c:159)

base::sequence_manager::internal::SequenceManagerImpl::~SequenceManagerImpl() (in Chromium Embedded Framework) (sequence_manager_impl.cc:200)

base::sequence_manager::internal::SequenceManagerImpl::CreateTaskQueueImpl(base::sequence_manager::TaskQueue::Spec const&) (in Chromium Embedded Framework) (sequence_manager_impl.cc:318)

If anybody can make sense of this, maybe have an idea of what's causing it, I'd be curious to hear about it. Address values were from a .crashlog. — It looks like it has something to do with threading and the task queue, to me?


Edit 2: As a side note, does anyone know why the bug onset is inconsistent? The first time OBS worked for months without issue, only to break. This time it worked after a system update only to break again. Both times OBS had been quit hours before and the machine left alone. This is bothering me, as you would expect the bug to, at the very least, be consistent. What allowed it to work before? What changed? These are the things that keep me up at night.


Edit 3: Another oddity: resetting OBS by way of deleting it's support directory restores functionality, and browser sources work. However, importing the old scene breaks OBS, suggesting that it is a matter of configuration? What is causing this bug?


Edit 4:

Discovery

It has to do with the number of OBS Browser objects in your scene file, total, not just what's active. "Disabling" CEF temporarily, and removing a handful (about 3) of browser objects from all scenes (ensuring there are no stale references keeping them live), before enabling CEF, results in successful launch.

Does OBS properly destroy and recreate CEF objects when switching scenes, when "Shutdown source when not visible" is enabled? As this behavior suggest no, OBS creates all the browsers up front (most of my browser objects are set to shutdown when not visible.)


~~Edit 5: It's still crashing after close, but I can consistently get it to launch normally again by disabling CEF, removing one [1] browser object, and re-enabling CEF.~~

Which is... odd, behavior. What is it that changes when OBS exits?

Edit 6: Disabling CEF, successfully launching OBS and exiting, then re-enabling CEF now works, without removing browser objects. To summarize:

  • If too many browser objects exist across all scenes, CEF will crash on initialization.
  • You can disable CEF by adding .bak to it's framework extension.
  • Reducing the amount of browser sources, whilst CEF is disabled, can facilitate future launches.
    • CEF will still crash on initialization, after a "successful" exit with CEF enabled, however.
  • A certain point of browser source reduction can be reached, facilitating launches without reduction.
    • An intermediary launch by disabling CEF, launching OBS, exiting, and reenabling CEF, is still required.
  • A certain point of reduction can be reached, facilitating launches without an intermediary launch.
    • This number seems to be quite low however (Tested: a fresh scene library with one [1] browser object).
  • The issue stems from CEF's initialization function.
    • However, it is not consistent, and is effected by the number of OBS-Browser sources.
    • It may stem from threading/queue issues?
    • It is also effected by how OBS exits, as sources that may be added and function whilst the app is operating will suddenly cause CEF to crash on next launch.
  • Adding full system permissions to OBS remedies nothing (thought I'd give it a shot).

MisutaaAsriel avatar Oct 30 '20 07:10 MisutaaAsriel