Description
windowless_frame_rate
In CEF 51 there is a new option "windowless_frame_rate" in BrowserSettings.
Chromium flags
There are a bunch of flags in Chromium that can be used to tweak OSR, I see people posting them from time to time on the CEF Forum and in the CEF Issue Tracker.
You can pass flags to CEF Python programmatically, see api/CommandLineSwitches.md.
Try for example combinations of these flags:
--disable-gpu --disable-gpu-compositing
--enable-begin-frame-scheduling
--disable-d3d11
For best performance pass --disable-gpu --disable-gpu-compositing --enable-begin-frame-scheduling
- info by Marshall from the CEF Forum. These three flags are added by default in upstream cefclient OSR mode. Note that this will disable WebGL.
--disable-gpu --disable-gpu-compositing
When the disable-gpu
and disable-gpu-compositing
command-line flags are specified the CefRenderHandler::OnPaint method will be called directly from the compositor instead of requiring an additional copy for each frame.
Use software rendering and compositing (disable GPU) for increased FPS and decreased CPU usage. This will also disable WebGL so remove these switches if you need that capability.See https://bitbucket.org/chromiumembedded/cef/issues/1257 for details.
These flags are passed by default when calling cefclient with OSR enabled. If you pass --enable-gpu to cefclient then these flags will not be added.
--enable-begin-frame-scheduling
Synchronize the frame rate between all processes. This results in decreased CPU usage by avoiding the generation of extra frames that would otherwise be discarded. The frame rate can be set at browser creation time via CefBrowserSettings.windowless_frame_rate or changed dynamically using CefBrowserHost::SetWindowlessFrameRate. In cefclient it can be set via the command-line using --off-screen-frame-rate=XX
. See https://bitbucket.org/chromiumembedded/cef/issues/1368 for details.
--disable-d3d11
Windows-only to disable use of Direct3D 11.
cefclient
You can compare performance with the cefclient sample application from upstream. The cefclient executable is distributed along with CEF Python binaries. To run it in OSR mode type:
./cefclient --off-screen-rendering-enabled
By default frame rate is 30, to change it:
./cefclient --off-screen-rendering-enabled --off-screen-frame-rate=60
Additional flags that can be passed to cefclient:
--off-screen-frame-rate
--enable-gpu
--transparent-painting-enabled
--multi-threaded-message-loop
--external-message-pump
When --enable-gpu
is not passed, then cefclient adds these flags automatically by default: --disable-gpu --disable-gpu-compositing
Up-to-date OSR performance related flags can be found in upstream cefclient > ClientAppBrowser::OnBeforeCommandLineProcessing.
Message loop work
There is this line in kivy_.py to run message loop work:
#start idle
Clock.schedule_interval(self._cef_mes, 0)
Is this the best optimized way? The comment states "idle", which makes me wonder. Here is the reference in Kivy docs: https://kivy.org/docs/api-kivy.clock.html
Clock.schedule_once(my_callback, 0) # call after the next frame
Clock.schedule_once(my_callback, -1) # call before the next frame
How can we call message loop work in Kivy using constant intervals like 10ms?
PDF rendering in OSR mode
Not really performance related, but will mention it here for now. If the PDF extension is enabled then cc Surfaces must be disabled for PDFs to render correctly. For details see CEF Issue 1689:
https://bitbucket.org/chromiumembedded/cef/issues/1689
So:
- Either disable PDF extension using these flags:
--disable-extensions --disable-pdf-extension
- Or if PDF extension is enabled then in OSR mode you need to pass the
--disable-surfaces
flag
Is --disable-surfaces
flag deprecated? Can't find it neither using cs.chromium.org nor peter.sh flags