Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF print callback is not invoked in case of an internal error #3879

Open
dcernoch-up opened this issue Feb 6, 2025 · 0 comments
Open

PDF print callback is not invoked in case of an internal error #3879

dcernoch-up opened this issue Feb 6, 2025 · 0 comments
Labels
bug Bug report

Comments

@dcernoch-up
Copy link
Contributor

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_const
  DCHECK(!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...

@dcernoch-up dcernoch-up added the bug Bug report label Feb 6, 2025
@magreenblatt 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report
Projects
None yet
Development

No branches or pull requests

1 participant