BorjaPascual wrote:
Hi! The crash happens at CefBrowserHost::CreateBrowser, when I call CefInitialize. Since it seems to work like some sort of black box, I didn't know I could choose to call the browser in a different way. How can it be done?
Okay I thought you were calling the Sync version. You can check the documentation here
https://magpcss.org/ceforum/apidocs/projects/(default)/CefBrowser.html#CreateBrowser(CefWindowInfo&,CefRefPtr%3CCefClient%3E,constCefString&,constCefBrowserSettings&).
The main difference is that Sync version will block and return the created browser, while the other one will not block and you will be able to get the created browser in the CefLifeSpanHandler that you provide if I am not mistaken.
This is the code of CreateBrowser, you see that there is a few checks at the start of the function, so any of those might be triggered in your case. Can you not load the symbols or check if there is some logging to know what exactly is the error in cef_browser_host_create_browser?
Did you call CefInitialize before creating the browser?
- Code: Select all
// static
bool CefBrowserHost::CreateBrowser(
const CefWindowInfo& windowInfo,
CefRefPtr<CefClient> client,
const CefString& url,
const CefBrowserSettings& settings,
CefRefPtr<CefDictionaryValue> extra_info,
CefRefPtr<CefRequestContext> request_context) {
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
// Verify that the settings structure is a valid size.
if (settings.size != sizeof(cef_browser_settings_t)) {
NOTREACHED() << "invalid CefBrowserSettings structure size";
return false;
}
// Verify windowless rendering requirements.
if (windowInfo.windowless_rendering_enabled &&
!client->GetRenderHandler().get()) {
NOTREACHED() << "CefRenderHandler implementation is required";
return false;
}
if (windowInfo.windowless_rendering_enabled &&
!CefContext::Get()->settings().windowless_rendering_enabled) {
LOG(ERROR) << "Creating a windowless browser without setting "
"CefSettings.windowless_rendering_enabled may result in "
"reduced performance or runtime errors.";
}
if (!request_context) {
request_context = CefRequestContext::GetGlobalContext();
}
auto helper = std::make_unique<CreateBrowserHelper>(
windowInfo, client, url, settings, extra_info, request_context);
auto request_context_impl =
static_cast<CefRequestContextImpl*>(request_context.get());
// Wait for the browser context to be initialized before creating the browser.
request_context_impl->ExecuteWhenBrowserContextInitialized(base::BindOnce(
[](std::unique_ptr<CreateBrowserHelper> helper) {
// Always execute asynchronously to avoid potential issues if we're
// being called synchronously during app initialization.
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CreateBrowserHelper::Run,
std::move(helper)));
},
std::move(helper)));
return true;
}