Add/modify command line arguments from main and sub process

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.

Add/modify command line arguments from main and sub process

Postby YogeshTembe » Thu Mar 30, 2023 1:31 am

I want to add new commandline switches or modify few command line switches in main process.
I tried using "OnBeforeCommandLineProcessing" and process_type is supposed to be empty for main process. But I am not able to find a log with "process_type" empty.. I get few logs for other sub-processes.
To update main process command line flags we need to use "OnBeforeCommandLineProcessing" this function right? or is there any other way ?
If we try updating sub-process command line switches in "OnBeforeCommandLineProcessing", then it crashes.

I want to add new commandline switches or modify few command line switches in few sub processes.
I tried adding log in "OnBeforeChildProcessLaunch" but it does not get invoked. I am returning "CefBrowserProcessHandler" from "GetBrowserProcessHandler" function. Is there anything I am missing ?
Also I had few more doubts related to "OnBeforeChildProcessLaunch" -
1) how to identify process_type in OnBeforeChildProcessLaunch ?
2) This function will be called for gpu-process and renderer only? not for any other sub-process ?

Please let me know if there is any better way to achieve same thing.
YogeshTembe
Techie
 
Posts: 23
Joined: Tue Sep 14, 2021 6:01 am

Re: Add/modify command line arguments from main and sub proc

Postby magreenblatt » Thu Mar 30, 2023 9:14 am

OnBeforeCommandLineProcessing is the correct method. Make sure to pass your CefApp instance to both CefExecuteProcess and CefInitialize. Command-line flags should usually only be set on the main process. Which flags are you trying to set?
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Add/modify command line arguments from main and sub proc

Postby YogeshTembe » Sat Apr 01, 2023 4:40 am

1) OnBeforeCommandLineProcessing is called only for sub-processes and I do not see log with "process_type" empty so I guess its not called for main process. I have passed instance of cefApp to both CefExecuteProcess and CefInitialize. Is there any other reson why OnBeforeCommandLineProcessing is not called for main process ?

2) There are few flags attached to renderer sub-process. I wanted to know if those flags are copied from main process or they are dynamically attached to the renderer sub-process.
I wanted to remove all the command line flags from renderer sub-process and still have those switches turned on programatically, is there any way to achieve this ? We can add cefsettings in main process so can we do something similar in sub-process ?
YogeshTembe
Techie
 
Posts: 23
Joined: Tue Sep 14, 2021 6:01 am

Re: Add/modify command line arguments from main and sub proc

Postby magreenblatt » Sat Apr 01, 2023 8:10 am

OnBeforeCommandLineProcessing is called only for sub-processes

That is incorrect.

I wanted to remove all the command line flags from renderer sub-process and still have those switches turned on programatically, is there any way to achieve this ?

OnBeforeChildProcessLaunch can be used to modify the flags passed to sub-processes but usage as you describe is not recommended. Some command-line flags are required to properly launch sub-processes.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Add/modify command line arguments from main and sub proc

Postby YogeshTembe » Wed Apr 05, 2023 5:38 am

1) Who is responsible for calling sub-process executable that is passed in CefSettings "browser_subprocess_path" ?
2) How does main process flags are passed to sub-processes? Can we stop inheriting flags from main process to sub-processes ?
YogeshTembe
Techie
 
Posts: 23
Joined: Tue Sep 14, 2021 6:01 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 51 guests