Page 1 of 1

Add/modify command line arguments from main and sub process

PostPosted: Thu Mar 30, 2023 1:31 am
by YogeshTembe
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.

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

PostPosted: Thu Mar 30, 2023 9:14 am
by magreenblatt
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?

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

PostPosted: Sat Apr 01, 2023 4:40 am
by YogeshTembe
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 ?

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

PostPosted: Sat Apr 01, 2023 8:10 am
by magreenblatt
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.

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

PostPosted: Wed Apr 05, 2023 5:38 am
by YogeshTembe
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 ?