obsproject / obs-browser

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

On Linux, the Browser Source rendering is very laggy (~3FPS) where Chrome and FF run at 60FPS #309

Open xurei opened 3 years ago

xurei commented 3 years ago

Operating System Info

Other

Other OS

Manjaro Linux

OBS Studio Version

27.0.1

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/FsbiJvZzu3Kl4SSU

OBS Studio Crash Log URL

No response

Expected Behavior

Using this as a Browser Source : https://outer-wilds-anim-6zl8zgucn-xurei.vercel.app/

A comparable FPS using the Browser Source compared to Chrome/FF

Current Behavior

The framerate is really laggy (~5FPS).

Steps to Reproduce

  1. Create a Browser Source with this URL : https://outer-wilds-anim-6zl8zgucn-xurei.vercel.app/ (dimensions 2560x1440)
  2. Compare with the same page on Google Chrome or Firefox (with 75% zoom on a 1080p screen)

Anything else we should know?

Note that the page is not optimized at all. I'm actually more interested for an explanation of the underlying cause rather than an actual fix of the issue.

I tested it on Windows and the animation is fluid.

xurei commented 3 years ago

I just made a performance profiling of the page and here is the result : Screenshot from 2021-07-28 16-18-33

Apparently there is some kind of throttle happening. The browser is almost always idle...

By comparison, the same profile results when opened in Chrome : Screenshot from 2021-07-28 15-57-07

WizardCM commented 3 years ago

Our browser source is officially untested with CEF 88.0.4324 on Linux, so I'm not surprised there might be quirks.

Are browser docks/panels having similar performance issues, or is it limited to browser sources?

xurei commented 3 years ago

For what I know, it only happens on this specific, highly unoptimized page.

The other browser sources I are completely fluid. I just tested a more complex page with 200+ sprites moving and no lag at all.

Our browser source is officially untested with CEF 88.0.4324 on Linux

I'm not blaming or requesting anything here, I'm just curious about what could be causing this.

tytan652 commented 3 years ago

On AUR, there is two "stable" OBS packages, obs-studio-browser which use this CEF and obs-studio-tytan652 which add some tweaks and use the right CEF.

mihawk90 commented 3 years ago

Our browser source is officially untested with CEF 88.0.4324 on Linux

Can reproduce on Fedora though with CEF 4280 (from the OBS CDN).

I suspect missing hardware acceleration (to my knowledge that is still not available on Linux because ... reasons). My CPU fan ramps up immediately and it also gets less and less laggy the further down you set the resolution in the source properties.

tytan652 commented 3 years ago

CEF Hardware accel is actually made of unmerged PR for Windows and macOS unfortunately

xurei commented 3 years ago

I just checked and GPU raster is disabled on OBS side, and enabled in Chrome.

Screenshot from 2021-07-28 17-44-46

The root cause seems to be that indeed.

I'm trying obs-studio-tytan652 to see if there is any difference

kkartaltepe commented 3 years ago

Hardware rendering is not supported on linux because its not compatible with wayland. And in this case since you are on not on ubuntu, your packager's settings may vary*

xurei commented 3 years ago

@kkartaltepe Isn't there any way to detect a X11 environment then, which remains widely used, and I guess it would probably work ?

kkartaltepe commented 3 years ago

Probably, the minor testing we did during the last version mostly worked but wayland was our priority.

kkartaltepe commented 3 years ago

If you want to play with it locally you can apply the patch, if you see that doesnt help let us know and we can reopen the bug.

diff --git a/browser-app.cpp b/browser-app.cpp
index 3b867e7..22ba818 100644
--- a/browser-app.cpp
+++ b/browser-app.cpp
@@ -81,7 +81,7 @@ void BrowserApp::OnBeforeCommandLineProcessing(
                CefString type = command_line->GetSwitchValue("type");

                if (!enableGPU && type.empty()) {
-                       command_line->AppendSwitch("disable-gpu");
+                       // command_line->AppendSwitch("disable-gpu");
                        command_line->AppendSwitch("disable-gpu-compositing");
                }
        }
mihawk90 commented 3 years ago

That line doesn't exist on current obs-browser master:

https://github.com/obsproject/obs-browser/blob/80b0c8202bc8d304a777fe2d956b847bb05713c8/browser-app.cpp#L76

However I still can reproduce the issue as stated above, and I am using the current master because I was testing the Drag&Drop fix

edit: https://github.com/obsproject/obs-browser/commit/d5640004b3e4ae2cd9c0e4a93b4da6b4d15c0498 obsproject/obs-browser#278

kkartaltepe commented 3 years ago

Ah looks like it did land before 27, sorry for misremembering.

xurei commented 3 years ago

@kkartaltepe The line is indeed missing. However, this portion of code gave me the hint :

bool enableGPU = command_line->HasSwitch("enable-gpu");
CefString type = command_line->GetSwitchValue("type");

if (!enableGPU && type.empty()) {
    command_line->AppendSwitch("disable-gpu-compositing");
}

Running obs --enable-gpu gives a much smoother rendering :smiley: around 25FPS

Chrome devtools still states that GPU raster is off, though. Around 25% of the frames are dropped when 60FPS are configured in OBS source properties. Almost none with 30FPS.

kkartaltepe commented 3 years ago

The sample page looks like it renders with CSS animations which I dont think will be as performant in cef for a long time. But maybe someone more knowledgeable can see if there is a better way to tickle cefs buttons.

torgabor commented 2 years ago

I've tested 27.2.0 on Ubuntu 20.04, and it seems the issue still persists, even after the CEF update. I think the root cause is that the CEF shared texture support is not working. Are the shared textures implemented yet for Linux, or are they still WIP?

RytoEX commented 2 years ago

I've tested 27.2.0 on Ubuntu 20.04, and it seems the issue still persists, even after the CEF update. I think the root cause is that the CEF shared texture support is not working. Are the shared textures implemented yet for Linux, or are they still WIP?

Shared textures are only on Windows and macOS right now.