Describe the bug
When CefRequestContext::CreateContext is used with a cache_path that is more than 1 level deep from the root_cache_path, the directory tree is created, but the cache is not saved.
ValidateCachePath in contect.cc correctly checks root_cache_path.IsParent(cache_path) (ie. parent or ancestor), but ChromeBrowserContext::InitializeAsync in chrome_browser_context.cc only checks cache_path_.DirName() == user_data_dir (ie. parent only).
Works correctly:
|
if (!root_cache_path.empty() && root_cache_path != cache_path && |
|
!root_cache_path.IsParent(cache_path)) { |
|
LOG(ERROR) << "The cache_path directory (" << cache_path.value() |
|
<< ") is not a child of the root_cache_path directory (" |
|
<< root_cache_path.value() << ")"; |
|
return false; |
|
} |
Behaves differently:
|
if (cache_path_ == user_data_dir) { |
|
// Use the default disk-based profile. |
|
auto profile = GetPrimaryUserProfile(); |
|
ProfileCreated(CreateStatus::kInitialized, profile); |
|
return; |
|
} else if (cache_path_.DirName() == user_data_dir) { |
|
// Create or load a specific disk-based profile. May continue |
|
// synchronously or asynchronously. |
If this is a Chrome-side limitation, then documentation should be updated to reflect the change in behaviour.
To Reproduce
- Initialise CEF with a
root_cache_path of C:/my_cef_data
- Initialise a
CefRequestContext with a cache_path of C:/my_cef_data/my_caches/cache_one
Expected behavior
The directories should be created if they don't exist, and the context's cache should be stored in the defined subdirectory, as long as it is an ancestor of the root.
If this value is non-empty then it must be an absolute path that is either equal to or a child directory of CefSettings.root_cache_path.
Source
Screenshots
N/A
Versions (please complete the following information):
- OS: Windows 10
- CEF Version: 136.1.5
Additional context
Does the problem reproduce with the cefclient or cefsimple sample application at the same version?
N/A
Does the problem reproduce with Google Chrome at the same version?
Unsure if this is a Chrome-side limitation .
OBS Studio with the Alloy Runtime has used a nested cache path for at least 5 years, and during testing of the Chrome Runtime we realised caches were not being saved. After experimentation, it was determined that while we set plugin_config\obs-browser as the root_cache_path, the request context's cache_path is 1 level too deep due to being in a subdirectory.
[78312:69704:0517/221241.630:ERROR:cef\libcef\browser\chrome\chrome_browser_context.cc:117] Cannot create profile at path C:\OBS\obs-studio\build_x64\rundir\RelWithDebInfo\config\obs-studio\plugin_config\obs-browser\obs_profile_cookies\C60F82022E73EDE3
As a temporary workaround, changing from obs_profile_cookies\ to obs_profile_cookies_ fixes the issue.
Reference documentation:
IsParent
https://github.com/chromium/chromium/blob/95770f62b3ab35bfde96945813ec4861060ba2f3/base/files/file_path.h#L243-L249
DirName
https://github.com/chromium/chromium/blob/95770f62b3ab35bfde96945813ec4861060ba2f3/base/files/file_path.h#L261-L267
Describe the bug
When
CefRequestContext::CreateContextis used with acache_paththat is more than 1 level deep from theroot_cache_path, the directory tree is created, but the cache is not saved.ValidateCachePathincontect.cccorrectly checksroot_cache_path.IsParent(cache_path)(ie. parent or ancestor), butChromeBrowserContext::InitializeAsyncinchrome_browser_context.cconly checkscache_path_.DirName() == user_data_dir(ie. parent only).Works correctly:
cef/libcef/browser/context.cc
Lines 155 to 161 in 7581264
Behaves differently:
cef/libcef/browser/chrome/chrome_browser_context.cc
Lines 98 to 105 in 7581264
If this is a Chrome-side limitation, then documentation should be updated to reflect the change in behaviour.
To Reproduce
root_cache_pathofC:/my_cef_dataCefRequestContextwith acache_pathofC:/my_cef_data/my_caches/cache_oneExpected behavior
The directories should be created if they don't exist, and the context's cache should be stored in the defined subdirectory, as long as it is an ancestor of the root.
Screenshots
N/A
Versions (please complete the following information):
Additional context
Does the problem reproduce with the cefclient or cefsimple sample application at the same version?
N/A
Does the problem reproduce with Google Chrome at the same version?
Unsure if this is a Chrome-side limitation .
OBS Studio with the Alloy Runtime has used a nested cache path for at least 5 years, and during testing of the Chrome Runtime we realised caches were not being saved. After experimentation, it was determined that while we set
plugin_config\obs-browseras theroot_cache_path, the request context'scache_pathis 1 level too deep due to being in a subdirectory.As a temporary workaround, changing from
obs_profile_cookies\toobs_profile_cookies_fixes the issue.Reference documentation:
IsParenthttps://github.com/chromium/chromium/blob/95770f62b3ab35bfde96945813ec4861060ba2f3/base/files/file_path.h#L243-L249
DirNamehttps://github.com/chromium/chromium/blob/95770f62b3ab35bfde96945813ec4861060ba2f3/base/files/file_path.h#L261-L267