Problem
On macOS with the Chromium/CEF renderer, cef_cookie_manager_t->set_cookie() consistently returns 0 (failure) regardless of timing. This affects both the global cookie manager and the browser request context cookie manager.
Root cause
CEF's external message loop mode (multi_threaded_message_loop = 0) does not properly initialize cookie store access via the C API. The cookie store is accessible internally (pages can read/write cookies via document.cookie), but the C API set_cookie, flush_store, and completion callbacks never work:
set_cookie() returns 0 ("cookies cannot be accessed")
flush_store() deadlocks when called from the main thread
- Completion callbacks passed to
get_cookie_manager() and flush_store() never fire
- These failures persist even after the browser has been running for minutes with pages loaded
Current workaround
Cookies are injected via JavaScript (document.cookie = "...") after page load, then the page is reloaded. See commit a98b733.
Limitations of workaround
- httpOnly cookies cannot be set via JS
- Requires a page load + reload cycle (two round trips)
- Only works for cookies matching the current page domain
Ideal fix
Either:
- Find the correct way to initialize CEF cookie access in external message loop mode
- Use CDP (Chrome DevTools Protocol) for cookie operations instead of the C API
- Wait for upstream CEF fix if this is a known issue
Environment
- CEF API version: 14600
- macOS, external message loop mode
--use-mock-keychain flag active
Problem
On macOS with the Chromium/CEF renderer,
cef_cookie_manager_t->set_cookie()consistently returns 0 (failure) regardless of timing. This affects both the global cookie manager and the browser request context cookie manager.Root cause
CEF's external message loop mode (
multi_threaded_message_loop = 0) does not properly initialize cookie store access via the C API. The cookie store is accessible internally (pages can read/write cookies viadocument.cookie), but the C APIset_cookie,flush_store, and completion callbacks never work:set_cookie()returns 0 ("cookies cannot be accessed")flush_store()deadlocks when called from the main threadget_cookie_manager()andflush_store()never fireCurrent workaround
Cookies are injected via JavaScript (
document.cookie = "...") after page load, then the page is reloaded. See commit a98b733.Limitations of workaround
Ideal fix
Either:
Environment
--use-mock-keychainflag active