immersive-web / webxr-polyfill

Use the WebXR Device API today, providing fallbacks to native WebVR 1.1 and Cardboard
Apache License 2.0
378 stars 84 forks source link

the API in Devices sometimes passes sessionId, sometimes does not #129

Open blairmacintyre opened 4 years ago

blairmacintyre commented 4 years ago

By not passing sessionID to all methods in the XRDevice class, it is impossible to support different capabilities and values on different sessions.

For example, if there is an inline session and an immersive session active, they share values of the various spaces.

Methods include: getProjectionMatrix, getBasePoseMatrix, getBaseViewMatrix, getInputSources, getInputPose, requestFrameOfReferenceTransform, requestStageBounds

blairmacintyre commented 4 years ago

To expand on this: if a polyfill device wants to support both immersive sessions and inline sessions, it needs to know what kind of session is calling the device methods. Since, for example, the inline session may want / need to return different values from the immersive sessions. Some of the above only seem to be called during a rAF callback, so a device can save the current session of the frame in onFrameStart. But others (e.g., getInputSources) can be called anywhere.

blairmacintyre commented 4 years ago

The right solution would be to have the session methods pass the session ID down to all device methods. Does anyone not agree with this?

jsantell commented 4 years ago

IIRC this was necessary for previous AR prototypes; (all of?) the methods should be changed to receive session ID.