Skip to content

Commit

Permalink
fix: log postmessage errors (#1426)
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianLars authored Dec 31, 2024
1 parent 4740c0b commit b4ba5b4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
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

0 comments on commit b4ba5b4

Please sign in to comment.