Page 1 of 1

Shared use of browser cache required

Posted: Thu Dec 05, 2024 11:09 am
by R. Eisenkolb
Hello Salvador

Since Chromium 120, it is mandatory to use a different browser cache directory for each running CEF client instance on a computer.
Otherwise, StartMainProcess fails from the second instance onwards.
https://stackoverflow.com/questions/78652092/cef4delphi-application-cant-run-two-instances
In our opinion, this is not a solution for supporting multiple instances of an app on one computer.
We would like to support a user who has started multiple app instances on one computer with the same cache.

Example spell checker:
The user adds a new word to the spelling dictionary. This is saved in the cache under dictionaries.
If the same user has opened a second CEF instance, then this instance has a different cache and therefore a different dictionary.
How to ensure that all instances for a user have an up-to-date dictionary?

Interestingly, StartMainProcess succeeds even for multiple instances when MultiThreadedMessageLoop = false and ExternalMessagePump = true.
Although this is not recommended as the cache may become corrupt.

Best regards
Reinhard

Re: Shared use of browser cache required

Posted: Thu Dec 05, 2024 3:55 pm
by salvadordf
R. Eisenkolb wrote: Thu Dec 05, 2024 11:09 am Hello Salvador

Since Chromium 120, it is mandatory to use a different browser cache directory for each running CEF client instance on a computer.
Otherwise, StartMainProcess fails from the second instance onwards.
https://stackoverflow.com/questions/78652092/cef4delphi-application-cant-run-two-instances
In our opinion, this is not a solution for supporting multiple instances of an app on one computer.
We would like to support a user who has started multiple app instances on one computer with the same cache.

Example spell checker:
The user adds a new word to the spelling dictionary. This is saved in the cache under dictionaries.
If the same user has opened a second CEF instance, then this instance has a different cache and therefore a different dictionary.
How to ensure that all instances for a user have an up-to-date dictionary?

Interestingly, StartMainProcess succeeds even for multiple instances when MultiThreadedMessageLoop = false and ExternalMessagePump = true.
Although this is not recommended as the cache may become corrupt.

Best regards
Reinhard
Hello Reinhard,

I'm sorry that you don't like this feature but it was added at the CEF project because it was never safe to have several instances of the same application using the same cache directory due to corruption issues.

Just to clarify, The CEF4Delphi and CEF projects are independent. I'm not a Google employee either. I'm just an independent freelance developer.

The recommended solution is to use the GlobalCEFApp.OnAlreadyRunningAppRelaunch event to be notified when a second app instance tried to run. This event is executed in the first instance and you can decide how to handle the situation.

I just added an example to the TabbedBrowser2 demo that opens a new browser tab with the URL given in the second command line :
https://github.com/salvadordf/CEF4Delphi/blob/8e5b4e4ef38cf9bbcd11509dbf6a7926f9e35422/demos/Delphi_VCL/TabbedBrowser2/uMainForm.pas#L158

Re: Shared use of browser cache required

Posted: Fri Dec 06, 2024 7:28 am
by R. Eisenkolb
Hello Salvador,

We really appreciate you doing this work. And we are very grateful for the help we get from you. I'm sorry if it gave the impression that I wanted to hold you responsible for decisions made by Google developers.

Best regards
Reinhard