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

Let Window::inner_size() return None if the Window isn't "ready" yet #2863

Open
daxpedda opened this issue Jun 9, 2023 · 2 comments
Open
Assignees
Labels
C - needs discussion Direction must be ironed out S - enhancement Wouldn't this be the coolest?

Comments

@daxpedda
Copy link
Member

daxpedda commented Jun 9, 2023

I've heard this come up many times before, but when using Winit to render stuff, users often have to check for the window size not to be zero.

I've encountered this before in X11, but I don't know the story behind this on other backends. For Wasm, it's easy to hit this problem at application startup, where the canvas isn't even inserted yet into the DOM, where it makes perfect sense to return None in Window::inner_size(). See #2859 (comment) which spawned this issue.

@daxpedda daxpedda added S - enhancement Wouldn't this be the coolest? DS - web C - needs discussion Direction must be ironed out labels Jun 9, 2023
@daxpedda daxpedda self-assigned this Jun 9, 2023
@daxpedda daxpedda removed the DS - web label Jun 9, 2023
@kchibisov
Copy link
Member

This is more general issue of async window startup, we have similar problem on Wayland, which is solved right now by dispatching event loop and waiting for the events to complete.

@rib do you happen to remember what the conclusion for stuff like that was? I think we need a way for window to be created async.

My initial idea would be to have normal constructor for that which will return not a window, but WindowId, as it'll reserve the slot for window in the backends internal map with unique ids, so the user will have a target for events and a place in the hash map, and the actual window will be received as part of some event so they insert into vacant slot in the map/whatever they use?

@mcclure
Copy link

mcclure commented Jul 17, 2024

Just to note, I filed a dupe of this bug in 2023, and I am still experiencing the problem (in the form of my program often being unable to run in wasm if I don't include protective code for the nonsense case of a 0,0 window) as of 0.30.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C - needs discussion Direction must be ironed out S - enhancement Wouldn't this be the coolest?
Development

No branches or pull requests

3 participants