Crash when cache_path and root_cache_path are not set

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.

Crash when cache_path and root_cache_path are not set

Postby aligre » Tue Dec 19, 2023 9:02 am

Hello

We're currently testing CEF 120 in our application, on windows 10, and we have a crash in a rare situation :
+ two processes are launched
+ the processes's cef settings about cache (cache_path and root_cache_path) have an empty value (*).
+ Then the second process crashes. It emits the following recent warning :
WARNING:resource_util.cc(94)] Please customize CefSettings.root_cache_path for your application.
Use of the default value may lead to unintended process singleton behavior


(*) : we empty these two settings during test replays in order to avoid instability due to cache content.

To reproduce the issue on cefclient from CEF120, it's only necessary to activate the multi_threaded_message_loop :
1) For example, in MainContextImpl::PopulateSettings from file tests\cefclient\browser\main_context_impl.cc
add the following settings value at the end of the method and rebuild
settings->multi_threaded_message_loop = 1;
2) Launch first cefclient : it's ok.
3) Launch another cefclient without closing the previous one : crash with the following log content
[1219/143816.198:WARNING:resource_util.cc(94)] Please customize CefSettings.root_cache_path for your application. Use of the default value may lead to unintended process singleton behavior.
[1219/143816.234:FATAL:ref_counted.h(220)] Check failed: !in_dtor_.
and the call stack of the crash is in the UI THREAD, while in the main thread the method CefInitialize has previously failed.

With the same modifications (multi_threaded_message_loop) in CEF 118 and the same scenario, the crash did not occur and both cefclients are working fine.

Does someone know if the memory cache mode (i.e. when cache_path and root_cache_path are empty) is no more supported ?
maybe when combined with multi_threaded_message_loop?

Thanks
aligre
Techie
 
Posts: 24
Joined: Fri Apr 09, 2021 7:38 am

Re: Crash when cache_path and root_cache_path are not set

Postby magreenblatt » Tue Dec 19, 2023 11:57 am

Are you checking the return value of CefInitialize? See https://github.com/chromiumembedded/cef/issues/3615
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Crash when cache_path and root_cache_path are not set

Postby aligre » Tue Dec 19, 2023 3:11 pm

Thanks for the link that helps us to understand the configuration with 2 app instances, each of them using the default cache directory, is not a valid configuration.
We have now different ways to fix that : OnAlreadyRunningAppRelaunch, one different cache dir for each instance
aligre
Techie
 
Posts: 24
Joined: Fri Apr 09, 2021 7:38 am

Re: Crash when cache_path and root_cache_path are not set

Postby magreenblatt » Tue Dec 19, 2023 5:06 pm

Please customize CefSettings.root_cache_path for your application.
Use of the default value may lead to unintended process singleton behavior

You should still do as this warning suggests. Using the default root_cache_path value may result in some other CEF-based application's OnAlreadyRunningAppRelaunch being called when you launch your application.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Crash when cache_path and root_cache_path are not set

Postby aligre » Wed Dec 20, 2023 4:23 am

Yes, clearly
Thanks
aligre
Techie
 
Posts: 24
Joined: Fri Apr 09, 2021 7:38 am

Re: Crash when cache_path and root_cache_path are not set

Postby linuxcef07 » Wed Dec 20, 2023 12:09 pm

After checking the return value of CefInitialize, there are no crashes.
But there is still issue with rendering along with warnings related to "root_cache_path" & "CefBrowserProcessHandler::OnAlreadyRunningAppRelaunch".
[1220/173153.944186:WARNING:resource_util.cc(94)] Please customize CefSettings.root_cache_path for your application. Use of the default value may lead to unintended process singleton behavior.
[1220/173154.189642:WARNING:sandbox_linux.cc(400)] InitializeSandbox() called with multiple threads in process gpu-process.
[1220/173154.225909:WARNING:child_thread_type_switcher_linux.cc(27)] Could not find tid
[1220/173154.433736:WARNING:alloy_browser_main.cc(167)] Unhandled app relaunch; implement CefBrowserProcessHandler::OnAlreadyRunningAppRelaunch.


I am bit confused what is exactly needed to fix this:
1. Customize the "CefSettings.root_cache_path" before calling CefInitialize()? OR
2. Implement CefBrowserProcessHandler::OnAlreadyRunningAppRelaunch() and set current_directory to customized path in it.
OR both?
linuxcef07
Techie
 
Posts: 34
Joined: Wed Dec 20, 2023 11:57 am

Re: Crash when cache_path and root_cache_path are not set

Postby magreenblatt » Wed Dec 20, 2023 1:44 pm

You should:

1. Customize the "CefSettings.root_cache_path" before calling CefInitialize() AND
2. Implement CefBrowserProcessHandler::OnAlreadyRunningAppRelaunch()

Your OnAlreadyRunningAppRelaunch implementation should take whatever action is appropriate for your application (for example, focus an existing browser or create a new browser). The arguments passed to OnAlreadyRunningAppRelaunch are read-only.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Crash when cache_path and root_cache_path are not set

Postby linuxcef07 » Thu Dec 21, 2023 6:59 am

Thanks, magreenblat for your reply.

As per https://cef-builds.spotifycdn.com/docs/121.0/classCefBrowserProcessHandler.html#a052a91639483467c0b546d57a05c2f06, OnAlreadyRunningAppRelaunch() needs to be implemented when an already running app is relaunched with the same CefSettings.root_cache_path value.

I am setting different directory path for root_cache_path (by appending current process id) before Initialise(). Now, I don’t see any issue after this code change.

So as per my understanding, I don’t need to override/implement OnAlreadyRunningAppRelaunch() method in my application. Can you please confirm?
linuxcef07
Techie
 
Posts: 34
Joined: Wed Dec 20, 2023 11:57 am

Re: Crash when cache_path and root_cache_path are not set

Postby magreenblatt » Thu Dec 21, 2023 10:19 am

I am setting different directory path for root_cache_path (by appending current process id) before Initialise(). Now, I don’t see any issue after this code change.

So as per my understanding, I don’t need to override/implement OnAlreadyRunningAppRelaunch() method in my application. Can you please confirm?

You do not need to implement OnAlreadyRunningAppRelaunch when using a unique root_cache_path value.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Crash when cache_path and root_cache_path are not set

Postby linuxcef07 » Thu Dec 21, 2023 11:45 am

Thanks magreenblatt for confirmation.
Just to add, the root cache directories (created by CEF) are not deleted by CEF after process termination. Assuming, this needs to be done from my app side, I will implement cleanup logic in my app. Thanks.
linuxcef07
Techie
 
Posts: 34
Joined: Wed Dec 20, 2023 11:57 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 207 guests

cron