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 1 commit
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.
13 changes: 9 additions & 4 deletions src/webview2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1041,10 +1041,15 @@ 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?"
);

#[cfg(any(debug_assertions, feature = "tracing"))]
if res.is_err() {
let error_code = windows::Win32::Foundation::GetLastError();
#[cfg(feature = "tracing")]
tracing::error!("PostMessage failed ; is the messages queue full? Error code {error_code:?}");
#[cfg(debug_assertions)]
eprintln!("PostMessage failed ; is the messages queue full? {error_code:?}");
}
}
FabianLars marked this conversation as resolved.
Show resolved Hide resolved

unsafe extern "system" fn main_thread_dispatcher_proc(
Expand Down