rust-windowing / winit

Window handling library in pure Rust

Home Page:https://docs.rs/winit/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

On web, opening the print dialog (File > Print...) panics

Maximetinu opened this issue · comments

This debug_assert! is hit when opening the browser's print dialog

Steps to reproduce

  • Open any simple web app that uses Winit. For example, a Bevy game (can be reproduced in Bevy's examples, like here: https://bevyengine.org/examples/2D%20Rendering/move-sprite/)
  • Open the print dialog of the browser. In Google Chrome, it is File > Print... or pressing Ctrl+P or Cmd+P
  • Alternatively, you can call print() in the JS console

Expected behaviour

Printing the pixels of canvas, inside the web, at the exact moment of opening the Print dialog, would be ideal. In fact, it's the current behaviour (+ the panic).

It'd be preferable to not show the canvas at all, or to show it as black, rather than crashing.

Actual behaviour

Printing the current frame kind of works:

image

But then, it panics with the following stack trace:

image

Duplicate of #3457.

Personally I can't reproduce this, but the reality is that this is almost certainly a browser bug. Its not relevant for production code because it is only a debug_assert! after all.

I'm unsure how to proceed here really, ideally I would be able to reproduce this so I can report the bug in Chrome (or find out that it is an issue on our end).

Alternatively, to figure out exactly how we could implement a workaround for Winit here, by accounting for this to not work, a reproduction would be required as well.

Let me know if you have additional information or if you are able to boil it down to a more minimal example (one without Bevy).

Since you couldn't repro, I tried in another browser, Firefox, and it doesn't panic in it. It does in Safari. That smells like it's a bug in Chrome indeed

Just one question:

Personally I can't reproduce this

You mean, in a minimal winit example of your own? Or not even in that Bevy example that I linked? Which browser did you try?

Personally I can't reproduce this

You mean, in a minimal winit example of your own? Or not even in that Bevy example that I linked? Which browser did you try?

I tried the Bevy example you linked, which is pretty broken because it doesn't include #3553, a minimal Bevy example and the Winit example. I tried Chrome and Firefox on Linux. Also tried to zoom in before hitting opening the print dialog to at least pretend like my scale factor isn't 1.

Cool, thx for the details! 🙏