Page 1 of 1

Injecting Commandline Parameters for Offscreen Browser

PostPosted: Wed Jun 16, 2021 12:22 pm
by Mayhew
Our app uses a windowed browser and in certain cases will create offscreen browsers to render some content. We would like the renderer process for the offscreen browsers to have different options than the main renderer for the windowed browser and I'm having trouble figuring out how to do this. Mainly we want to pass --disable-accelerated-video-decode to the offscreen render processes as they perform better in our use case with that flag. That flag causes a performance hit in our windowed browser which is why we don't want to set it generally.

My CefApp subclasses OnBeforeCommandlineProcessing can do this but the only info I have to go on there is the process type and I cannot differentiate between the main renderer and offscreen renderers.

I can pass some extra info into my CreateBrowser call which could be detected in cef app subclasses OnBrowserCreated (if I implement the CefRenderProcessHandler there) but I think that would come in after the renderer process for that browser had already been created. If OnBrowserCreated is called before OnBeforeCommandlineProcessing that would work but I'm not sure that is is the case.

Any ideas on the best way to do this?

Re: Injecting Commandline Parameters for Offscreen Browser

PostPosted: Wed Jun 16, 2021 1:28 pm
by magreenblatt
Generally, you can add command-line switches for subprocesses using CefBrowserProcessHandler::OnBeforeChildProcessLaunch. Note, however, that "disable-accelerated-video-decode" appears to also impact the GPU process which is shared by all browsers, so your stated intention may not work with that particular flag. In that case you would need to launch the OSR browsers using a separate main process (whole separate CEF instance).

Re: Injecting Commandline Parameters for Offscreen Browser

PostPosted: Tue Jun 22, 2021 12:23 pm
by Mayhew
Thanks for catching the GPU dependency. I did some searching and now see what you mean. This flag also seems to disable the sandbox which is not something we want to do so we are punting on this optimization.