Injecting Commandline Parameters for Offscreen Browser

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Injecting Commandline Parameters for Offscreen Browser

Postby Mayhew » Wed Jun 16, 2021 12:22 pm

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?
Mayhew
Expert
 
Posts: 303
Joined: Mon Apr 18, 2011 8:02 pm

Re: Injecting Commandline Parameters for Offscreen Browser

Postby magreenblatt » Wed Jun 16, 2021 1:28 pm

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).
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Injecting Commandline Parameters for Offscreen Browser

Postby Mayhew » Tue Jun 22, 2021 12:23 pm

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.
Mayhew
Expert
 
Posts: 303
Joined: Mon Apr 18, 2011 8:02 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 31 guests