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

Web: transferControlToOffscreen() breaks calls to canvas #2733

Closed
daxpedda opened this issue Mar 13, 2023 · 0 comments · Fixed by #2778
Closed

Web: transferControlToOffscreen() breaks calls to canvas #2733

daxpedda opened this issue Mar 13, 2023 · 0 comments · Fixed by #2778
Labels

Comments

@daxpedda
Copy link
Member

daxpedda commented Mar 13, 2023

I am using transferControlToOffscreen() to draw in a different thread, which unfortunately invalidates any calls to width() and height().

This was not really an issue until now because I can simply avoid calling Window::set_inner_size(). But later I discovered that switching to fullscreen and changing the scale factor will trigger a call to width() and height() by Winit I can't prevent.

I have two proposals to fix this:

  • Detect the failure when calling HtmlCanvasElement::set_width() and just do nothing in that case. This is simple, but would require introducing custom wasm-bindgen imports because set_width() is not marked with #[catch]. This can't be fixed upstream because it's a breaking change.
  • Introduce a new method to WindowExtWebSys to actually call the transferControlToOffscreen() for the user, storing a flag somewhere that the canvas is now disconnected.

Happy to make a PR of course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants