You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cookies created when using Alloy bootstrap not available when switching to Chrome bootstrapΒ #3721
I'm using CEF via the downstream project CefSharp which had previously used the Alloy bootstrap but is switching to the Chrome bootstrap by default in v126. As a result of this, cookies that existed prior to switching are no longer available.
To Reproduce
Steps to reproduce the behavior:
Initialize CEF using Alloy bootstrap with a clean cache_path
Create a cookie (or visit site that sets a cookie)
Restart CEF now using Chrome bootstrap with same cache_path
No cookies exist
Expected behavior
Either cookies available by default after switching to use Chrome bootstrap or an option provided to migrate them from Alloy to Chrome.
It was suggested by another user on the CefSharp issue that it is due to the Chrome bootstrap using an encryption key that is stored in the Local State file, but the Alloy bootstrap uses a key from LocalPrefs.json
We don't plan to migrate cache directories automatically. CEF doesn't know what Profile-specific directory you were using previously, and not all files/directories are applicable between Chrome and Alloy bootstraps.
Your application can copy some files before calling CefInitialize. For example, it's fine to copy the Local Storage and Session Storage folders between Alloy and Chrome cache directories.
I have not tried copying Cookies or Cookies-journal files. Both Local State and LocalPrefs.json are JSON files, so you can copy values between them as needed (and test/verify that it works as you expect).
We don't plan to migrate cache directories automatically. CEF doesn't know what Profile-specific directory you were using previously, and not all files/directories are applicable between Chrome and Alloy bootstraps.
I am using the same cache_path that I used for the Alloy bootstrap when switching to the Chrome bootstrap. I don't need chromium to detect and auto migrate, I'm happy to be explicit and provide whatever information is required to migrate the cookies.
I have tried copying the Local Storage, Session Storage and Network folders to a sub folder called Default which appears to be where the ChromeBootstrap would create these folders and then copied the "os_crypt" block that contains and "encrypted_key" field from the LocalPrefs.json file created by the AlloyBootstrap to the "Local State" file created by the Chrome bootstrap but that was not enough. Is there somewhere that I can reference to better understand the folder structure differences between the two?
Even with log level at Verbose the log file does not indicate a problem loading the cookies :(
copied the "os_crypt" block that contains and "encrypted_key" field from the LocalPrefs.json file created by the AlloyBootstrap to the "Local State" file created by the Chrome bootstrap but that was not enough
It might be better to extract the cookies using the CefCookieManager API while running with the Alloy bootstrap, and then use the same API to import the cookies after restarting (or installing the new app version) with the Chrome bootstrap.
Is there somewhere that I can reference to better understand the folder structure differences between the two?
It's probably easiest just to run cefclient with Alloy (--disable-chrome-runtime) and Chrome bootstraps with different --cache-path values, and compare the resulting directory structures. Many of the contents will be the same, with Chrome creating some additional files and folders. As you've noticed, Chrome uses a "Default" subdirectory under cache-path whereas Alloy writes everything in the cache-path directory.
It might be better to extract the cookies using the CefCookieManager API while running with the Alloy bootstrap, and then use the same API to import the cookies after restarting (or installing the new app version) with the Chrome bootstrap.
I considered that but I wanted it to be transparent to the user and due to the restriction of only being able to initialise CEF once per process I decided to explore other options first.
Anyway, I've made some progress. Not sure what I had done before that did not work but I was able to migrate my cookies this time by doing the following:
Run the Alloy bootstrap and ensure some cookies exist
Create a Default directory in the cache_path folder
Copy the Local Storage, Session Storage and Network folders to the sub folder Default (maybe should copy some other folders too, have not investigated further yet)
rename LocalPrefs.json in cache_path to Local State (this is essentially setting up the correct os_crypt.encrypted_key value that can be used to decrypt the cookie values)
Activity
magreenblatt commentedon Jun 24, 2024
We don't plan to migrate cache directories automatically. CEF doesn't know what Profile-specific directory you were using previously, and not all files/directories are applicable between Chrome and Alloy bootstraps.
Your application can copy some files before calling CefInitialize. For example, it's fine to copy the
Local StorageandSession Storagefolders between Alloy and Chrome cache directories.I have not tried copying
CookiesorCookies-journalfiles. BothLocal StateandLocalPrefs.jsonare JSON files, so you can copy values between them as needed (and test/verify that it works as you expect).EamonHetherton commentedon Jun 24, 2024
I am using the same cache_path that I used for the Alloy bootstrap when switching to the Chrome bootstrap. I don't need chromium to detect and auto migrate, I'm happy to be explicit and provide whatever information is required to migrate the cookies.
I have tried copying the
Local Storage,Session StorageandNetworkfolders to a sub folder calledDefaultwhich appears to be where the ChromeBootstrap would create these folders and then copied the "os_crypt" block that contains and "encrypted_key" field from the LocalPrefs.json file created by the AlloyBootstrap to the "Local State" file created by the Chrome bootstrap but that was not enough. Is there somewhere that I can reference to better understand the folder structure differences between the two?Even with log level at Verbose the log file does not indicate a problem loading the cookies :(
magreenblatt commentedon Jun 24, 2024
It might be better to extract the cookies using the CefCookieManager API while running with the Alloy bootstrap, and then use the same API to import the cookies after restarting (or installing the new app version) with the Chrome bootstrap.
It's probably easiest just to run cefclient with Alloy (
--disable-chrome-runtime) and Chrome bootstraps with different--cache-pathvalues, and compare the resulting directory structures. Many of the contents will be the same, with Chrome creating some additional files and folders. As you've noticed, Chrome uses a "Default" subdirectory under cache-path whereas Alloy writes everything in the cache-path directory.EamonHetherton commentedon Jun 25, 2024
I considered that but I wanted it to be transparent to the user and due to the restriction of only being able to initialise CEF once per process I decided to explore other options first.
Anyway, I've made some progress. Not sure what I had done before that did not work but I was able to migrate my cookies this time by doing the following:
Defaultdirectory in the cache_path folderLocal Storage,Session StorageandNetworkfolders to the sub folderDefault(maybe should copy some other folders too, have not investigated further yet)LocalPrefs.jsonin cache_path toLocal State(this is essentially setting up the correct os_crypt.encrypted_key value that can be used to decrypt the cookie values)