Commit 42a1454b authored by Anna Offenwanger's avatar Anna Offenwanger Committed by Commit Bot

Add XR.WebXR.PresentationSession.StartAction metric

Add a metric to track how presentation was started.

Bug: 808586
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.linux:linux_vr;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I2abda74f64ddc5fed58c6b71fbebcdddd2f8bab8
Reviewed-on: https://chromium-review.googlesource.com/986976
Commit-Queue: Anna Offenwanger <offenwanger@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548451}
parent b1513e62
...@@ -772,6 +772,13 @@ void VrShell::RecordVrStartAction(VrStartAction action) { ...@@ -772,6 +772,13 @@ void VrShell::RecordVrStartAction(VrStartAction action) {
} }
} }
void VrShell::RecordPresentationStartAction(PresentationStartAction action) {
SessionMetricsHelper* metrics_helper =
SessionMetricsHelper::FromWebContents(web_contents_);
if (metrics_helper)
metrics_helper->RecordPresentationStartAction(action);
}
void VrShell::ShowSoftInput(JNIEnv* env, void VrShell::ShowSoftInput(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj, const base::android::JavaParamRef<jobject>& obj,
bool show) { bool show) {
......
...@@ -187,6 +187,7 @@ class VrShell : device::GvrGamepadDataProvider, ...@@ -187,6 +187,7 @@ class VrShell : device::GvrGamepadDataProvider,
void ExitFullscreen(); void ExitFullscreen();
void LogUnsupportedModeUserMetric(UiUnsupportedMode mode); void LogUnsupportedModeUserMetric(UiUnsupportedMode mode);
void RecordVrStartAction(VrStartAction action); void RecordVrStartAction(VrStartAction action);
void RecordPresentationStartAction(PresentationStartAction action);
void OnUnsupportedMode(UiUnsupportedMode mode); void OnUnsupportedMode(UiUnsupportedMode mode);
void OnExitVrPromptResult(UiUnsupportedMode reason, void OnExitVrPromptResult(UiUnsupportedMode reason,
ExitVrPromptChoice choice); ExitVrPromptChoice choice);
......
...@@ -132,12 +132,21 @@ void VrShellDelegate::RecordVrStartAction( ...@@ -132,12 +132,21 @@ void VrShellDelegate::RecordVrStartAction(
JNIEnv* env, JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj, const base::android::JavaParamRef<jobject>& obj,
jint start_action) { jint start_action) {
VrStartAction action = static_cast<VrStartAction>(start_action);
if (action == VrStartAction::kDeepLinkedApp) {
// If this is a deep linked app we expect a DisplayActivate to be coming
// down the pipeline shortly.
possible_presentation_start_action_ =
PresentationStartAction::kDeepLinkedApp;
}
if (!vr_shell_) { if (!vr_shell_) {
pending_vr_start_action_ = static_cast<VrStartAction>(start_action); pending_vr_start_action_ = action;
return; return;
} }
vr_shell_->RecordVrStartAction(static_cast<VrStartAction>(start_action)); vr_shell_->RecordVrStartAction(action);
} }
void VrShellDelegate::OnPresentResult( void VrShellDelegate::OnPresentResult(
...@@ -149,6 +158,7 @@ void VrShellDelegate::OnPresentResult( ...@@ -149,6 +158,7 @@ void VrShellDelegate::OnPresentResult(
bool success) { bool success) {
if (!success) { if (!success) {
std::move(callback).Run(false, nullptr); std::move(callback).Run(false, nullptr);
possible_presentation_start_action_ = base::nullopt;
return; return;
} }
...@@ -163,6 +173,15 @@ void VrShellDelegate::OnPresentResult( ...@@ -163,6 +173,15 @@ void VrShellDelegate::OnPresentResult(
return; return;
} }
// If possible_presentation_start_action_ is not set at this point, then this
// request present probably came from blink, and has already been reported
// from there.
if (possible_presentation_start_action_) {
vr_shell_->RecordPresentationStartAction(
*possible_presentation_start_action_);
possible_presentation_start_action_ = base::nullopt;
}
vr_shell_->ConnectPresentingService( vr_shell_->ConnectPresentingService(
std::move(submit_client), std::move(request), std::move(display_info), std::move(submit_client), std::move(request), std::move(display_info),
std::move(present_options)); std::move(present_options));
...@@ -174,6 +193,16 @@ void VrShellDelegate::DisplayActivate(JNIEnv* env, ...@@ -174,6 +193,16 @@ void VrShellDelegate::DisplayActivate(JNIEnv* env,
const JavaParamRef<jobject>& obj) { const JavaParamRef<jobject>& obj) {
device::GvrDevice* device = static_cast<device::GvrDevice*>(GetDevice()); device::GvrDevice* device = static_cast<device::GvrDevice*>(GetDevice());
if (device) { if (device) {
if (!possible_presentation_start_action_ ||
possible_presentation_start_action_ !=
PresentationStartAction::kDeepLinkedApp) {
// The only possible sources for DisplayActivate are at the moment DLAs
// and HeadsetActivations. Therefore if it's not a DLA it must be a
// HeadsetActivation.
possible_presentation_start_action_ =
PresentationStartAction::kHeadsetActivation;
}
device->Activate( device->Activate(
device::mojom::VRDisplayEventReason::MOUNTED, device::mojom::VRDisplayEventReason::MOUNTED,
base::BindRepeating(&VrShellDelegate::OnActivateDisplayHandled, base::BindRepeating(&VrShellDelegate::OnActivateDisplayHandled,
...@@ -268,6 +297,8 @@ void VrShellDelegate::OnActivateDisplayHandled(bool will_not_present) { ...@@ -268,6 +297,8 @@ void VrShellDelegate::OnActivateDisplayHandled(bool will_not_present) {
// WebVR page didn't request presentation in the vrdisplayactivate handler. // WebVR page didn't request presentation in the vrdisplayactivate handler.
// Tell VrShell that we are in VR Browsing Mode. // Tell VrShell that we are in VR Browsing Mode.
ExitWebVRPresent(); ExitWebVRPresent();
// Reset possible_presentation_start_action_ as it may have been set.
possible_presentation_start_action_ = base::nullopt;
} }
} }
......
...@@ -99,6 +99,7 @@ class VrShellDelegate : public device::GvrDelegateProvider { ...@@ -99,6 +99,7 @@ class VrShellDelegate : public device::GvrDelegateProvider {
base::OnceCallback<void(bool)> on_present_result_callback_; base::OnceCallback<void(bool)> on_present_result_callback_;
bool pending_successful_present_request_ = false; bool pending_successful_present_request_ = false;
base::Optional<VrStartAction> pending_vr_start_action_; base::Optional<VrStartAction> pending_vr_start_action_;
base::Optional<PresentationStartAction> possible_presentation_start_action_;
base::CancelableClosure clear_activate_task_; base::CancelableClosure clear_activate_task_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_; scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
......
...@@ -290,13 +290,26 @@ void SessionMetricsHelper::RecordVrStartAction(VrStartAction action) { ...@@ -290,13 +290,26 @@ void SessionMetricsHelper::RecordVrStartAction(VrStartAction action) {
} }
} }
void SessionMetricsHelper::RecordPresentationStartAction(
PresentationStartAction action) {
if (!presentation_session_tracker_ || mode_ != Mode::kWebXrVrPresentation) {
pending_presentation_start_action_ = action;
} else {
presentation_session_tracker_->ukm_entry()->SetStartAction(action);
pending_presentation_start_action_ = base::nullopt;
}
}
void SessionMetricsHelper::ReportRequestPresent() { void SessionMetricsHelper::ReportRequestPresent() {
// If we're not in VR, log this as an entry into VR from 2D. // If we're not in VR, log this as an entry into VR from 2D.
if (mode_ == Mode::kNoVr) { if (mode_ == Mode::kNoVr) {
RecordVrStartAction(VrStartAction::kPresentationRequest); RecordVrStartAction(VrStartAction::kPresentationRequest);
// TODO(offenwanger): Record entered presentation from 2D. RecordPresentationStartAction(
PresentationStartAction::kRequestFrom2dBrowsing);
} else {
RecordPresentationStartAction(
PresentationStartAction::kRequestFromVrBrowsing);
} }
// TODO(offenwanger): Else record entered presentation from VR.
} }
void SessionMetricsHelper::MaybeSetVrStartAction(VrStartAction action) { void SessionMetricsHelper::MaybeSetVrStartAction(VrStartAction action) {
...@@ -471,6 +484,14 @@ void SessionMetricsHelper::OnEnterPresentation() { ...@@ -471,6 +484,14 @@ void SessionMetricsHelper::OnEnterPresentation() {
SessionTracker<ukm::builders::XR_WebXR_PresentationSession>>( SessionTracker<ukm::builders::XR_WebXR_PresentationSession>>(
std::make_unique<ukm::builders::XR_WebXR_PresentationSession>( std::make_unique<ukm::builders::XR_WebXR_PresentationSession>(
ukm::GetSourceIdForWebContentsDocument(web_contents()))); ukm::GetSourceIdForWebContentsDocument(web_contents())));
if (!pending_presentation_start_action_) {
pending_presentation_start_action_ = PresentationStartAction::kOther;
}
presentation_session_tracker_->ukm_entry()->SetStartAction(
*pending_presentation_start_action_);
pending_presentation_start_action_ = base::nullopt;
} }
void SessionMetricsHelper::OnExitPresentation() { void SessionMetricsHelper::OnExitPresentation() {
...@@ -617,6 +638,11 @@ void SessionMetricsHelper::DidFinishNavigation( ...@@ -617,6 +638,11 @@ void SessionMetricsHelper::DidFinishNavigation(
SessionTracker<ukm::builders::XR_WebXR_PresentationSession>>( SessionTracker<ukm::builders::XR_WebXR_PresentationSession>>(
std::make_unique<ukm::builders::XR_WebXR_PresentationSession>( std::make_unique<ukm::builders::XR_WebXR_PresentationSession>(
ukm::GetSourceIdForWebContentsDocument(web_contents()))); ukm::GetSourceIdForWebContentsDocument(web_contents())));
if (pending_presentation_start_action_) {
presentation_session_tracker_->ukm_entry()->SetStartAction(
*pending_presentation_start_action_);
pending_presentation_start_action_ = base::nullopt;
}
} }
num_session_navigation_++; num_session_navigation_++;
......
...@@ -37,6 +37,24 @@ enum class VrStartAction : int { ...@@ -37,6 +37,24 @@ enum class VrStartAction : int {
kVrStartActionLast = kIntentLaunch, kVrStartActionLast = kIntentLaunch,
}; };
// The source of a request to enter XR Presentation.
enum PresentationStartAction {
// A catch all for methods of Presentation entry that are not otherwise
// logged.
kOther = 0,
// The user triggered a presentation request on a page in 2D, probably by
// clicking an enter VR button.
kRequestFrom2dBrowsing = 1,
// The user triggered a presentation request on a page in VR browsing,
// probably by clicking an enter VR button.
kRequestFromVrBrowsing = 2,
// The user activated a headset on a page that listens for headset activations
// and requests presentation.
kHeadsetActivation = 3,
// The user opened a deep linked app, probably from the Daydream homescreen.
kDeepLinkedApp = 4,
};
// SessionTimer will monitor the time between calls to StartSession and // SessionTimer will monitor the time between calls to StartSession and
// StopSession. It will combine multiple segments into a single session if they // StopSession. It will combine multiple segments into a single session if they
// are sufficiently close in time. It will also only include segments if they // are sufficiently close in time. It will also only include segments if they
...@@ -142,6 +160,7 @@ class SessionMetricsHelper : public content::WebContentsObserver { ...@@ -142,6 +160,7 @@ class SessionMetricsHelper : public content::WebContentsObserver {
void RecordUrlRequested(GURL url, NavigationMethod method); void RecordUrlRequested(GURL url, NavigationMethod method);
void RecordVrStartAction(VrStartAction action); void RecordVrStartAction(VrStartAction action);
void RecordPresentationStartAction(PresentationStartAction action);
void ReportRequestPresent(); void ReportRequestPresent();
private: private:
...@@ -195,6 +214,7 @@ class SessionMetricsHelper : public content::WebContentsObserver { ...@@ -195,6 +214,7 @@ class SessionMetricsHelper : public content::WebContentsObserver {
NavigationMethod last_url_request_method_; NavigationMethod last_url_request_method_;
base::Optional<VrStartAction> pending_page_session_start_action_; base::Optional<VrStartAction> pending_page_session_start_action_;
base::Optional<PresentationStartAction> pending_presentation_start_action_;
int num_videos_playing_ = 0; int num_videos_playing_ = 0;
int num_session_navigation_ = 0; int num_session_navigation_ = 0;
......
...@@ -3452,6 +3452,18 @@ be describing additional metrics about the same event. ...@@ -3452,6 +3452,18 @@ be describing additional metrics about the same event.
SessionTracker::GetRoundedDurationInSeconds. SessionTracker::GetRoundedDurationInSeconds.
</summary> </summary>
</metric> </metric>
<metric name="StartAction">
<summary>
A metric to track specifically how the user got into XR presentation. 0:
Other, catch all. 1: RequestFrom2DBrowsing, the page requested
presentation while Chrome was in 2D mode. 2: RequestFromVRBrowsing, the
page requested presentation while Chrome was in VR browsing mode. 3:
HeadsetActivation, the user activated the VR headset while in 2D browsing
on the page, which listens for headset activations to request
presentation. 4: DeepLinkedApp, The page was launched in Chrome from the
VR system home (e.g., Daydream Home) and requested presentation.
</summary>
</metric>
</event> </event>
</ukm-configuration> </ukm-configuration>
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