-
Notifications
You must be signed in to change notification settings - Fork 1.1k
winit-web: skip_recreation_check added #4276
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
base: master
Are you sure you want to change the base?
Conversation
6d2cf3b
to
1b4974a
Compare
The reason this is in place is for consistency between platforms. You can use Is there an issue with using |
The issue was mentioned in matrix, but basically we mark it for recreation as soon as you create the event loop, but spawn clears only after spawn/etc. Users can not run loops in parallel. I'd generally lift the restriction on the event loop creation from at least the backend itself. |
Ah, I see, my bad, I didn't read the OP carefully enough as well.
Where else can it be enforced then? "at least" implies that it stays somewhere else, or did you mean you want to remove the restriction altogether? I'm still of the same mind here: for consistency we shouldn't allow parallel event loop creation by default. Allowing it for |
How about something like |
That does sound fine for me. However, I think I would prefer to guide users towards Also while we are at it, whats your use-case for running Winit in parallel? |
I'm not using My use case is I'm trying to run multiple instances of what amounts to a game client side-by-side embedded in a Dioxus web app (so winit is not the root of the conceptual application) to represent each player's perspective. I could rework my Hopefully that makes sense. I'm happy to provide more info 🙂 |
Apologies, my suggestion is that instead of adding an escape hatch to I'm sorry for using the wrong method names, I'm a bit behind on all the renamed stuff.
I would recommend you to stick with a single event loop to reduce the overhead. However, the overhead is probably insignificant in comparison to a whole game and in comparison with the advantage of cleaner code. Sounds cool though and makes sense to me! |
My only concern with that is that there is an overlap there where this "could" snag. In practice this seems pretty unlikely and presumably easy to work around, but the following would fail: let event_loop_1 = EventLoop::new().unwrap(); // recreation flag set
let event_loop_2 = EventLoop::new().unwrap(); // panic
event_loop_1.spawn_app(App1::default()); // recreation flag reset here
event_loop_2.spawn_app(App2::default()); If you're good with that, I'll update this PR to just clear the flag inside of |
I'm thinking that the best implementation might be to make I was surprised that the current behavior was implemented this way in the first place: resetting the recreation flag instead of just ignoring it. So I went a back to the original PR #2897 and found #2907. Looking at #3311, it is probably best not to proceed here. I apologize for stringing you along here, I completely forgot about all this. So unless we re-assess our position here, I'm currently in favor of not allowing multiple event loops in parallel. |
I'm not sure how handling Anyways for my purposes, should I pivot to the long running singleton |
Is it really limited if you create the |
@kchibisov, assuming you're talking to me, are you suggesting I just directly create a |
I meant to use |
Gotcha. Sounds good to me 🙂 |
The idea of allowing parallel But there are other cases that would interfere in the future. When we change the window/surface model Web can implement more top-level methods, like changing the window title or window size. Moreover, the plan was in the future to replace multiple Windows in Web with subviews. So the only All of these things would significantly interfere with each other. Moreover I'm confident that parallel
I predict you should pivot. But as a contributor I've not contributed to Winit in a long time and I don't want to pretend I've the ultimate say here.
This could be a viable solution. But it needs to be something else then |
@kchibisov shall I close this PR? |
If you can achieve what you want by calling to |
I cannot achieve that presently. I would need to expose something on |
I think if the PR is directly against winit-web and not winit-core/etc it could be easier to move with it forward. I'm not web maintainer so can not say much about it, even though, I don't like that we have such recreation stuff for other backends as well, but some really need it, so it's in place for everyone as a lowest denominator. |
af39113
to
6053ee5
Compare
PR updated. If you don't want this touching |
20ce47c
to
5e7cb20
Compare
Yeah, I guess the point is to have it entirely in |
Just confirming, the usage of this will be: winit::platform::web::EventLoop::new(&winit::platform::web::PlatformSpecificEventLoopAttributes {
skip_recreation_check: true,
})? Instead of the extension trait form: winit::event_loop::EventLoop::builder().with_skip_recreation_check().build()? This creates some other friction, because now I have update some method calls like I've updated the PR removing the extension trait stuff. Let me know if you'd like any other changes 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just making sure my disapproval is not overlooked at a later point.
I hope I made myself clear in #4276 (comment).
Isn't it fine if it's a specific backend behavior that you should generally not rely upon, but just how the current backend may work? it's not a |
What does "should generally not rely upon" entail? Do you mean just because its backend specific? In my explanation I pointed out why parallel event loops will conflict with each other in the future on Web, backend specifically. |
if in the future you would be able to achieve the desired functionality with the single event loop then I don't see an issue. I'm not forcing any change here in particular though, just trying to find a compromise, since it's not the first time there's such request for web. |
OPs motivation is already achievable with the current API. The requested change is just for convenience. There is no plan to support running event loops in parallel on Web. I proposed a hypothetical API for parallel event loops on Web in #4276 (comment). However, I believe this would require not-insignificant amount of work and code to maintain. So IMO, unless there is a good use-case, we should not add that feature.
This request is about parallel event loops not about event loop re-creation, which is already covered with It would be good to know what other use-cases are out there. |
I think they just don't want to create them in sequence or IIRC the issue is that you can |
Check #4276 (comment) for the use-case. But indeed, event loops doesn't support being run in parallel. But there is no use-case for running the event loop in parallel except for simpler implementations, ergo convenience. Multi-window API is harder than |
changelog
module if knowledge of this change could be valuable to usersTested locally against a web app with two separate Canvases with their own winit+wgpu contexts in a Dioxus web app and unmounting+remounting the components (destroying and recreating everything in the process).