Skip to content
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

Enable building with CEF 6261 & 6367 (Chromium 122 & 124) #434

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

WizardCM
Copy link
Member

@WizardCM WizardCM commented Feb 4, 2024

Description

This allows compiling OBS Browser with Chromium 124-based CEF versions.

This also adds basic support for the new, official, shared textures API on both Windows and macOS.

Sources:

Fun note; Remote debugging now requires --remote-allow-origins=* otherwise Remote Debugging immediately disconnects - even for localhost.

Motivation and Context

At some point we'd like to upgrade to modern CEF. To do that, obs-browser needs to compile.

How Has This Been Tested?

Launch OBS with a CEF 6261 or 6367 build. Have not tested downgrading CEF to our currently supported versions.

Only tested on Windows.

Types of changes

  • Tweak (non-breaking change to improve existing functionality)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@WizardCM WizardCM added the Enhancement New feature or improvement label Feb 4, 2024
jmickelonis added a commit to jmickelonis/obs-browser that referenced this pull request Feb 7, 2024
@jmickelonis
Copy link

jmickelonis commented Feb 9, 2024

Slightly off-topic, but you might be interested to know.
I built with 6261 (beta) on Ubuntu 23.10. Browser sources and docks do show up, but calls to ExecuteJavascript fail silently without effect. 6167 stable works fine.

@PatTheMav
Copy link
Member

@WizardCM do you want to include the texture flip override for builds above 6261 in this PR as well (as discussed off-thread)?

As the texture shared with us is originally created for video encoding, it's pre-flipped already.

@RytoEX RytoEX mentioned this pull request Apr 2, 2024
6 tasks
@RytoEX RytoEX requested a review from PatTheMav April 2, 2024 22:53
@RytoEX RytoEX self-assigned this Apr 2, 2024
@RytoEX
Copy link
Member

RytoEX commented Apr 3, 2024

@WizardCM do you want to include the texture flip override for builds above 6261 in this PR as well (as discussed off-thread)?

As the texture shared with us is originally created for video encoding, it's pre-flipped already.

Gentle ping, @WizardCM ?

This allows compiling OBS Browser with Chromium 124-based CEF versions.

This also enables basic support for the new, official, shared texture
API, purely because building without it would be *more* difficult.

Sources:
 - https://bitbucket.org/chromiumembedded/cef/commits/260dd0ca2
@WizardCM WizardCM changed the title Enable building with CEF 6261 (Chromium 122) Enable building with CEF 6261 & 6367 (Chromium 122 & 124) Apr 28, 2024
@WizardCM
Copy link
Member Author

@RytoEX @PatTheMav Per prior discussion, this PR now makes the necessary adjustments (including flip) to correctly run shared textures with CEF 6367. I have tested it on Windows 10 with the 6367 CEF build only. I've also kept the two commits separate for easier review, and they can realistically be combined for final merge.

@@ -415,7 +427,11 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>,
UpdateExtraTexture();
obs_leave_graphics();

#if CHROME_VERSION_BUILD >= 6367
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt the correctness, although it might be true for now because the underlying FrameSinkVideoCapturer will resurrect the frame if there's no change, but I don't remember whether it will still clone the handle and change the value (although it still points to same texture). See Export Handle

Also, even the textures are different, there are still chances that CloneHandle will return same value of two different texture.

In conclusion, I suggest not record this, and do not early return if new last_handle == info.shared_texture_handle to prevent potential frame skips.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a theoretical or confirmed problem? If this is definitely creating an observable problem after building against the latest version of CEF, then we should address it now. If this is merely a theoretical problem that has not been confirmed, then I don't want to spend too much time dwelling on it. I'd rather make it possible to make builds against CEF 122/124+ and figure out what problems exist and fix them.

Copy link

@reitowo reitowo May 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although IOSurface pointers could be valid for this as discussed with @PatTheMav , DXGI handles are not. I think we should just remove this line and remove last_handle. Re-importing every frame just cost 50~100us and I think we can omit it.

The problem is this is a real theoretical problem and we will not know if underlying chromium code changes behaviour. The suggested behaviour doesn't let us "cache".

Considering a frame skip could be rare and hard to notice, I think we should just disable such "optimization" and do the absolute right thing, prevent letting someone in the world wondering why frames are skipped.

If someone have time to write a reliable test to confirm such skip are valid on all platform, I'll be in favor, otherwise I think is it worthless to take the risk considering the cost is so small.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A problem can't be both "real" and "theoretical". I'm asking if there's an observable failure/error when building with this code against CEF 124+. As it is right now, we cannot test obs-browser with CEF 124+ in any meaningful way without this PR, which is my concern at the moment. I'm not saying "don't ever fix this". I'm saying "does this need to be fixed before merging", because otherwise we can't meaningfully test CEF 124+ without specifically pulling this PR locally.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theoretically, yes. You can also anaylze the code and get the same conclusion. So I think we would better remove this >= 6367 to take no risk.

void *shared_handle)
#endif
{
if (type != PET_VIEW) {
// TODO Overlay texture on top of bs->texture
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also left a word here. This should be removed >= 6367 as it has no guarantee on both macOS and Windows that same handle = same content. On Linux this handle is no more valid because of that complex native pixmap structure.

#ifndef _WIN32
	if (shared_handle == bs->last_handle)
		return;
#endif

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with the other one, is this a theoretical or confirmed problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants