centricular / gstcefsrc

A simple gstreamer wrapper around Chromium Embedded Framework
84 stars 45 forks source link

gst-launch process uses 100% cpu load #2

Closed hamza-u closed 4 years ago

hamza-u commented 4 years ago

gst-launch process uses 100% cpu load even on loading an empty html page.

MathieuDuponchelle commented 4 years ago

CEF is pretty demanding, however I can't reproduce this here:

GST_PLUGIN_PATH=$PWD/Release:$GST_PLUGIN_PATH gst-launch-1.0 cefsrc url="https://google.com" ! queue ! cefdemux name=d   d.video ! video/x-raw ! queue ! videoconvert ! autovideosink

shows around 55 % CPU usage on my machine, with single-core load not exceeding 40 % .

The default resolution is 1920 x 1080, and lowering that to eg 640 x 480:

GST_PLUGIN_PATH=$PWD/Release:$GST_PLUGIN_PATH gst-launch-1.0 cefsrc url="https://google.com" ! video/x-raw, width=640, height=480 ! queue ! cefdemux name=d   d.video ! video/x-raw ! queue ! videoconvert ! autovideosink

does show a corresponding decrease in CPU usage (20 %, single core not exceeding 10 %).

More precisions will be needed to debug this, eg what hardware are you running this on, does CPU usage decrease if you lower the resolution, gstreamer version, etc ..

hamza-u commented 4 years ago
  1. Tried with 320x240 @ 10fps - google.com, still it's 10% load
  2. gstreamer version is 1.14.5
  3. Regardless of hardware it takes 100% of one core, tried on laptpo, Intel E3v4 server, aws c5 instances too.
  4. When i wrtoe a simple CEF app without gstreamer there i do not see this issue.
  5. I'm suspecting something is going wrong as CEF & Gstreamer both use glib event loop.
MathieuDuponchelle commented 4 years ago
  1. Tried with 320x240 @ 10fps - google.com, still it's 10% load

I assume you meant 100 % here :)

  1. gstreamer version is 1.14.5

OK, I'm trying with gst-build / master, please set that up on your end and report results

  1. I'm suspecting something is going wrong as CEF & Gstreamer both use glib event loop.

Usage of GMainLoop in and of itself isn't known to cause such issues ;)

MathieuDuponchelle commented 4 years ago

Perhaps you can learn more with a profiling program, eg gprof

hamza-u commented 4 years ago

On replacing g_main_loop_run() from gstreamer app with while (true) sleep() and adding CefRunMessageLoop(); instead of CefDoMessageLoopWork (); in cefsrc plugin, 100% CPU load issue went away.

But obviously this is not a correct solution as event handling in gstreamer app is broken.

MathieuDuponchelle commented 4 years ago

Interesting, but please try with latest gstreamer: https://gitlab.freedesktop.org/gstreamer/gst-build

MathieuDuponchelle commented 4 years ago

Also @hamza-u please paste the pipeline you're trying

hamza-u commented 4 years ago

Sure i will try with latest gstreamer.

pipeline used : cefsrc ! videoconvert ! fakesink sync=true async=false Also tried with xvimagesink.

MathieuDuponchelle commented 4 years ago

OK.

On my end:

GST_PLUGIN_PATH=$PWD/Release:$GST_PLUGIN_PATH gst-launch-1.0 cefsrc url="www.google.com" ! videoconvert ! fakesink sync=true async=false

CPU usage sits at 11 % :)

I assume you haven't modified the default CEF version downloaded by the build system?

In any case, definitely try with master gst-build, and ideally obtain profiling data with gprof.

MathieuDuponchelle commented 4 years ago

@hamza-u to keep things tidy I will close this as I haven't had an answer to my last question, please reopen if you have more information.

hamza-u commented 4 years ago

@MathieuDuponchelle , sorry for delayed response, i was using CEF version 76.1.13+gf19c584+chromium-76.0.3809.132, on using same version as yours 3.3440.1806.g65046b7 i do not see high cpu usage issue.

MathieuDuponchelle commented 4 years ago

ok then :)