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

fix: log postmessage errors #1426

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/postmessage-assert-panic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wry": "patch"
---

On Windows, Wry will now log PostMessage errors instead of panicking.
19 changes: 14 additions & 5 deletions src/webview2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1040,11 +1040,20 @@ impl InnerWebView {

let raw = Box::into_raw(boxed2);

let res = PostMessageW(hwnd, *EXEC_MSG_ID, WPARAM(raw as _), LPARAM(0));
assert!(
res.is_ok(),
"PostMessage failed ; is the messages queue full?"
);
let _res = PostMessageW(hwnd, *EXEC_MSG_ID, WPARAM(raw as _), LPARAM(0));

#[cfg(any(debug_assertions, feature = "tracing"))]
if let Err(err) = _res {
let msg = format!(
"PostMessage failed ; is the messages queue full? Error code {} - {}",
err.code(),
err.message()
);
#[cfg(feature = "tracing")]
tracing::error!("{}", &msg);
#[cfg(debug_assertions)]
eprintln!("{}", msg);
}
}

unsafe extern "system" fn main_thread_dispatcher_proc(
Expand Down