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

[bug] PostMessage failed ; is the messages queue full? #10546

Open
Fly-Potato opened this issue Aug 9, 2024 · 28 comments
Open

[bug] PostMessage failed ; is the messages queue full? #10546

Fly-Potato opened this issue Aug 9, 2024 · 28 comments
Labels
platform: Windows status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@Fly-Potato
Copy link

Describe the bug

PanicInfo { payload: Any { .. }, message: Some(PostMessage failed ; is the messages queue full?), location: Location { file: "C:\Users\Potato\.cargo\registry\src\mirrors.aliyun.com-8754fae0eb2f08f1\wry-0.41.0\src\webview2\mod.rs", line: 974, col: 5 }, can_unwind: true, force_no_backtrace: false }

Reproduction

No response

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.26100 X64
    ✔ WebView2: 126.0.2592.113
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.80.0 (051478957 2024-07-21)
    ✔ cargo: 1.80.0 (376290515 2024-07-16)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.12.0
    - pnpm: 9.1.3
    - yarn: 1.22.22
    - npm: 10.8.2

[-] Packages
    - tauri [RUST]: 2.0.0-rc.1
    - tauri-build [RUST]: 2.0.0-rc.1
    - wry [RUST]: 0.41.0
    - tao [RUST]: 0.28.1
    - @tauri-apps/api [NPM]: 2.0.0-rc.0
    - @tauri-apps/cli [NPM]: 2.0.0-rc.2

[-] App
    - build-type: bundle
    - CSP: img-src 'self' asset: http://asset.localhost blob: data:; style-src 'unsafe-inline' 'self' asset: http://asset.localhost blob: data:; connect-src ipc: http://ipc.localhost; default-src 'self'; media-src 'self' asset: http://asset.localhost blob: data:
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: React
    - bundler: Vite

Stack trace

No response

Additional context

No response

@Fly-Potato Fly-Potato added status: needs triage This issue needs to triage, applied to new issues type: bug labels Aug 9, 2024
@Fly-Potato
Copy link
Author

What is this problem?

@Fly-Potato Fly-Potato changed the title [bug] Some(PostMessage failed ; is the messages queue full?) [bug] PostMessage failed ; is the messages queue full? Aug 9, 2024
@Fly-Potato
Copy link
Author

This problem often occurs

@FabianLars
Copy link
Member

Do you have a minimal reproduction example for us? If not, something not-minimal is okay too, but we need something to work on since you're the first one to report this.

@Fly-Potato
Copy link
Author

Fly-Potato commented Aug 12, 2024

This issue mostly occurs when using tauri SQL and http plugins, But the frequency of occurrence is very low, Is it because the interaction between JS and Rust is too frequent?

@Fly-Potato
Copy link
Author

PanicInfo { payload: Any { .. }, message: Some(called Result::unwrap() on an Err value: OsError { line: 1094, file: "C:\Users\Potato\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.28.1\src\platform_impl\windows\window.rs", error: IoError(Os { code: 1400, kind: Uncategorized, message: "无效的窗口句柄。" }) }), location: Location { file: "C:\Users\Potato\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tauri-runtime-wry-2.0.0-rc.2\src/lib.rs", line: 3755, col: 55 }, can_unwind: true, force_no_backtrace: false }

the new error

@greenhat616
Copy link

greenhat616 commented Sep 10, 2024

Same issue here. It should be occurred frequentlly while close window in dev mode.

Any solutions could be shared here?

@Fly-Potato
Copy link
Author

I haven't found any solution

@Fly-Potato
Copy link
Author

#10893

@greenhat616
Copy link

greenhat616 commented Sep 12, 2024

@FabianLars Maybe we could modify the the assert! to log::error!(), intended to prevent the program panic? Or is it possible to use a backoff strategy to retry it? backon crate etc.

#[inline]
  unsafe fn dispatch_handler<F>(hwnd: HWND, function: F)
  where
    F: FnMut() + 'static,
  {
    // We double-box because the first box is a fat pointer.
    let boxed = Box::new(function) as Box<dyn FnMut()>;
    let boxed2: Box<Box<dyn FnMut()>> = Box::new(boxed);

    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?"
    );
  }

And I see this dispatcher should call when current thread is not the main thread. If I create the webview window in app_handle.run_on_main_thread() and it could avoid this issue?

@FabianLars
Copy link
Member

And I see this dispatcher should call when current thread is not the main thread. If I create the webview window in app_handle.run_on_main_thread() and it could avoid this issue?

Tauri should take care of the thread requirements internally already.

Maybe we could modify the the assert! to log::error!()

Yeah, that sounds reasonable - @lucasfernog ?

Or is it possible to use a backoff strategy to retry it? backon crate etc.

hmm, idk i personally would prefer to try to prevent these before looking into some retry mechanism but don't have any hard feelings about it.

@greenhat616
Copy link

@FabianLars @lucasfernog
Has there been any breakthrough on this issue? We're receiving increasingly frequent feedback from users about it. The problem tends to occur shortly after a webview window is closed. I suspect it might be due to ongoing IPC operations being sent to the window during its closure.

We may have to manually catch this crash using panic::take_hook, and then display an option to ignore the error.

@wonfen
Copy link

wonfen commented Oct 7, 2024

@FabianLars @lucasfernog @amrbashir
Tons of feedback on our project, any ideas how to fix it?
clash-verge-rev/clash-verge-rev#1779
clash-verge-rev/clash-verge-rev#1774
clash-verge-rev/clash-verge-rev#1784

any clues from the stack trace? #11120

@greenhat616
Copy link

@wonfen It seem that Tauri do not impl cancelable ipc or send barrier(block ipc while the window is closing), and it just panic while ipc is failed -- That's why the ignore in panic hook is useful.

@wonfen
Copy link

wonfen commented Oct 8, 2024

@wonfen It seem that Tauri do not impl cancelable ipc or send barrier(block ipc while the window is closing), and it just panic while ipc is failed -- That's why the ignore in panic hook is useful.

But the process is still crashed after ignore the panic? I don't know what else we can do in our end.

@greenhat616
Copy link

greenhat616 commented Oct 8, 2024

@wonfen It seem that Tauri do not impl cancelable ipc or send barrier(block ipc while the window is closing), and it just panic while ipc is failed -- That's why the ignore in panic hook is useful.

But the process is still crashed after ignore the panic? I don't know what else we can do in our end.

Are you using the panic = "abort"?

In this way, the program will exit immediately after hook executed, and there is no chance for cleanup logic defined in Drop trait.

You'd better use the panic = "unwind" instead.

Here is a dialogue describing the behavior of panic. https://zhuanlan.zhihu.com/p/687092686

@wonfen
Copy link

wonfen commented Oct 8, 2024

Are you using the panic = "abort"?

In this way, the program will exit immediately after hook executed, and there is no chance for cleanup logic defined in Drop trait.

You'd better use the panic = "unwind" instead.

Here is a dialogue describing the behavior of panic. https://zhuanlan.zhihu.com/p/687092686

I got what you mean, you’re saying that we can use a panic hook to help identify the cause of a panic, but it doesn’t directly solve the panic itself.

@wonfen
Copy link

wonfen commented Oct 13, 2024

Hi @FabianLars @lucasfernog
is there anything I can do in our end?

@lvfch
Copy link

lvfch commented Oct 21, 2024

Is there any progress on this issue? I also frequently encounter this problem in my project

@Fly-Potato
Copy link
Author

Fly-Potato commented Oct 25, 2024

@FabianLars @lucasfernog @amrbashir Can this issue be fixed as soon as possible

@wonfen
Copy link

wonfen commented Oct 27, 2024

@FabianLars @lucasfernog @amrbashir
Is there any additional information or resources we can provide beyond the Stack trace in #11120 to assist with resolving this bug?
Our app serves over 1 million users, so a timely resolution would have a significant positive impact.

@amrbashir
Copy link
Member

amrbashir commented Oct 28, 2024

@wonfen do you have a minimal reproducible example I can test with? or steps to reproduce.

@aramrw
Copy link

aramrw commented Oct 28, 2024

I just wanted to confirm that I get this same error. So far it doesn't actually seem like it causes any problems but I will trace my code and update if I find out where it happens.

@Fly-Potato
Copy link
Author

@amrbashir please look at #10893

@amrbashir
Copy link
Member

@Fly-Potato that's not the same issue and the blocking of open function from shell plugin has been fixed in tauri-apps/plugins-workspace#1881

@Fly-Potato
Copy link
Author

@amrbashir Okay, the above problem probably occurs in multi window situations. After the current window processes the data, it sends multiple events to the main window. The main window receives the message and performs further processing. At this time, it will concurrently call the HTTP plugin, causing the main process to freeze

@amrbashir
Copy link
Member

I am not sure how the freezing is related to this issue, I am specifically asking for repro about PostMessage failed; is the messages queue full

@oomeow
Copy link

oomeow commented Nov 3, 2024

@amrbashir I reproduced the issue in my repo tauri-app, this is a simple tauri app example.
Execution steps: Click the Greet button -> Close the window immediately
then the problem will appear

oomeow added a commit to oomeow/clash-verge-self that referenced this issue Nov 12, 2024
ref: tauri-apps/tauri#10546
This problem only occurs in windows
oomeow added a commit to oomeow/clash-verge-self that referenced this issue Nov 12, 2024
ref: tauri-apps/tauri#10546
This problem only occurs in windows

fix: update panic strategy
@lvfch
Copy link

lvfch commented Nov 23, 2024

Still not solved? I'm ready to give up on using tauri. The community is too inactive and the problem solving is so slow. I'm going to switch to a more stable framework.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: Windows status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

8 participants