chromiumembedded / cef

Chromium Embedded Framework (CEF). A simple framework for embedding Chromium-based browsers in other applications.
https://bitbucket.org/chromiumembedded/cef/
Other
3.27k stars 457 forks source link

alloy: Crash when loading an editable PDF #3644

Closed awarkw closed 7 months ago

awarkw commented 7 months ago

This issue may not have anything to do with the fact that the PDF is editable. There is also a dialog that shows after PDF loads, which may be the real cause of the crash.

Even the latest CEF client (below) crashes. All that's needed to reproduce it is the URL: https://www.agenciatributaria.es/static_files/Sede/Procedimiento_ayuda/G603/mod145_es_es.pdf

cef_binary_122.0.5+g1bfee76+chromium-122.0.6261.18_windows32_beta_client

[0207/162622.557:WARNING:frame_impl.cc(427)] SendProcessMessage sent to detached frame 6-E5DA32DBFA2E444DBDCBA167440405BF will be ignored [0207/162622.725:INFO:CONSOLE(0)] "Unchecked runtime.lastError: Not implemented", source: chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html (0)

rocknowradio commented 7 months ago

It crashes in alloy mode, not in chrome runtime mode. I suspect a some form of delegate is not implemented (as the Not implemented message says), similar with the missing filesystem delegate I reported some time ago.

magreenblatt commented 7 months ago

Something is trying to show a JavaScript alert() (alert_message="枀换ǀ") when loading this PDF. GetTabModalDialogManager is returning nullptr in CefJavaScriptDialogManager::RunJavaScriptDialog.

Call stack:

>   libcef.dll!CefJavaScriptDialogManager::RunJavaScriptDialog(content::WebContents * web_contents, content::RenderFrameHost * render_frame_host, content::JavaScriptDialogType message_type, const std::__Cr::basic_string<char16_t,std::__Cr::char_traits<char16_t>,std::__Cr::allocator<char16_t>> & message_text, const std::__Cr::basic_string<char16_t,std::__Cr::char_traits<char16_t>,std::__Cr::allocator<char16_t>> & default_prompt_text, base::OnceCallback<void (bool, const std::__Cr::basic_string<char16_t,std::__Cr::char_traits<char16_t>,std::__Cr::allocator<char16_t>> &)> callback, bool * did_suppress_message) Line 155 C++
    content.dll!content::WebContentsImpl::RunJavaScriptDialog(content::RenderFrameHostImpl * render_frame_host, const std::__Cr::basic_string<char16_t,std::__Cr::char_traits<char16_t>,std::__Cr::allocator<char16_t>> & message, const std::__Cr::basic_string<char16_t,std::__Cr::char_traits<char16_t>,std::__Cr::allocator<char16_t>> & default_prompt, content::JavaScriptDialogType dialog_type, bool disable_third_party_subframe_suppresion, base::OnceCallback<void (bool, const std::__Cr::basic_string<char16_t,std::__Cr::char_traits<char16_t>,std::__Cr::allocator<char16_t>> &)> response_callback) Line 7720   C++
    content.dll!content::RenderFrameHostImpl::RunJavaScriptDialog(const std::__Cr::basic_string<char16_t,std::__Cr::char_traits<char16_t>,std::__Cr::allocator<char16_t>> & message, const std::__Cr::basic_string<char16_t,std::__Cr::char_traits<char16_t>,std::__Cr::allocator<char16_t>> & default_prompt, content::JavaScriptDialogType dialog_type, bool disable_third_party_subframe_suppresion, base::OnceCallback<void (bool, const std::__Cr::basic_string<char16_t,std::__Cr::char_traits<char16_t>,std::__Cr::allocator<char16_t>> &)> ipc_response_callback) Line 5677 C++
    content.dll!content::RenderFrameHostImpl::RunModalAlertDialog(const std::__Cr::basic_string<char16_t,std::__Cr::char_traits<char16_t>,std::__Cr::allocator<char16_t>> & alert_message, bool disable_third_party_subframe_suppresion, base::OnceCallback<void ()> response_callback) Line 5622   C++
abid76 commented 7 months ago

I had the same issue in CefSharp. The browser crashes when there is no JSDialogHandler implemented. The dialog is triggered by a PDF XFA form. Implementing a JSDialogHandler did solve the problem. This should also apply to CEF as CefSharp is just a wrapper of CEF.

This issue seems to be related to https://github.com/cefsharp/CefSharp/issues/4701 which is about PDF with an XFA form. In the linked issue the browser crashes when it is closed.

rocknowradio commented 7 months ago

I have encountered in the past several crashes (never reproduced, and from the minidumps I could not deduce the URL). My solution was to patch CefJavaScriptDialogManager::RunJavaScriptDialog as (pasting crudely here, but is pretty clear)

  if (!CanUseChromeDialogs()) {
    // Dismiss the dialog.
    std::move(callback).Run(false, std::u16string());
    return;
  }

  auto manager = GetTabModalDialogManager(web_contents);
+ if (!manager) {
+   std::move(callback).Run(false, std::u16string());
+   return;
+ }
  manager->RunJavaScriptDialog(web_contents, render_frame_host, message_type,
                               message_text, default_prompt_text,
                               std::move(callback), did_suppress_message);
}

Edit: also RunBeforeUnloadDialog suffers from the same issue, I suppose, where GetTabModalDialogManager returns nullptr. As well as HandleJavaScriptDialog, CancelDialogs.