Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upHook up new openxr context menu gesture to embedder context menu machinery #26051
Conversation
|
If I may make a general comment on the design: while this undoubtedly "works", could it perhaps contribute to what was already noted to be a somewhat complex situation on the main-thread? Even if webxr is running off the main thread, could there be a simpler way to express this new API? I had a look at this PR, and the related one in WebXR, and if I understand it correctly this is essentially about calling So in an ideal world, would it not be great if OpenXR could just call Then those API could be implemented with messaging for off-the-main-thread Xr, and on the main-thread be simply synchronous call(it looks like showing the menu is natively async already?)? What I find somewhat harder to reason about the current design is how polling the result of the menu choice is tied to waiting on a frame inside Xr, and how if it's running on the main-thread the messaging is actually to the same event-loop(with the polling happening in a kind of sub-event-loop). Obviously, since the embedder doesn't even have a handle to Webxr at this point(only the compositor has), what I'm proposing would require a larger refactoring, so it's perhaps more suited for a follow-up. I do think it would be a good step towards simplifying and disentangling the various parts on the main-thread(or even off-main thread) embedder/device interactions. Note: when I write "the embedder" above, I mean |
| @@ -164,6 +169,7 @@ pub struct ServoGlue { | |||
| browsers: Vec<BrowserId>, | |||
| events: Vec<WindowEvent>, | |||
| current_url: Option<ServoUrl>, | |||
| context_menu_sender: Option<IpcSender<ContextMenuResult>>, | |||
This comment has been minimized.
This comment has been minimized.
gterzian
Mar 30, 2020
Member
I think this could be a threaded channel. The EmbedderProxy itself also uses a threaded channel internally.
|
@gterzian The API change has landed as part of #26043
At the moment, we're just following the current embedder API structure. But I'd be interested to know what type of changes you'd like to see in a future embedder API. Feel free to file another issue to continue the conversation. |
Yes, and I'm mainly referring to the additional integration taking place here, where the result of menu choice is handled by polling the |
Yes, but I don't want the webxr crate to know anything about the embedder.
The openxr device is not running on the main thread. It's tied to waiting on a frame just because that's where all the other events are being handled, I needed to pick some point on the openxr thread to poll, so I picked this one, since all the other events are being handled there, and in my eye this is basically just another device event that we're "helping". I thought of the other way of doing this: Instead of polling, we can give the device access to the |
I agree, I think the current structure wrapping the
Ok, thanks for pointing this out, just had a better look at the code and saw the use of
Ok I see. Just a question, I now see there is actually a Could you not add "something wrapping a sender of a That seems like a potential way to separate this from the animation frame? |
|
Ok so I've taken a better look at the code, and I think this is is a concrete proposal that would address my concerns with regards to tying the menu to the animation frame flow:
pub trait ContextMenuProvider: Send {
/// Called from the session thread.
fn open_context_menu(&self);
/// Called from the main thread once the result have been received.
/// Maybe separate the two in two different traits?
fn handle_selection(&self, result: usize);
}Then, when the device calls Then, when the embedder gets the result via Then, when the session thread receives the So, not saying this is super simple either, however it does address my concern of tying the messaging into the frame loop. |
Ah yes, so then my suggestion above would have to be updated to not passing the pub trait ContextMenuProvider: Send {
/// Called from the session thread.
fn open_context_menu(&self, Box<dyn ContextMenuCallback>);
}
pub trait ContextMenuCallback {
/// Called by the embedder,
/// This would internally send the `SessionMsg::Quit` based on the result passed.
fn handle_result(&self, result: ContextMenuResult)
}and to create the |
the embedder doesn't have an easy way to get a handle to the openxr device's sender
Yes. We could pass the quitter down to the embedder via the ShowContextMenu trait, and add another function to it that allows for cancelling context menus. I didn't want to make the core webxr API dependent on openxr-specific things though. Like, I considered exactly this design, especially since the quitter exists already; Basically, I've considered this design, but I'm unconvinced that it is better -- both are kinda gnarly. I guess having one trait is better than having two. Thoughts? |
|
@Manishearth Thanks for elaborating, now that I realize the XR frame loop really does need to keep polling frames while the session is running, I think my concern about polling for the result of the menu as part of the frame loop seems less relevant. I'd say this PR can also FIX #26057 Looks good to me, perhaps you could still replace the IPC channel with a threaded one if we're indeed not crossing a process boundary? |
|
@gterzian we're not crossing a process boundary now, unsure if this might ever change. Still, I'm open to the Quitter-based design as well, do you still prefer it? It might be cleaner. |
Ok :)
My main concern was tying the polling of the menu result into the frame loop, since that concern doesn't apply to the Xr frame loop, I'm much more ambivalent. |
Add a gesture to open up a context menu; fix quitting This adds a gesture (currently: "palm facing upwards") to open up a context menu. servo side: servo/servo#26051 r? @jdm
|
Cool, then in the interest of laziness I'll keep it the way it is. |
Add a gesture to open up a context menu; fix quitting This adds a gesture (currently: "palm facing upwards") to open up a context menu. servo side: servo/servo#26051 r? @jdm
Add a gesture to open up a context menu; fix quitting This adds a gesture (currently: "palm facing upwards") to open up a context menu. servo side: servo/servo#26051 r? @jdm
|
@bors-servo r=jdm |
|
|
|
|
@bors-servo r=jdm |
|
|
Hook up new openxr context menu gesture to embedder context menu machinery Based on #26043 Fixes #25797, #26057 servo/webxr#144 needs to land first Currently when exited the Servo window is blurred, apparently we need to call `Window.Activate` on it. r? @jdm cc @paulrouget
|
|
|
@bors-servo retry |
Hook up new openxr context menu gesture to embedder context menu machinery Based on #26043 Fixes #25797, #26057 servo/webxr#144 needs to land first Currently when exited the Servo window is blurred, apparently we need to call `Window.Activate` on it. r? @jdm cc @paulrouget
|
|
|
@bors-servo retry
|
|
|
Manishearth commentedMar 27, 2020
•
edited
Based on #26043
Fixes #25797, #26057
servo/webxr#144 needs to land first
Currently when exited the Servo window is blurred, apparently we need to call
Window.Activateon it.r? @jdm
cc @paulrouget