Commit 00e6dd05 authored by Anna Offenwanger's avatar Anna Offenwanger Committed by Commit Bot

Adding Origin Trial for WebXR Device API

Create an origin trial for WebXR and a separate one for exposing controllers as Gamepads.
Controllers will still be exposed as Gamepads by default for WebVR origin trial, but must be
enabled separately for WebXR.

Bug: 779691

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I639b259ea2a583bdbd3f18b6d30b7e107cdb21c1
Reviewed-on: https://chromium-review.googlesource.com/982679
Commit-Queue: Anna Offenwanger <offenwanger@chromium.org>
Reviewed-by: default avatarDavid Dorwin <ddorwin@chromium.org>
Reviewed-by: default avatarPavel Feldman <pfeldman@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548291}
parent 2f884693
......@@ -2209,6 +2209,9 @@ const FeatureEntry kFeatureEntries[] = {
{"webxr", flag_descriptions::kWebXrName,
flag_descriptions::kWebXrDescription, kOsAll,
FEATURE_VALUE_TYPE(features::kWebXr)},
{"webxr-gamepad-support", flag_descriptions::kWebXrGamepadSupportName,
flag_descriptions::kWebXrGamepadSupportDescription, kOsAll,
FEATURE_VALUE_TYPE(features::kWebXrGamepadSupport)},
{"webxr-orientation-sensor-device",
flag_descriptions::kWebXrOrientationSensorDeviceName,
flag_descriptions::kWebXrOrientationSensorDeviceDescription, kOsAll,
......
......@@ -760,8 +760,8 @@ const char kFramebustingDescription[] =
const char kGamepadExtensionsName[] = "Gamepad Extensions";
const char kGamepadExtensionsDescription[] =
"Enabling this option allows web applications to access experimental "
"extensions to the Gamepad APIs.";
"Enables experimental extensions to the Gamepad APIs, and exposes VR "
"controllers as Gamepads for WebVR";
const char kGpuRasterizationMsaaSampleCountName[] =
"GPU rasterization MSAA sample count.";
......@@ -1777,16 +1777,22 @@ const char kWebrtcStunOriginDescription[] =
const char kWebvrName[] = "WebVR";
const char kWebvrDescription[] =
"Allow web applications to access experimental "
"Virtual Reality functionality via the WebVR 1.1 API. This feature will "
"eventually be replaced by the WebXR Device API. Warning: Enabling this "
"will also allow WebVR content on insecure origins to access these "
"powerful APIs, and may pose a security risk.";
"Enables access to experimental Virtual Reality functionality via the "
"WebVR 1.1 API. This feature will eventually be replaced by the WebXR "
"Device API. Warning: Enabling this will also allow WebVR content on "
"insecure origins to access these powerful APIs, and may pose a security "
"risk. Controllers are exposed as Gamepads and Gamepad Extensions are "
"enabled.";
const char kWebXrName[] = "WebXR Device API";
const char kWebXrDescription[] =
"Allow web applications to access experimental APIs to interact with "
"Virtual Reality (VR) and Augmented Reality (AR) devices.";
"Enables access to experimental APIs to interact with Virtual Reality (VR) "
"and Augmented Reality (AR) devices.";
const char kWebXrGamepadSupportName[] = "WebXR Gamepad Support";
const char kWebXrGamepadSupportDescription[] =
"Expose VR controllers as Gamepads for use with the WebXR Device API. Each "
"XRInputSource will have a corresponding Gamepad instance";
const char kWebXrOrientationSensorDeviceName[] =
"WebXR orientation sensor device";
......
......@@ -482,6 +482,8 @@ extern const char kFramebustingDescription[];
extern const char kGamepadExtensionsName[];
extern const char kGamepadExtensionsDescription[];
extern const char kWebXrGamepadSupportName[];
extern const char kWebXrGamepadSupportDescription[];
extern const char kGpuRasterizationMsaaSampleCountName[];
extern const char kGpuRasterizationMsaaSampleCountDescription[];
......
......@@ -207,6 +207,9 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(
WebRuntimeFeatures::EnableWebXR(
base::FeatureList::IsEnabled(features::kWebXr));
if (base::FeatureList::IsEnabled(features::kWebXrGamepadSupport))
WebRuntimeFeatures::EnableWebXRGamepadSupport(true);
if (command_line.HasSwitch(switches::kDisablePresentationAPI))
WebRuntimeFeatures::EnablePresentationAPI(false);
......
......@@ -121,9 +121,15 @@ const base::Feature kFramebustingNeedsSameOriginOrUserGesture{
"FramebustingNeedsSameOriginOrUserGesture",
base::FEATURE_ENABLED_BY_DEFAULT};
// Enables extended Gamepad API features like motion tracking and haptics.
// Enables extended Gamepad API features like motion tracking and haptics, and
// exposing VR inputs and controllers as GamePads.
const base::Feature kGamepadExtensions{"GamepadExtensions",
base::FEATURE_DISABLED_BY_DEFAULT};
// Enables extended Gamepad API features that expose VR controllers as Gamepads
// for use with WebXR Device API. Each XRInputSource will have a corresponding
// Gamepad instance.
const base::Feature kWebXrGamepadSupport{"WebXRGamepadSupport",
base::FEATURE_DISABLED_BY_DEFAULT};
// Causes the implementations of guests (inner WebContents) to use
// out-of-process iframes.
......
......@@ -40,6 +40,7 @@ CONTENT_EXPORT extern const base::Feature kFontCacheScaling;
CONTENT_EXPORT extern const base::Feature
kFramebustingNeedsSameOriginOrUserGesture;
CONTENT_EXPORT extern const base::Feature kGamepadExtensions;
CONTENT_EXPORT extern const base::Feature kWebXrGamepadSupport;
CONTENT_EXPORT extern const base::Feature kGuestViewCrossProcessFrames;
CONTENT_EXPORT extern const base::Feature kHeapCompaction;
CONTENT_EXPORT extern const base::Feature kImageCaptureAPI;
......
......@@ -97,6 +97,12 @@ def origin_trial_features_info(info_provider, reader, idl_filenames, target_comp
interface, implements = read_idl_file(reader, idl_filename)
feature_names = get_origin_trial_feature_names_from_interface(interface)
# If this interface has NoInterfaceObject then we don't want to add
# includes for it because it is a base interface to be implemented
# by other interfaces, and does not generate an ECMAScript binding.
if 'NoInterfaceObject' in interface.extended_attributes:
continue
# If this interface implements another one,
# it inherits any conditional features from it.
for implement in implements:
......
......@@ -148,12 +148,10 @@ CanvasRenderingContext::ContextType CanvasRenderingContext::ContextTypeFromId(
return kContextWebgl;
if (id == "webgl2")
return kContextWebgl2;
if (id == "bitmaprenderer") {
if (id == "bitmaprenderer")
return kContextImageBitmap;
}
if (id == "xrpresent" && RuntimeEnabledFeatures::WebXREnabled()) {
if (id == "xrpresent")
return kContextXRPresent;
}
return kContextTypeCount;
}
......
......@@ -258,7 +258,9 @@ CanvasRenderingContext* HTMLCanvasElement::GetCanvasRenderingContext(
CanvasRenderingContext::ContextTypeFromId(type);
// Unknown type.
if (context_type == CanvasRenderingContext::kContextTypeCount)
if (context_type == CanvasRenderingContext::kContextTypeCount ||
(context_type == CanvasRenderingContext::kContextXRPresent &&
!OriginTrials::webXREnabled(&GetDocument())))
return nullptr;
// Log the aliased context type used.
......
......@@ -19,6 +19,7 @@
#include "core/html/canvas/CanvasRenderingContextFactory.h"
#include "core/html/canvas/ImageData.h"
#include "core/imagebitmap/ImageBitmap.h"
#include "core/origin_trials/origin_trials.h"
#include "core/workers/WorkerGlobalScope.h"
#include "gpu/config/gpu_feature_info.h"
#include "platform/graphics/CanvasResourceProvider.h"
......@@ -168,7 +169,9 @@ CanvasRenderingContext* OffscreenCanvas::GetCanvasRenderingContext(
CanvasRenderingContext::ContextTypeFromId(id);
// Unknown type.
if (context_type == CanvasRenderingContext::kContextTypeCount)
if (context_type == CanvasRenderingContext::kContextTypeCount ||
(context_type == CanvasRenderingContext::kContextXRPresent &&
!OriginTrials::webXREnabled(execution_context)))
return nullptr;
CanvasRenderingContextFactory* factory =
......
......@@ -48,5 +48,5 @@ dictionary CanvasContextCreationAttributesModule {
boolean premultipliedAlpha = true;
boolean preserveDrawingBuffer = false;
boolean failIfMajorPerformanceCaveat = false;
[RuntimeEnabled=WebXR] XRDevice compatibleXRDevice = null;
[OriginTrialEnabled=WebXR] XRDevice compatibleXRDevice = null;
};
......@@ -45,8 +45,8 @@ interface Gamepad {
[OriginTrialEnabled=GamepadExtensions, MeasureAs=GamepadVibrationActuator] readonly attribute GamepadHapticActuator? vibrationActuator;
[OriginTrialEnabled=GamepadExtensions, MeasureAs=GamepadPose] readonly attribute GamepadPose? pose;
[OriginTrialEnabled=GamepadExtensions, MeasureAs=GamepadHand] readonly attribute GamepadHand hand;
[OriginTrialEnabled=WebXRGamepadSupport, MeasureAs=GamepadHand] readonly attribute GamepadHand hand;
// https://w3c.github.io/webvr/#interface-gamepad
[OriginTrialEnabled=GamepadExtensions, MeasureAs=GamepadDisplayId] readonly attribute unsigned long displayId;
[OriginTrialEnabled=WebXRGamepadSupport, MeasureAs=GamepadDisplayId] readonly attribute unsigned long displayId;
};
......@@ -4,6 +4,7 @@
interface GamepadButton {
readonly attribute boolean pressed;
[OriginTrialEnabled=GamepadExtensions, MeasureAs=GamepadButtonTouched] readonly attribute boolean touched;
// TODO(bajones): Enable this by default as it is part of the core spec.
[OriginTrialEnabled=WebXRGamepadSupport, MeasureAs=GamepadButtonTouched] readonly attribute boolean touched;
readonly attribute double value;
};
......@@ -7,7 +7,7 @@
ImplementedAs=NavigatorVR
] partial interface Navigator {
// Latest API
[SecureContext, RuntimeEnabled=WebXR] readonly attribute XR xr;
[SecureContext, OriginTrialEnabled=WebXR] readonly attribute XR xr;
// Legacy API
[OriginTrialEnabled=WebVR, CallWith=ScriptState] Promise getVRDisplays();
......
......@@ -34,5 +34,5 @@ dictionary WebGLContextAttributes {
boolean premultipliedAlpha = true;
boolean preserveDrawingBuffer = false;
boolean failIfMajorPerformanceCaveat = false;
[RuntimeEnabled=WebXR] XRDevice compatibleXRDevice = null;
[OriginTrialEnabled=WebXR] XRDevice compatibleXRDevice = null;
};
......@@ -708,5 +708,5 @@ typedef unrestricted float GLclampf;
[RuntimeEnabled=OffscreenCanvas, CallWith=ScriptState, RaisesException] Promise commit();
// WebXR Device API support
[RuntimeEnabled=WebXR, SecureContext, CallWith=ScriptState] Promise setCompatibleXRDevice(XRDevice device);
[OriginTrialEnabled=WebXR, SecureContext, CallWith=ScriptState] Promise setCompatibleXRDevice(XRDevice device);
};
......@@ -5,7 +5,7 @@
// https://immersive-web.github.io/webxr/spec/latest/#xr-interface
[
SecureContext,
RuntimeEnabled=WebXR
OriginTrialEnabled=WebXR
] interface XR : EventTarget {
attribute EventHandler ondevicechange;
[CallWith=ScriptState] Promise requestDevice();
......
......@@ -5,7 +5,7 @@
// https://immersive-web.github.io/webxr/spec/latest/#xrcoordinatesystem-interface
[
SecureContext,
RuntimeEnabled=WebXR
OriginTrialEnabled=WebXR
] interface XRCoordinateSystem {
Float32Array? getTransformTo(XRCoordinateSystem other);
};
......@@ -5,7 +5,7 @@
// https://immersive-web.github.io/webxr/spec/latest/#xrdevice-interface
[
SecureContext,
RuntimeEnabled=WebXR
OriginTrialEnabled=WebXR
] interface XRDevice : EventTarget {
[CallWith=ScriptState] Promise supportsSession([PermissiveDictionaryConversion] optional XRSessionCreationOptions options);
[CallWith=ScriptState] Promise requestSession([PermissiveDictionaryConversion] optional XRSessionCreationOptions options);
......
......@@ -5,7 +5,7 @@
// https://immersive-web.github.io/webxr/spec/latest/#xrdevicepose-interface
[
SecureContext,
RuntimeEnabled=WebXR
OriginTrialEnabled=WebXR
] interface XRDevicePose {
readonly attribute Float32Array poseModelMatrix;
......
......@@ -12,7 +12,7 @@ enum XRFrameOfReferenceType {
[
SecureContext,
RuntimeEnabled=WebXR
OriginTrialEnabled=WebXR
] interface XRFrameOfReference : XRCoordinateSystem {
readonly attribute XRStageBounds? bounds;
readonly attribute double emulatedHeight;
......
......@@ -4,7 +4,7 @@
[
SecureContext,
RuntimeEnabled=WebXR
OriginTrialEnabled=WebXR
] interface XRInputPose {
readonly attribute Float32Array pointerMatrix;
readonly attribute Float32Array? gripMatrix;
......
......@@ -15,7 +15,7 @@ enum XRPointerOrigin {
[
SecureContext,
RuntimeEnabled=WebXR
OriginTrialEnabled=WebXR
] interface XRInputSource {
readonly attribute XRHandedness handedness;
readonly attribute XRPointerOrigin pointerOrigin;
......
......@@ -4,7 +4,7 @@
[
SecureContext,
RuntimeEnabled=WebXR,
OriginTrialEnabled=WebXR,
Constructor(DOMString type, XRInputSourceEventInit eventInitDict)
] interface XRInputSourceEvent : Event {
readonly attribute XRPresentationFrame frame;
......
......@@ -5,5 +5,5 @@
// https://immersive-web.github.io/webxr/spec/latest/#xrlayer-interface
[
SecureContext,
RuntimeEnabled=WebXR
OriginTrialEnabled=WebXR
] interface XRLayer {};
......@@ -5,6 +5,7 @@
#include "modules/xr/XRPresentationContext.h"
#include "bindings/modules/v8/rendering_context.h"
#include "core/origin_trials/origin_trials.h"
namespace blink {
......@@ -23,7 +24,7 @@ void XRPresentationContext::SetCanvasGetContextResult(
CanvasRenderingContext* XRPresentationContext::Factory::Create(
CanvasRenderingContextHost* host,
const CanvasContextCreationAttributesCore& attrs) {
if (!RuntimeEnabledFeatures::WebXREnabled())
if (!OriginTrials::webXREnabled(host->GetTopExecutionContext()))
return nullptr;
return new XRPresentationContext(host, attrs);
}
......
......@@ -5,7 +5,7 @@
// https://immersive-web.github.io/webxr/spec/latest/#xrpresentationcontext-interface
[
SecureContext,
RuntimeEnabled=WebXR
OriginTrialEnabled=WebXR
] interface XRPresentationContext {
// back-reference to the canvas
readonly attribute HTMLCanvasElement canvas;
......
......@@ -5,7 +5,7 @@
// https://immersive-web.github.io/webxr/spec/latest/#xrpresentationframe-interface
[
SecureContext,
RuntimeEnabled=WebXR
OriginTrialEnabled=WebXR
] interface XRPresentationFrame {
readonly attribute XRSession session;
readonly attribute FrozenArray<XRView> views;
......
......@@ -5,7 +5,7 @@
// https://immersive-web.github.io/webxr/spec/latest/#xrsession-interface
[
SecureContext,
RuntimeEnabled=WebXR
OriginTrialEnabled=WebXR
] interface XRSession : EventTarget {
readonly attribute XRDevice device;
readonly attribute boolean exclusive;
......
......@@ -5,7 +5,7 @@
// https://immersive-web.github.io/webxr/spec/latest/#xrsessionevent-interface
[
SecureContext,
RuntimeEnabled=WebXR,
OriginTrialEnabled=WebXR,
Constructor(DOMString type, XRSessionEventInit eventInitDict)
] interface XRSessionEvent : Event {
readonly attribute XRSession session;
......
......@@ -5,7 +5,7 @@
// https://immersive-web.github.io/webxr/spec/latest/#xrstagebounds-interface
[
SecureContext,
RuntimeEnabled=WebXR
OriginTrialEnabled=WebXR
] interface XRStageBounds {
readonly attribute FrozenArray<XRStageBoundsPoint> geometry;
};
......@@ -5,7 +5,7 @@
// https://immersive-web.github.io/webxr/spec/latest/#xrstageboundspoint-interface
[
SecureContext,
RuntimeEnabled=WebXR
OriginTrialEnabled=WebXR
] interface XRStageBoundsPoint {
readonly attribute double x;
readonly attribute double z;
......
......@@ -5,7 +5,7 @@
// https://immersive-web.github.io/webxr/spec/latest/#xrview-interface
[
SecureContext,
RuntimeEnabled=WebXR
OriginTrialEnabled=WebXR
] interface XRView {
readonly attribute VREye? eye;
readonly attribute Float32Array projectionMatrix;
......
......@@ -5,7 +5,7 @@
// https://immersive-web.github.io/webxr/spec/latest/#xrviewport-interface
[
SecureContext,
RuntimeEnabled=WebXR
OriginTrialEnabled=WebXR
] interface XRViewport {
readonly attribute long x;
readonly attribute long y;
......
......@@ -7,7 +7,7 @@ typedef (WebGLRenderingContext or WebGL2RenderingContext) XRWebGLRenderingContex
// https://immersive-web.github.io/webxr/spec/latest/#xrwebgllayer-interface
[
SecureContext,
RuntimeEnabled=WebXR,
OriginTrialEnabled=WebXR,
Constructor(XRSession session, XRWebGLRenderingContext context, optional XRWebGLLayerInit layerInit),
RaisesException=Constructor
] interface XRWebGLLayer : XRLayer {
......
......@@ -140,6 +140,10 @@ void WebRuntimeFeatures::EnableGamepadExtensions(bool enable) {
RuntimeEnabledFeatures::SetGamepadExtensionsEnabled(enable);
}
void WebRuntimeFeatures::EnableWebXRGamepadSupport(bool enable) {
RuntimeEnabledFeatures::SetWebXRGamepadSupportEnabled(enable);
}
void WebRuntimeFeatures::EnableGenericSensor(bool enable) {
RuntimeEnabledFeatures::SetSensorEnabled(enable);
}
......
......@@ -1289,6 +1289,16 @@
},
{
name: "WebXR",
origin_trial_feature_name: "WebXR Device",
status: "test",
},
// Subset of the GamepadExtensions wanted for WebXR, which expose VR controller
// functionality as Gamepads.
{
name: "WebXRGamepadSupport",
origin_trial_feature_name: "WebXR Gamepad Support",
// This feature is a strict subset of GamepadExtensions.
implied_by: ["GamepadExtensions"],
status: "test",
},
{
......
......@@ -83,6 +83,7 @@ class WebRuntimeFeatures {
BLINK_PLATFORM_EXPORT static void EnableFileSystem(bool);
BLINK_PLATFORM_EXPORT static void EnableForceTallerSelectPopup(bool);
BLINK_PLATFORM_EXPORT static void EnableGamepadExtensions(bool);
BLINK_PLATFORM_EXPORT static void EnableWebXRGamepadSupport(bool);
BLINK_PLATFORM_EXPORT static void EnableGenericSensor(bool);
BLINK_PLATFORM_EXPORT static void EnableGenericSensorExtraClasses(bool);
BLINK_PLATFORM_EXPORT static void EnableHeapCompaction(bool);
......
......@@ -26193,6 +26193,7 @@ from previous Chrome versions.
<int value="-1248478422" label="enable-zip-archiver-packer"/>
<int value="-1246840031" label="OptInImeMenu:disabled"/>
<int value="-1241747717" label="enable-android-password-link"/>
<int value="-1237621246" label="WebXRGamepadSupport:disabled"/>
<int value="-1235586511" label="enable-datasaver-prompt"/>
<int value="-1234740672" label="UsePdfCompositorServiceForPrint:disabled"/>
<int value="-1225198073" label="ReaderModeInCCT:disabled"/>
......@@ -26998,6 +26999,7 @@ from previous Chrome versions.
<int value="723619383" label="TopSitesFromSiteEngagement:enabled"/>
<int value="724208771" label="TabsInCBD:enabled"/>
<int value="725270017" label="ScrollAnchorSerialization:disabled"/>
<int value="726764779" label="WebXRGamepadSupport:enabled"/>
<int value="727571565" label="PasswordForceSaving"/>
<int value="728656094" label="PasswordForceSaving:disabled"/>
<int value="730024226" label="enable-out-of-process-pdf"/>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment