Commit c6542def authored by Piotr Bialecki's avatar Piotr Bialecki Committed by Chromium LUCI CQ

WebXR depth: add depth buffer resolution limit & histogram

Add depth buffer resolution limit along with a histogram to measure the
resolution of depth buffer that was obtained from ARCore.

Bug: 1154323
Change-Id: I7109c76732e76dd825f0a45e2dd32570b89e79d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2568752Reviewed-by: default avatarKlaus Weidner <klausw@chromium.org>
Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Commit-Queue: Piotr Bialecki <bialpio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833554}
parent c8df352d
......@@ -7,6 +7,7 @@
#include "base/android/jni_android.h"
#include "base/bind.h"
#include "base/containers/span.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/checked_math.h"
#include "base/numerics/math_constants.h"
#include "base/optional.h"
......@@ -1760,6 +1761,8 @@ mojom::XRDepthDataPtr ArCoreImpl::GetDepthData() {
<< num_planes;
if (time_delta > previous_depth_data_time_) {
// The depth data is more recent than what was previously returned, we need
// to send the latest information back:
mojom::XRDepthDataUpdatedPtr result = mojom::XRDepthDataUpdated::New();
result->time_delta = time_delta;
......@@ -1782,6 +1785,26 @@ mojom::XRDepthDataPtr ArCoreImpl::GetDepthData() {
return nullptr;
}
// Log a histogram w/ the number of entries in the depth buffer to make sure
// we have a way of measuring the impact of the decision to suppress
// too-high-resolution depth buffers. Assuming various common aspect ratios
// & fixing the width to 160 pixels, the total number of pixels varies from
// ~6000 to ~20000, and w/ the threshold below set to 43200 pixels, the
// custom count from 5000 to 55000 with bucket size of 1000 should give us
// sufficient granularity of data.
UMA_HISTOGRAM_CUSTOM_COUNTS("XR.ARCore.DepthBufferSizeInPixels",
buffer_size / 2, 5000, 55000, 50);
if (buffer_size / 2 > 240 * 180) {
// ARCore should report depth data buffers w/ resolution in the ballpark
// of 160x120. If the number of data entries is higher than 240 * 180
// (=43200), we should not return it. The threshold was picked by
// multiplying each expected dimension (160x120) by 1.5. Note that this
// translates to 2.25 increase in allowed number of pixels compared to
// the currently expected resolution.
return nullptr;
}
mojo_base::BigBuffer pixels(buffer_size);
// Interpret BigBuffer's data as a width by height array of uint16_t's and
......@@ -1805,6 +1828,8 @@ mojom::XRDepthDataPtr ArCoreImpl::GetDepthData() {
return mojom::XRDepthData::NewUpdatedDepthData(std::move(result));
}
// We don't have more recent data than what was already returned, inform the
// caller that previously returned data is still valid:
return mojom::XRDepthData::NewDataStillValid(
mojom::XRDepthDataStillValid::New());
}
......
......@@ -18219,6 +18219,17 @@ regressions. -->
</summary>
</histogram>
<histogram name="XR.ARCore.DepthBufferSizeInPixels" units="pixels"
expires_after="2021-12-01">
<owner>bialpio@chromium.org</owner>
<owner>xr-dev@chromium.org</owner>
<summary>
Recorded on every frame for as long as depth data is requested in an XR
session backed by ARCore device. Measures the number of pixels (width *
height) in the depth buffer obtained from ARCore.
</summary>
</histogram>
<histogram name="XR.RuntimeUsed" enum="XRDeviceId" expires_after="2021-07-01">
<owner>alcooper@chromium.org</owner>
<owner>mlamouri@google.com</owner>
......
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