Auto merge of #26164 - Manishearth:dirty-endsession, r=jdm

Dirty canvas when exiting immersive sessions

Fixes https://github.com/servo/servo/issues/26162, fixes servo/webxr#155

We basically end up in a situation where the main thread is asleep. It's unclear to me why it doesn't wake up after attempts to interact with the screen, but we stopped dirtying the canvas during the immersive session (https://github.com/servo/servo/pull/26077) so the main thread wasn't awake initially.

This is probably not the cleanest fix -- we really should not be ending up in situations where the main thread is perma-asleep -- however, we should be dirtying the canvas after exiting immersive mode _anyway_ since the contents need to be shown to the user, so this fix is still valid, even if it's not fixing the root cause.
This commit is contained in:
bors-servo 2020-04-13 20:02:48 -04:00 committed by GitHub
commit 33a74a4f4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 1 deletions

View file

@ -14,6 +14,9 @@ use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRFrameRequestCal
use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRSessionMethods;
use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRVisibilityState;
use crate::dom::bindings::codegen::Bindings::XRSystemBinding::XRSessionMode;
use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding::{
XRWebGLLayerMethods, XRWebGLRenderingContext,
};
use crate::dom::bindings::error::{Error, ErrorResult};
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::refcounted::Trusted;
@ -319,6 +322,9 @@ impl XRSession {
self,
);
event.upcast::<Event>().fire(self.upcast());
// The page may be visible again, dirty the layers
// This also wakes up the event loop if necessary
self.dirty_layers();
},
XREvent::AddInput(info) => {
self.input_sources.add_input_sources(self, &[info]);
@ -463,6 +469,17 @@ impl XRSession {
pub fn session_id(&self) -> SessionId {
self.session.borrow().id()
}
pub fn dirty_layers(&self) {
if let Some(layer) = self.RenderState().GetBaseLayer() {
match layer.Context() {
XRWebGLRenderingContext::WebGLRenderingContext(c) => c.mark_as_dirty(),
XRWebGLRenderingContext::WebGL2RenderingContext(c) => {
c.base_context().mark_as_dirty()
},
}
}
}
}
impl XRSessionMethods for XRSession {