From 0941026b41a41c7616a19fb24b513ae60ab5b634 Mon Sep 17 00:00:00 2001 From: Matt Gajownik Date: Sun, 9 Jun 2024 15:41:52 +1000 Subject: [PATCH 1/3] Enable building with CEF 5938 on macOS At some point between 5563 and 5938, the parameter's type changed. --- browser-app.cpp | 4 ++++ browser-app.hpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/browser-app.cpp b/browser-app.cpp index 582b1c6ee..576a3f7b8 100644 --- a/browser-app.cpp +++ b/browser-app.cpp @@ -517,7 +517,11 @@ void ProcessCef() #define MAX_DELAY (1000 / 30) +#if CHROME_VERSION_BUILD < 5938 void BrowserApp::OnScheduleMessagePumpWork(int64 delay_ms) +#else +void BrowserApp::OnScheduleMessagePumpWork(int64_t delay_ms) +#endif { if (delay_ms < 0) delay_ms = 0; diff --git a/browser-app.hpp b/browser-app.hpp index e23156e02..035f13857 100644 --- a/browser-app.hpp +++ b/browser-app.hpp @@ -110,7 +110,11 @@ class BrowserApp : public CefApp, CefString &exception) override; #ifdef ENABLE_BROWSER_QT_LOOP +#if CHROME_VERSION_BUILD < 5938 virtual void OnScheduleMessagePumpWork(int64 delay_ms) override; +#else + virtual void OnScheduleMessagePumpWork(int64_t delay_ms) override; +#endif QTimer frameTimer; #endif From c8ef252246c867be7ff4d21f366a79aa17918388 Mon Sep 17 00:00:00 2001 From: Matt Gajownik Date: Sun, 4 Feb 2024 23:12:55 +1100 Subject: [PATCH 2/3] Enable building with CEF 6261 This allows compiling OBS Browser with Chromium 122-based CEF versions. Sources: - https://github.com/chromiumembedded/cef/blame/d3a483ef59f8f40c624967361e05edda413bbf5b/libcef_dll/ctocpp/browser_ctocpp.h#L57 - https://bitbucket.org/chromiumembedded/cef/commits/f3b570c --- browser-app.cpp | 14 ++++++++++++-- obs-browser-page/obs-browser-page-main.cpp | 2 ++ obs-browser-plugin.cpp | 5 ++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/browser-app.cpp b/browser-app.cpp index 576a3f7b8..fb1c3a8a6 100644 --- a/browser-app.cpp +++ b/browser-app.cpp @@ -147,7 +147,12 @@ void BrowserApp::ExecuteJSFunction(CefRefPtr browser, std::vector names; browser->GetFrameNames(names); for (auto &name : names) { - CefRefPtr frame = browser->GetFrame(name); + CefRefPtr frame = +#if CHROME_VERSION_BUILD >= 6261 + browser->GetFrameByName(name); +#else + browser->GetFrame(name); +#endif CefRefPtr context = frame->GetV8Context(); context->Enter(); @@ -346,7 +351,12 @@ bool BrowserApp::OnProcessMessageReceived(CefRefPtr browser, std::vector names; browser->GetFrameNames(names); for (auto &name : names) { - CefRefPtr frame = browser->GetFrame(name); + CefRefPtr frame = +#if CHROME_VERSION_BUILD >= 6261 + browser->GetFrameByName(name); +#else + browser->GetFrame(name); +#endif CefRefPtr context = frame->GetV8Context(); context->Enter(); diff --git a/obs-browser-page/obs-browser-page-main.cpp b/obs-browser-page/obs-browser-page-main.cpp index 6a3906c5d..97bf0ee61 100644 --- a/obs-browser-page/obs-browser-page-main.cpp +++ b/obs-browser-page/obs-browser-page-main.cpp @@ -79,8 +79,10 @@ int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int) std::thread shutdown_check; CefMainArgs mainArgs(nullptr); +#if CHROME_VERSION_BUILD < 5615 if (!SetHighDPIv2Scaling()) CefEnableHighDPISupport(); +#endif CefRefPtr command_line = CefCommandLine::CreateCommandLine(); diff --git a/obs-browser-plugin.cpp b/obs-browser-plugin.cpp index 188958efe..8cf67e013 100644 --- a/obs-browser-plugin.cpp +++ b/obs-browser-plugin.cpp @@ -748,9 +748,12 @@ bool obs_module_load(void) os_event_init(&cef_started_event, OS_EVENT_TYPE_MANUAL); -#ifdef _WIN32 +#if defined(_WIN32) && CHROME_VERSION_BUILD < 5615 /* CefEnableHighDPISupport doesn't do anything on OS other than Windows. Would also crash macOS at this point as CEF is not directly linked */ CefEnableHighDPISupport(); +#endif + +#ifdef _WIN32 EnumAdapterCount(); #else #if defined(__APPLE__) && !defined(ENABLE_BROWSER_LEGACY) From c4c2a7df594dfd8eabbf80d0c4a03c3d9ea1266a Mon Sep 17 00:00:00 2001 From: Matt Gajownik Date: Sun, 28 Apr 2024 21:34:22 +1000 Subject: [PATCH 3/3] Enable building with CEF 6367 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 --- browser-client.cpp | 22 ++++++++++++++++++++-- browser-client.hpp | 12 ++++++++---- obs-browser-source.cpp | 2 +- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/browser-client.cpp b/browser-client.cpp index d91ca7024..1c0ca264e 100644 --- a/browser-client.cpp +++ b/browser-client.cpp @@ -373,7 +373,11 @@ void BrowserClient::UpdateExtraTexture() void BrowserClient::OnAcceleratedPaint(CefRefPtr, PaintElementType type, const RectList &, +#if CHROME_VERSION_BUILD >= 6367 + const CefAcceleratedPaintInfo &info) +#else void *shared_handle) +#endif { if (type != PET_VIEW) { // TODO Overlay texture on top of bs->texture @@ -384,7 +388,7 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr, return; } -#ifndef _WIN32 +#if !defined(_WIN32) && CHROME_VERSION_BUILD < 6367 if (shared_handle == bs->last_handle) return; #endif @@ -399,12 +403,20 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr, bs->texture = nullptr; } -#if defined(__APPLE__) && CHROME_VERSION_BUILD > 4183 +#if defined(__APPLE__) && CHROME_VERSION_BUILD > 6367 + bs->texture = gs_texture_create_from_iosurface( + (IOSurfaceRef)(uintptr_t)info.shared_texture_io_surface); +#elif defined(__APPLE__) && CHROME_VERSION_BUILD > 4183 bs->texture = gs_texture_create_from_iosurface( (IOSurfaceRef)(uintptr_t)shared_handle); #elif defined(_WIN32) && CHROME_VERSION_BUILD > 4183 bs->texture = +#if CHROME_VERSION_BUILD >= 6367 + gs_texture_open_nt_shared( + (uint32_t)(uintptr_t)info.shared_texture_handle); +#else gs_texture_open_nt_shared((uint32_t)(uintptr_t)shared_handle); +#endif //if (bs->texture) // gs_texture_acquire_sync(bs->texture, 1, INFINITE); @@ -415,7 +427,13 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr, UpdateExtraTexture(); obs_leave_graphics(); +#if defined(__APPLE__) && CHROME_VERSION_BUILD >= 6367 + bs->last_handle = info.shared_texture_io_surface; +#elif CHROME_VERSION_BUILD >= 6367 + bs->last_handle = info.shared_texture_handle; +#else bs->last_handle = shared_handle; +#endif } #ifdef CEF_ON_ACCELERATED_PAINT2 diff --git a/browser-client.hpp b/browser-client.hpp index cbff1201e..36dd5d89c 100644 --- a/browser-client.hpp +++ b/browser-client.hpp @@ -135,10 +135,14 @@ class BrowserClient : public CefClient, const void *buffer, int width, int height) override; #ifdef ENABLE_BROWSER_SHARED_TEXTURE - virtual void OnAcceleratedPaint(CefRefPtr browser, - PaintElementType type, - const RectList &dirtyRects, - void *shared_handle) override; + virtual void + OnAcceleratedPaint(CefRefPtr browser, PaintElementType type, + const RectList &dirtyRects, +#if CHROME_VERSION_BUILD >= 6367 + const CefAcceleratedPaintInfo &info) override; +#else + void *shared_handle) override; +#endif #ifdef CEF_ON_ACCELERATED_PAINT2 virtual void OnAcceleratedPaint2(CefRefPtr browser, PaintElementType type, diff --git a/obs-browser-source.cpp b/obs-browser-source.cpp index 09b301718..258bbcd86 100644 --- a/obs-browser-source.cpp +++ b/obs-browser-source.cpp @@ -658,7 +658,7 @@ extern void ProcessCef(); void BrowserSource::Render() { bool flip = false; -#ifdef ENABLE_BROWSER_SHARED_TEXTURE +#if defined(ENABLE_BROWSER_SHARED_TEXTURE) && CHROME_VERSION_BUILD < 6367 flip = hwaccel; #endif