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
Describe the bug
The "print to PDF" callback (CefPdfPrintCallback::OnPdfPrintFinished) is not called in case of internal errors in the Chromium / CEF. The reason is that code in print_util.cc passes down an empty path string in case of an internal error - which causes an early return in the generated C-to-C++ code (pdf_print_callback_ctocpp.cc file) before the callback is invoked.
This may lead a hang-up in case an application waits for the result of the CefBrowserHost::PrintToPDF operation.
To Reproduce
We ran into this issue when accidentally passing down the --headless flag to the CEF code, which led to a hang-up in our application. Unfortunately, this is not reproducible by CEF samples.
Expected behavior
The callback should be invoked in any case to indicate the caller the state of the print to PDF operation.
Versions (please complete the following information):
OS: Any (tested on Windows 11)
CEF Version: 130
Additional context
The generated code responsible for invoking the callback:
NO_SANITIZE("cfi-icall") void CefPdfPrintCallback_0_CToCpp::OnPdfPrintFinished(const CefString& path, bool ok) {
shutdown_checker::AssertNotShutdown();
auto* _struct = GetStruct();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING// !!! This causes exit for any invocation in style: callback->OnPdfPrintFinished(CefString(), false) !!!// Verify param: path; type: string_byref_constDCHECK(!path.empty());
if (path.empty()) {
return;
}
// Execute
_struct->on_pdf_print_finished(_struct,
path.GetStruct(),
ok);
}
A simplest fix seems to be to make the path callback parameter optional to avoid its verification. Another way might be to repurpose the parameter to contain an error message in case the ok parameter is false, but I'm personally not a fan of using a single parameter for two distinct purposes...
The text was updated successfully, but these errors were encountered:
magreenblatt
changed the title
PDF print callback is not ivoked in case of an internal error
PDF print callback is not invoked in case of an internal error
Feb 11, 2025
Describe the bug
The "print to PDF" callback (
CefPdfPrintCallback::OnPdfPrintFinished
) is not called in case of internal errors in the Chromium / CEF. The reason is that code in print_util.cc passes down an empty path string in case of an internal error - which causes an early return in the generated C-to-C++ code (pdf_print_callback_ctocpp.cc
file) before the callback is invoked.This may lead a hang-up in case an application waits for the result of the
CefBrowserHost::PrintToPDF
operation.To Reproduce
We ran into this issue when accidentally passing down the
--headless
flag to the CEF code, which led to a hang-up in our application. Unfortunately, this is not reproducible by CEF samples.Expected behavior
The callback should be invoked in any case to indicate the caller the state of the print to PDF operation.
Versions (please complete the following information):
Additional context
The generated code responsible for invoking the callback:
A simplest fix seems to be to make the
path
callback parameter optional to avoid its verification. Another way might be to repurpose the parameter to contain an error message in case theok
parameter isfalse
, but I'm personally not a fan of using a single parameter for two distinct purposes...The text was updated successfully, but these errors were encountered: