Skip to content
This repository was archived by the owner on Nov 19, 2023. It is now read-only.

Commit e99355a

Browse files
committed
Fix lifecycle issues on Quest 2
1 parent 436f150 commit e99355a

File tree

7 files changed

+24
-34
lines changed

7 files changed

+24
-34
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/target
2+
/apk_target
23
*.sw*
34
/repos
45
Cargo.lock

Cargo.toml

+2-5
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ ndk-glue = "0.2.1"
3737
apk_label = "Bevy OpenXR wgpu"
3838
build_targets = ["aarch64-linux-android"]
3939
assets = "assets"
40-
libs = "libs"
41-
42-
[package.metadata.android.sdk]
40+
runtime_libs = "libs"
4341
min_sdk_version = 16
4442
target_sdk_version = 29
4543

@@ -62,10 +60,9 @@ resizeable_activity = "false"
6260
name = "com.oculus.vr.focusaware"
6361
value = "true"
6462

65-
[[package.metadata.android.intent_filter]]
63+
[[package.metadata.android.application.activity.intent_filter]]
6664
actions = ["android.intent.action.MAIN"]
6765
categories = ["com.oculus.intent.category.VR", "android.intent.category.LAUNCHER"]
68-
data = []
6966

7067
[[package.metadata.android.uses_permission]]
7168
name = "com.oculus.permission.HAND_TRACKING"

Makefile

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
install_cargo_apk:
2-
echo "Installing patched version of cargo-apk"
3-
cargo install --path repos/android-ndk-rs/cargo-apk
4-
51
download_dependencies:
62
mkdir -p repos
73
for i in android-ndk-rs bevy bevy_rapier gfx openxrs wgpu wgpu-rs; \
@@ -13,15 +9,15 @@ download_dependencies:
139
git -C repos/$$i checkout bevy_openxr; \
1410
fi; \
1511
done;
16-
12+
1713
git -C repos clone https://github.com/blaind/bevy_openxr.git
1814

1915
update_dependencies:
2016
for i in android-ndk-rs bevy bevy_rapier gfx openxrs wgpu wgpu-rs; \
2117
do \
2218
git -C repos/$$i pull; \
2319
done;
24-
20+
2521
git -C repos/bevy_openxr pull
2622
git pull
2723

@@ -38,8 +34,13 @@ adb_shell:
3834
$$ANDROID_SDK_ROOT/platform-tools/adb -d shell
3935

4036
run_xr_apk:
41-
cargo apk run --example xr_apk_scene --release
37+
CARGO_BUILD_TARGET_DIR=apk_target cargo apk run --example xr_apk_scene --release
4238

4339
run_xr_pc:
4440
cargo run --example xr_pc_scene
4541

42+
restart_apk:
43+
$$ANDROID_SDK_ROOT/platform-tools/adb shell am force-stop rust.example.xr_apk_scene
44+
$$ANDROID_SDK_ROOT/platform-tools/adb shell am start -a android.intent.action.MAIN -n rust.example.xr_apk_scene/android.app.NativeActivity
45+
46+

docs/install_oculus.md

+5-16
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,7 @@
55
Prequisite installation:
66

77
sudo apt-get install make openjdk-11-jre g++ libudev-dev libasound2-dev gcc
8-
9-
Currently a patched version of cargo-apk is required. Install it like this:
10-
11-
**NOTE! THIS WILL REPLACE PREVIOUSLY INSTALLED cargo-apk IN GLOBAL PATH!**
12-
13-
cargo install --path repos/android-ndk-rs/cargo-apk
14-
15-
or
16-
17-
install_cargo_apk
8+
cargo install cargo-apk
189

1910
If you have not setup udev yet, copy udev rules for Oculus Quest 2
2011

@@ -25,16 +16,14 @@ If you have not setup udev yet, copy udev rules for Oculus Quest 2
2516

2617
## Oculus OpenXR plugin
2718

28-
You must download `libopenxr_loader.so` from [Oculus OpenXR Mobile SDK](https://developer.oculus.com/downloads/package/oculus-openxr-mobile-sdk/) file. It should be stored to `libs/aarch64-linux-android` folder. It is at path `OpenXR/Libs/Android/arm64-v8a/Release` in the zip file.
19+
You must download `libopenxr_loader.so` from [Oculus OpenXR Mobile SDK](https://developer.oculus.com/downloads/package/oculus-openxr-mobile-sdk/) file. It should be stored to `libs/arm64-v8a` folder. It is at path `OpenXR/Libs/Android/arm64-v8a/Release` in the zip file.
2920

30-
$ ls -al libs/aarch64-linux-android/libopenxr_loader.so
31-
-rwxrwxr-x 1 user user 10639048 feb 13 14:46 libs/aarch64-linux-android/libopenxr_loader.so
21+
$ ls -al libs/arm64-v8a/libopenxr_loader.so
22+
-rwxrwxr-x 1 user user 10639048 feb 13 14:46 libs/arm64-v8a/libopenxr_loader.so
3223

33-
$ file libs/aarch64-linux-android/libopenxr_loader.so
24+
$ file libs/arm64-v8a/libopenxr_loader.so
3425
ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=..., with debug_info, not stripped
3526

36-
37-
3827
## Android SDK
3928

4029
You need android SDK & NDK to build .apk.

examples/xr_apk_scene.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ use xrbevy::{is_already_running, ExampleScenePlugin};
44
#[cfg_attr(target_os = "android", ndk_glue::main(backtrace = "on"))]
55
fn main() {
66
if is_already_running() {
7-
//return;
7+
// in android, main() can be called on resume
8+
// will create a new thread, but the process and existing App will be present
9+
println!("Already running - quit call to main()");
10+
} else {
11+
App::build()
12+
.add_plugin(ExampleScenePlugin)
13+
.add_plugin(bevy_openxr::OpenXRHandTrackingPlugin)
14+
.run();
815
}
9-
10-
App::build()
11-
.add_plugin(ExampleScenePlugin)
12-
.add_plugin(bevy_openxr::OpenXRHandTrackingPlugin)
13-
.run();
1416
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)