-
Notifications
You must be signed in to change notification settings - Fork 244
obs-browser: Groundwork to enable Chrome 4430/arm64/Apple silicon #310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
obs-browser: Groundwork to enable Chrome 4430/arm64/Apple silicon #310
Conversation
|
Please split the changes for newer CEF support to a separate commit from the hardware acceleration related changes. Additionally, please be sure to run clang-format. |
I'm not sure we follow what you want split, what lines are you wanting as their own PR? We may need to modify this PR further to scope it to only run against the arm64 CEF variant and exclude x86. Will capture your feedback + clang in that subsequent change thank you. |
WizardCM
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what lines are you wanting as their own PR?
Not as their own PR, but as a separate commit in this PR. The idea is that each commit should be a single "functional" change, and it should be possible to revert them independently.
I've added a couple comments on the areas that should be their own commit, likely simply titled "Enable basic CEF 4430 support", whereas everything else would be "Enable better texture support on CEF ARM versions" as while these are related to each other, they have a different purpose.
Also, separate note - has this been tested on Windows? If scoping this to ARM removes any effect to Windows, then ignore this question.
Either way, thank you for your efforts. :)
|
hi @Developer-Ecosystem-Engineering I'm attempting to build your PR, but I'm unable to find the patch you shared in your instructions: |
Hi @gnuherdnix, that patch can be found here https://bitbucket.org/chromiumembedded/cef/pull-requests/285, thats not our work but appears to be some custom work to support texture sharing in OBS Studio to improve performance and reduce CPU overhead on x86. It doesn't appear to be technically necessary on Apple silicon, but we are still reviewing some tests and data based on feedback from the team. We will need to rework this PR based on some feedback, that should happen in a bit. |
|
Hi @Developer-Ecosystem-Engineering, this patch is not a performance enhancement, what it really does, is to bring back the OnAcceleratedPaint from CefRenderHandler, wich allows to access a gpu texture instead having to map raw RGBA pixels in memory, but most importantly, allows that each frame can be requested, this is very important for video in order to prevent tearing. In windows it uses DirectX11 shared handles and IOSurface on apple. |
@pabloko For all intents and purposes, to the end user, enabling hardware accelerated browser sources is a performance enhancement because it allows them to have fluid 60 FPS complex browser-based sources and overlays. We're not talking about increasing the efficiency of a loop or function when we use the phrase in this context. |
|
@RytoEX out of curiosity, could you point me to where the build infrastructure and patches are stored for the CEF prebuilts used for Mac & Windows? I haven't been able to find them and wanted to try building locally. @Developer-Ecosystem-Engineering Thanks for the link. Regarding IOSurfaces, in the example at hand where we render onto the IOSurface backed GL texture from the CEF process, and then read from that same texture for rendering to the scene in OBS, are we managing to work with the same pointer to on-device GPU memory and avoid CPU<->GPU memory copies? My understanding is that IOSurface allows transparent access to the surface data and will copy whether needed from GPU or CPU memory, but I'm wondering if we effectively avoid CPU copies when we are only reading & writing to the GPU memory buffer across the two processes. |
We don't have a build infrastructure for our CEF prebuilts. They were generously built by contributors so that we could host them so that people don't have to rebuild them when building obs-studio or obs-browser. I don't believe we have any custom CEF patches publicly posted. As @Developer-Ecosystem-Engineering has said, the texture sharing patch we use is that unmerged CEF PR. It's possible that we modified it further to get it to actually work, but I didn't work on it, so I can't speak to the details. |
|
| // CEF 4430 doesn't seem to work correctly when init'd with shared texture on arm64: | ||
| // - we never see OnAcceleratedPaint called | ||
| // - everything is black | ||
| // so we'll disable that for the time being |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a comment on CEF PR 285 recently about OnPaint was being called instead of OnAcceleratedPaint and they had to disable the sandbox to get this to work.
https://bitbucket.org/chromiumembedded/cef/pull-requests/285/reimplement-shared-texture-support-for-viz#comment-243274341
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, nice find, will take a look! Not sure if you want potential M1 users to take a look at Apple silicon OBS Browser with/without this change. Won't be able to get to it today.
RytoEX
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the first two commits cancel each other out. Please squash your commits so that only the relevant commits remain.
97e7368 to
c5ba29f
Compare
Apologies, should be resolved now, didn't mean to close the PR! |
RytoEX
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use imperative mood for the commit message subjects.
For example:
Add support for CEF 4430
I can't properly think of a way to rephrase the first commit message subject.
Wrap the commit message bodies at 72 characters. End sentences in the commit message body with periods.
A clarifying point about this:
On Apple silicon its not necessary to use the custom CEF patch which enables texture sharing on x86, to achieve 60 fps. Its wired up but disabled (enabling it has no effect on arm64 && APPLE)
Some users use many browser sources at once, sometimes running heavy workloads (bit cups used to be the common example). Hardware acceleration and texture sharing reduce CPU load overall in addition to achieving 60 FPS, not just aiming to allow one browser source to reach 60 FPS.
Hardware acceleration is still enabled. If you disable it in CEF, you'll definitely notice even on M1. |
On Apple silicon its not necessary to use the custom CEF patch which enables texture sharing on x86 to achieve 60 fps. This change hooks it up, but leaves it disabled. Enabling it has no effect on __arm64__ && __APPLE__
Changes to support using 4430 (arm64 support) within OBS Browser.
75f2391 to
2b2f9b5
Compare
Set assignment to multiple lines per project guidelines
RytoEX
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heads up, there are merge conflicts.
Am I understanding correctly that this PR's main change is changing the disable-gpu-compositing CEF/Chromium switch from relying on the value of the enable-gpu command line switch to using the value of the "Enable Browser Source Hardware Acceleration" option and preventing failures when using CEF >= 4430?
| << "." << std::to_string(obs_pat); | ||
|
|
||
| #if CHROME_VERSION_BUILD >= 4472 | ||
| #if CHROME_VERSION_BUILD >= 4430 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is correcting a mistake in #297. According to the linked CEF commit, this is the correct version. I'd prefer this change as its own commit because "Add support for CEF 4430" only barely applies to this change, and I was staring at this change for far too long wondering why it was being changed and what it had to do with adding support for CEF 4430. Honestly, this could even be PR'd and merged separately, because it's a straightforward and simple fix for a mistake that can be merged separately from this.
| obs_get_base_effect((hwaccel) ? OBS_EFFECT_DEFAULT_RECT | ||
| : OBS_EFFECT_DEFAULT); | ||
| bool useDefaultRect = hwaccel; | ||
| #if CHROME_VERSION_BUILD >= 4430 && defined(__APPLE__) && defined(__arm64__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need defined(__APPLE__) if it's wrapped in an #ifdef __APPLE__ ?
| #if CHROME_VERSION_BUILD >= 4430 && defined(__APPLE__) && defined(__arm64__) | ||
| // CEF 4430 doesn't seem to work correctly when init'd with shared texture on arm64: | ||
| // - we never see OnAcceleratedPaint called | ||
| // - everything is black | ||
| // so we'll disable that for the time being | ||
| tex_sharing_avail = false; | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed this was within obs_enter_graphics(). Though it is just one extra assignment, we try to do as little possible inside the graphics context as possible. This looks like it can safely be done after obs_leave_graphics(). Or you could rearrange the ifdefs, but it's probably less complicated to just move this one.
|
Does this still need to be open? |
|
I believe @PatTheMav integrated the spirit of these changes into his PR already and CEF is building 'elsewhere' to be included as a binary payload for arm64 variants of OBS. Would be good for him to confirm he's happy with it and it needs no further iteration. |
|
Yeah we've mainly used the CEF build instructions. We still need to revisit the coupling of enabling GPU compositing in CEF and texture sharing (because even with the latter disabled, CEF seems to still do the former on my M1 Mac). But I'm happy to solve/revisit this in the scope of another PR. |
|
Closing then since this was integrated via #290 Lets see what the feedback is on the M1 OBS build w.r.t. CEF and what needs further work, if anything. |
Since these CEF patches are not available on any particularly OBS Project repository, instructions are provided here
This should produce "cef_binary_90.6.7+g19ba721+chromium-90.0.4430.212_macosarm64_minimal.zip" which will be used as a part of the OBS Studio build and will also need these OBS Browser changes.
Description
When using CEF 4430 or later, we should use the texture sharing/gpu compositing feature that OBS Browser relies on, otherwise behaves like previously
Motivation and Context
OBS Studio relies on a custom patch to CEF in order to perform certain features in OBS Browser. Until these patches are integrated into an Apple silicon variant of CEF, OBS Studio isn't at feature parity natively on Apple silicon.
How Has This Been Tested?
Tested on M1 iMac and M1 MBP
macOS 11.5.1
Types of changes
Checklist: