-
Notifications
You must be signed in to change notification settings - Fork 913
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
Expose winit::platform::emscripten::set_main_loop_callback
#814
Comments
Thanks for the issue! The However, work is ongoing to address your API concerns! @ryanisaacg has been doing great working getting a WASM backend going with the new event loop API through You can check out the API docs for the new API here, and I believe that addresses your issue; you can get periodically woken up for rendering with the new |
Sounds good, perhaps we should close this issue in favor of eventloop 2.0? I’m happy to take a stab at X11 (I don’t have a Linux box, but that’s what VMs are for, I suppose), especially if your Windows PR can be used as a reference. |
@vberger you mentioned that you might be doing the X11 backend in this comment - has that gone anywhere yet? If that work hasn't started, @tangmi you should be good to go. Thanks for the offer! |
I haven't started yet, I was thinking aybe getting at it in the coming days, though if you want to try & tackle it @tangmi , please do. Just be aware that the x11 code is very different from the Windows code, and it also currently contains a lot of work-arounds to compensate for X11 gotchas... |
Thanks for the heads up. I'll take a look at it, although no promises yet (ran into issues trying to install a linux system...). |
Hey @tangmi, are you still working on X11 support? How far did you get? |
Unfortunately no real progress. I don't have a linux machine or any machine powerful enough to reasonably run a VM :(. I ended up finding emscripten-specific workarounds to make my project work. |
Hi, it seems the only way to use
winit
on WASM is to useEventLoop::run_forever
, which doesn't seem to give the user an opportunity to do work (e.g. render) if no events have come through. Doing the normalloop { events_loop.poll_events(/* ... */) }
seems to cause the tab to hang, since we're not getting that sweet, sweetrequestAnimationFrame
(I'm assuming).I'm wondering if it'd be possible to export
winit::platform::emscripten::set_main_loop_callback
publicly, so one can write a main loop foremscripten
. (Maybe even better would be to add a method something likepub fn loop<F>(&mut self, mut per_frame: F) where F: FnMut() -> ControlFlow;
that could be implemented withset_main_loop_callback
on emscripten and something likewhile per_frame() != ControlFlow::Break {}
everywhere else.)Cheers!
The text was updated successfully, but these errors were encountered: