webaverse / metachromium-bin

Metachromium binary release
0 stars 1 forks source link

emit sessiongranted on page load #21

Open michaelybecker opened 4 years ago

michaelybecker commented 4 years ago

Context: #1, #2

sessiongranted is the future way browsers will initiate XR sessions, which will also enable automatic session start on page load (without user input, "VR buttons", etc).

XR Packages already implement them, as well as the Oculus browser (and AFrame).

Metachromium currently gets around the button by allowing automatic session request, i.e

navigator.xr.requestSession('immersive-vr', {
 optionalFeatures: [
 'local-floor',
 'bounded-floor',
 ],
}).then(onSessionStarted);

We want MC to conform to future standards by emitting a sessiongranted event on page load, so we can wrap this kind of code in

navigator.xr.addEventListener('sessiongranted', e =>
{
[CODE]
});
avaer commented 4 years ago

This might be easiest to accomplish with a baked-in Metachromium extension that emits this event and is installed into metachromium by default.

Note however that approach requires weird whitelisting flags on the command line to make the extension load in the default profile.

shu8 commented 4 years ago

I think we might also be able to do this using the DevTools protocol and injecting a JS snippet to the page to emit the event.

Not sure which method is cleaner to do though!