Skip to content

CEF C API set_cookie broken in external message loop mode #6

@rafiki270

Description

@rafiki270

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:

  1. Find the correct way to initialize CEF cookie access in external message loop mode
  2. Use CDP (Chrome DevTools Protocol) for cookie operations instead of the C API
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions