Don't use XrHostActivity during tests
Adds infrastructure to tell XrSessionCoordinator whether an additional activity (the XrHostActivity) should be created or not. At present, this will only be true when the XrServiceTestHook is set (i.e. during tests). While attempting to enable the current WebXr xr_browser_tests in android_browsertests issues were discovered with the activity lifecycle. Issue 381076469 tracks a fix to hopefully remove this workaround. Bug: 381000093,381076469 Change-Id: I16564f23ead58d7e4f31af1d0f0c859a05a0d566 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6065324 Commit-Queue: Alexander Cooper <alcooper@chromium.org> Reviewed-by: Piotr Bialecki <bialpio@chromium.org> Cr-Commit-Position: refs/heads/main@{#1391412}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
33076cc70b
commit
7f146ee5bb
components/webxr/android
java
src
org
chromium
components
device/vr/openxr
@ -174,7 +174,7 @@ public class XrSessionCoordinator {
|
||||
}
|
||||
|
||||
@CalledByNative
|
||||
private void startXrSession() {
|
||||
private void startXrSession(final WebContents webContents, boolean needsSeparateActivity) {
|
||||
if (DEBUG_LOGS) Log.i(TAG, "startXrSession");
|
||||
// The higher levels should have guaranteed that we're only called if there isn't any other
|
||||
// active session going on.
|
||||
@ -186,8 +186,16 @@ public class XrSessionCoordinator {
|
||||
mActiveSessionType = SessionType.VR;
|
||||
sActiveSessionAvailableSupplier.set(SessionType.VR);
|
||||
|
||||
Intent intent = XrHostActivity.createIntent(getApplicationContext());
|
||||
getApplicationContext().startActivity(intent);
|
||||
if (needsSeparateActivity) {
|
||||
Intent intent = XrHostActivity.createIntent(getApplicationContext());
|
||||
getApplicationContext().startActivity(intent);
|
||||
} else {
|
||||
XrSessionCoordinatorJni.get()
|
||||
.onXrHostActivityReady(
|
||||
mNativeXrSessionCoordinator,
|
||||
XrSessionCoordinator.this,
|
||||
getActivity(webContents));
|
||||
}
|
||||
}
|
||||
|
||||
private void endSessionFromXrHost() {
|
||||
|
@ -37,8 +37,10 @@ void OpenXrPlatformHelperAndroid::GetPlatformCreateInfo(
|
||||
auto activity_ready_callback =
|
||||
base::BindOnce(&OpenXrPlatformHelperAndroid::OnXrActivityReady,
|
||||
base::Unretained(this), std::move(result_callback));
|
||||
session_coordinator_->RequestXrSession(std::move(activity_ready_callback),
|
||||
std::move(shutdown_callback));
|
||||
session_coordinator_->RequestXrSession(
|
||||
create_info.render_process_id, create_info.render_frame_id,
|
||||
create_info.needs_separate_activity, std::move(activity_ready_callback),
|
||||
std::move(shutdown_callback));
|
||||
}
|
||||
|
||||
void OpenXrPlatformHelperAndroid::OnXrActivityReady(
|
||||
|
@ -93,15 +93,22 @@ void XrSessionCoordinator::RequestVrSession(
|
||||
}
|
||||
|
||||
void XrSessionCoordinator::RequestXrSession(
|
||||
int render_process_id,
|
||||
int render_frame_id,
|
||||
bool needs_separate_activity,
|
||||
ActivityReadyCallback ready_callback,
|
||||
device::JavaShutdownCallback shutdown_callback) {
|
||||
DVLOG(1) << __func__;
|
||||
DVLOG(1) << __func__
|
||||
<< ": needs_separate_activity=" << needs_separate_activity;
|
||||
JNIEnv* env = AttachCurrentThread();
|
||||
|
||||
activity_ready_callback_ = std::move(ready_callback);
|
||||
java_shutdown_callback_ = std::move(shutdown_callback);
|
||||
|
||||
Java_XrSessionCoordinator_startXrSession(env, j_xr_session_coordinator_);
|
||||
Java_XrSessionCoordinator_startXrSession(
|
||||
env, j_xr_session_coordinator_,
|
||||
webxr::GetJavaWebContents(render_process_id, render_frame_id),
|
||||
needs_separate_activity);
|
||||
}
|
||||
|
||||
void XrSessionCoordinator::EndSession() {
|
||||
|
@ -55,7 +55,10 @@ class XrSessionCoordinator : public device::XrJavaCoordinator {
|
||||
int render_process_id,
|
||||
int render_frame_id) override;
|
||||
|
||||
void RequestXrSession(ActivityReadyCallback ready_callback,
|
||||
void RequestXrSession(int render_process_id,
|
||||
int render_frame_id,
|
||||
bool needs_separate_activity,
|
||||
ActivityReadyCallback ready_callback,
|
||||
device::JavaShutdownCallback shutdown_callback);
|
||||
|
||||
// Methods called from the Java side.
|
||||
|
@ -133,6 +133,11 @@ std::vector<XrEnvironmentBlendMode> OpenXrApiWrapper::GetSupportedBlendModes(
|
||||
return environment_blend_modes;
|
||||
}
|
||||
|
||||
// static
|
||||
bool OpenXrApiWrapper::NeedsSeparateActivity() {
|
||||
return test_hook_ == nullptr;
|
||||
}
|
||||
|
||||
OpenXrApiWrapper::OpenXrApiWrapper() = default;
|
||||
|
||||
OpenXrApiWrapper::~OpenXrApiWrapper() {
|
||||
|
@ -77,6 +77,8 @@ class OpenXrApiWrapper {
|
||||
|
||||
static VRTestHook* GetTestHook();
|
||||
|
||||
static bool NeedsSeparateActivity();
|
||||
|
||||
bool UpdateAndGetSessionEnded();
|
||||
|
||||
// The supplied graphics_binding is guaranteed by the caller to exist until
|
||||
|
@ -131,6 +131,8 @@ void OpenXrDevice::RequestSession(
|
||||
OpenXrCreateInfo create_info;
|
||||
create_info.render_process_id = options->render_process_id;
|
||||
create_info.render_frame_id = options->render_frame_id;
|
||||
create_info.needs_separate_activity =
|
||||
OpenXrApiWrapper::NeedsSeparateActivity();
|
||||
platform_helper_->CreateInstanceWithCreateInfo(
|
||||
create_info,
|
||||
base::BindOnce(&OpenXrDevice::OnCreateInstanceResult,
|
||||
|
@ -26,6 +26,7 @@ class OpenXrGraphicsBinding;
|
||||
struct OpenXrCreateInfo {
|
||||
int render_process_id;
|
||||
int render_frame_id;
|
||||
bool needs_separate_activity = true;
|
||||
};
|
||||
|
||||
// This class exists to help provide an interface for working with OpenXR
|
||||
|
Reference in New Issue
Block a user