-
Notifications
You must be signed in to change notification settings - Fork 272
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
Windowing chapter won’t work on some platforms #532
Comments
I'm pretty sure that you can't use |
Yeah, you’re totally right. I had mis-copied some code from another project. I think spawning a future on the resumed event (using wasm bindgen futures or a native executor or using the event loop itself to poll the future) which writes into a oncecell is one good option. It’s really a pain that creating the surface must happen after the resumed event, and that sometimes creating an adapter without providing a surface causes issues too. If it weren’t for the latter you could make the adapter before entering the event loop, and lazily create the surface. But that can get you the wrong adapter sometimes. |
I'm going to have to circle back to this. I'm working on updating to 0.19 and they changed |
I think if your Window is an Arc, the surface gets a ‘static lifetime and is easier to work with. |
According to winit’s developers, it’s not permitted to create a surface on many platforms (Mac and android for example) until the Event::Resumed winit event is posted. This is a bummer because it means you need a mini state machine (I like to use an enum for this) to determine what phase in the initialization life cycle you’re in and you probably need a future executed for its side effect on web which means you need a OnceCell or something :/
I solved this a couple different ways in my modular renderer:
The async block could instead just cover the WGPU initialization.
The text was updated successfully, but these errors were encountered: