Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

Is it possible to let two TChromium components use the same render process?

Post Reply
tad.chen
Posts: 119
Joined: Fri Jan 04, 2019 1:39 am

Is it possible to let two TChromium components use the same render process?

Post by tad.chen »

When One TChromium component is created, its render process will be created too. Sometimes one render process only serves for one TChromium component, sometimes serves for several TChromium components. It's random! Is it possible to control it ? For example, let two TChromium components use the same render process?
User avatar
salvadordf
Posts: 4565
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Is it possible to let two TChromium components use the same render process?

Post by salvadordf »

Hi,

The number of processes is managed internally by Chromium. There are several process models supported by Chromium but if I remember correctly, CEF only supports the default model.

Read this for more information about the process models :
https://www.chromium.org/developers/des ... ess-models

You can try these switches :
  • --process-per-site
  • --process-per-tab
For example, add this line before the GlobalCEFApp.StartMainProcess call in the DPR file :

Code: Select all

GlobalCEFApp.AddCustomCommandLine('--process-per-site');
I haven't tested those switches and some people use this instead to enable the "process per site" model :

Code: Select all

GlobalCEFApp.AddCustomCommandLine('--process-per-site', 1);
You can also set GlobalCEFApp.SitePerProcess to FALSE or use the --renderer-process-limit switch to limit to the number of renderer processes.

The full list of switches is here :
https://peter.sh/experiments/chromium-c ... -switches/
tad.chen
Posts: 119
Joined: Fri Jan 04, 2019 1:39 am

Re: Is it possible to let two TChromium components use the same render process?

Post by tad.chen »

Thank you for your information! I'll think about it.
tad.chen
Posts: 119
Joined: Fri Jan 04, 2019 1:39 am

Re: Is it possible to let two TChromium components use the same render process?

Post by tad.chen »

salvadordf,

I made a test of JSExtension and found It doesn't support concurrency in one render process.

Browser process must sends JSExtension request one by one. If send the next request before last request's callback comes, it will be discarded.

This is found not only in one TChromium instance, but also in several TChromium instances running in one render process. For example, there are two TChromium instances A and B running in one render process. Sending JSExtension request to B must wait for the finish of Sending JSExtension request to A. I think the reason is that one render process only has one thread to handle all V8 javascript.

If A and B are running in different render process. It support concurrency.
User avatar
salvadordf
Posts: 4565
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Is it possible to let two TChromium components use the same render process?

Post by salvadordf »

Each render process handles IPC messages in its main thread and GlobalCEFApp.OnProcessMessageReceived is executed in the render process main thread.

If there's only one render process then all IPC messages will be handled sequentially by one thread.

Read this for more details about Chromium's multi-process architecture :
http://www.chromium.org/developers/desi ... chitecture

Image
User avatar
salvadordf
Posts: 4565
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Is it possible to let two TChromium components use the same render process?

Post by salvadordf »

A quote from the JavaScript integration document :
With CEF3 Blink (WebKit) and JS execution run in a separate renderer process. The main thread in a renderer process is identified as TID_RENDERER and all V8 execution must take place on this thread.
https://bitbucket.org/chromiumembedded/ ... ntegration
tad.chen
Posts: 119
Joined: Fri Jan 04, 2019 1:39 am

Re: Is it possible to let two TChromium components use the same render process?

Post by tad.chen »

OK! Thank you for your information.
Post Reply