fix: initialize CEF API version in cefsimple macOS helper

On macOS, CEF requires calling `cef_api_hash` immediately after
`cef_load_library` in both the main process and helper processes.
This initialization is necessary to ensure that CEF functions are
correctly configured and available before any other API calls.

Without this, calling CEF APIs such as `args.as_cmd_line()` which
invokes `cef_command_line_create` before `execute_process` results in
undefined behavior or crashes. This patch aligns the cef-rs' cefsimple
macOS helper with the official CEF C API implementation.

References:
- https://chromiumembedded.github.io/cef/using_the_capi#api-version-initialization
- https://github.com/chromiumembedded/cef/blob/5f93c2b090d19659451de4dfe44896ad7dbfd832/tests/cefsimple_capi/cefsimple_mac.m#L105-L107
This commit is contained in:
Takagi Tasuku committed 2026-02-02 19:11:41 +09:00
1 parent 2630d6352f
commit 3338bed393
1 file changed
+3
@@ -17,6 +17,9 @@ fn main() {
loader
};
// Initialize the CEF API version.
let _ = api_hash(sys::CEF_API_VERSION_LAST, 0);
execute_process(
Some(args.as_main_args()),
None::<&mut App>,