immersive-web / webxr-polyfill

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

supportsSession() -> isSessionSupported() #93

Closed toji closed 4 years ago

toji commented 4 years ago

Posted in anticipation of https://github.com/immersive-web/webxr/pull/841 landing. I'll take this out of draft once that happens.

Changes navigator.xr.supportsSession() to navigator.xr.isSessionSupported() and made the method resolve with a boolean to indicate success or failure. This matches the spec change made to do the same in response to feedback from the TAG.

This PR also introduces a small shim that assists developers using the previous signature by redirecting the call to the right place and outputting a warning to the console informing them of the new method name and behavior. That can eventually be removed once the API has been out for a bit.

jsantell commented 4 years ago

LGTM FWIW

takahirox commented 4 years ago

Likely when does Chrome Canary switch from .supportsSession() to .isSessionSupported()? Until it does the user code may need to be aware of the polyfill like

if (navigator.xr.isSessionSupported) {
  ...
} else if (navigator.xr.supportsSession) {
  ...
}
toji commented 4 years ago

Chrome canary should already have the new method, but we're also keeping the old function around for a little while with a console message warning developers that it's been deprecated and what they should replace it with.

takahirox commented 4 years ago

Thanks for the comment! That sounds nice.