cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot launch OpenXR game from other 2D activity or apps, Transitions fails and XR game crashes

nimavnova
Honored Guest

Original issue:

I am trying to create a normal 2D app to let the user perform some operations that are much easier to be maintained and handled in a Java/Kotlin app. Like fetch data and choosing some options, login and acquire a token, get location and etc. Then I want to send the user to an NativeActivity which starts OpenXR session and immersive part of the user experience starts. Unfortunately I can not start the native activity from the Kotlin code using Intents and startActivity. I managed to see the immersive mode for a sec but then it crashes shortly after creating XR session. 

I figured that there might be extra complications having native and Kotlin activities in the same app or issues in my OpenXR app itself, so I tried a simpler approach that can be reproduced easily to get help.

Simplified Issue, easy to reproduce: 
I have `XrSpaceWarp` sample from Oculus OpenXRSDK. No change to manifest-xml or the code, It works on it's own and I can run it via `adb` :

adb shell am start -n com.oculus.sdk.xrspacewarp/android.app.NativeActivity

Then I have a simple android app from project templates of AndroidStudio, and on click event of a button I create an Intent and try to launch the XrSpaceWarp example. 

val myIntent: Intent? = this.packageManager.getLaunchIntentForPackage("com.oculus.sdk.xrspacewarp");
// Or alternatively
//val myIntent = Intent(Intent.ACTION_MAIN)
//myIntent.setComponent(ComponentName("com.oculus.sdk.xrspacewarp", "android.app.NativeActivity"))
// Also tried setting all and some combination of the flags
if (myIntent != null) {
myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
myIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
myIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
}
try {
startActivity(myIntent)
} catch (e: ActivityNotFoundException) {
Log.d("dummy_app", "starting activity failed")
}

 Then the XrSpaceWarp app starts and I can see the scene (yellow floating cubes) for half a second, and then it crashes.

The manifest of the XrSpaceWarp sample app is:

 

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
		package="com.oculus.sdk.xrspacewarp"
		android:versionCode="1"
		android:versionName="1.0" android:installLocation="auto" >

	<!-- Tell the system this app requires OpenGL ES 3.1. -->
	<uses-feature android:glEsVersion="0x00030001" android:required="true"/>
    <uses-feature android:name="android.hardware.vr.headtracking" android:required="true" />
	<uses-permission android:name="android.permission.INTERNET" />
	<!-- Volume Control -->
	<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

	<application android:allowBackup="false" android:label="xrspacewarp" android:hasCode="false">
    <meta-data android:name="com.oculus.supportedDevices" android:value="all" />
    <!-- The activity is the built-in NativeActivity framework class. -->
		<!-- launchMode is set to singleTask because there should never be multiple copies of the app running. -->
		<!-- Theme.Black.NoTitleBar.Fullscreen gives solid black instead of a (bad stereoscopic) gradient on app transition. -->
		<!-- If targeting API level 24+, configChanges should additionally include 'density'. -->
		<!-- If targeting API level 24+, android:resizeableActivity="false" should be added. -->
		<activity
				android:name="android.app.NativeActivity"
				android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
				android:launchMode="singleTask"
				android:screenOrientation="landscape"
				android:configChanges="screenSize|screenLayout|orientation|keyboardHidden|keyboard|navigation|uiMode">
			<!-- Tell NativeActivity the name of the .so -->
			<meta-data android:name="android.app.lib_name" android:value="xrspacewarp" />
			<!-- This filter lets the apk show up as a launchable icon. -->
			<intent-filter>
				<action android:name="android.intent.action.MAIN" />
				<category android:name="com.oculus.intent.category.VR" />
				<category android:name="android.intent.category.LAUNCHER" />
			</intent-filter>
		</activity>
	</application>
</manifest>

 



I have tried this with different flags, adding more intent filters in the XR app with other actions than MAIN and categories and also other apps (like other games on the headset that I installed from the store) and same thing happens. I can see the other activity starts and also the XR-session and GLES context and everything, but it can not maintain the focus and the session. There are some permission errors I can see in all cases:

 

VrDeviceManagerService  vrdevicemanagerserver                E  Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.SET_VR_DEVICE_PARAMS
VrDeviceManagerService  vrdevicemanagerserver                E  Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.READ_VR_DEVICE_PARAMS
VrDeviceManagerService  vrdevicemanagerserver                E  Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.SET_VR_DEVICE_PARAMS
VrDeviceManagerService  vrdevicemanagerserver                E  Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.READ_VR_DEVICE_PARAMS
VrDeviceManagerService  vrdevicemanagerserver                E  Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.SET_VR_DEVICE_PARAMS
VrDeviceManagerService  vrdevicemanagerserver                E  Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.READ_VR_DEVICE_PARAMS
TREX                    com.oculus.sdk.xrspacewarp           E  Interface version 3 was not found. Check debug build for more information.
VrDeviceManagerService  vrdevicemanagerserver                E  Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.SET_VR_DEVICE_PARAMS
VrDeviceManagerService  vrdevicemanagerserver                E  Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.READ_VR_DEVICE_PARAMS
VrDeviceManagerService  vrdevicemanagerserver                E  Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.SET_VR_DEVICE_PARAMS
VrDeviceManagerService  vrdevicemanagerserver                E  Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.READ_VR_DEVICE_PARAMS
VrDeviceManagerService  vrdevicemanagerserver                E  Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.SET_VR_DEVICE_PARAMS
VrDeviceManagerService  vrdevicemanagerserver                E  Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.READ_VR_DEVICE_PARAMS
InputDispatcher         system_server                        E  But another display has a focused window
                                                                                                      FocusedWindows:
                                                                                                        displayId=0, name='4af4f2f Shell.EventInterceptor'
VrDeviceManagerService  vrdevicemanagerserver                E  Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.SET_VR_DEVICE_PARAMS
VrDeviceManagerService  vrdevicemanagerserver                E  Permission denied: process 5393 (uid 10108) doesn't have the required permission: com.oculus.permission.READ_VR_DEVICE_PARAMS
OVRMediaServiceManager  com.oculus.horizon                   E  LivestreamingManager Not initialized
OVRMediaServiceManager  com.oculus.horizon                   E  LivestreamingManager Not initialized
OVRMediaServiceManager  com.oculus.horizon                   E  LivestreamingManager Not initialized
OsSdk                   com.oculus.sdk.xrspacewarp           E  error getting shared memory region, memory type: HeadTracker, failed with Status(-1, EX_SECURITY): 'requested shared memory region when not registered/focused'
OsSdk                   com.oculus.sdk.xrspacewarp           E  error getting shared memory region, memory type: HeadTracker, failed with Status(-1, EX_SECURITY): 'requested shared memory region when not registered/focused'
OsSdk                   com.oculus.sdk.xrspacewarp           E  error getting shared memory region, memory type: HeadTracker, failed with Status(-1, EX_SECURITY): 'request throttled'
OsSdk                   com.oculus.sdk.xrspacewarp           E  error getting shared memory region, memory type: HeadTracker, failed with Status(-1, EX_SECURITY): 'request throttled'
OsSdk                   com.oculus.sdk.xrspacewarp           E  error getting shared memory region, memory type: HeadTracker, failed with Status(-1, EX_SECURITY): 'request throttled'
OsSdk                   com.oculus.sdk.xrspacewarp           E  error getting shared memory region, memory type: HeadTracker, failed with Status(-1, EX_SECURITY): 'request throttled'
AnalyticsEvent          com...us.identitymanagement.service  E  could not set key=selection_args value=null
QplClient               com.oculus.systemux:SystemUX         E  com.oculus.systemux: init() called multiple times.
QplClient               com.oculus.systemux:SystemUX         E  com.oculus.systemux: init() called multiple times.
XrSpaceWarp             com.oculus.sdk.xrspacewarp           E  OpenXR error: r = xrPollEvent(app->Instance, &eventDataBuffer): ??_t
XrSpaceWarp             com.oculus.sdk.xrspacewarp           E  OpenXR error: xrDestroySwapchain(frameBuffer->ColorSwapChain.Handle): 
XrSpaceWarp             com.oculus.sdk.xrspacewarp           E  OpenXR error: xrDestroySwapchain(frameBuffer->MotionVectorSwapChain.Handle): 
XrSpaceWarp             com.oculus.sdk.xrspacewarp           E  OpenXR error: xrDestroySwapchain(frameBuffer->MotionVectorDepthSwapChain.Handle): 
XrSpaceWarp             com.oculus.sdk.xrspacewarp           E  OpenXR error: xrDestroySwapchain(frameBuffer->ColorSwapChain.Handle): 
XrSpaceWarp             com.oculus.sdk.xrspacewarp           E  OpenXR error: xrDestroySwapchain(frameBuffer->MotionVectorSwapChain.Handle): 
XrSpaceWarp             com.oculus.sdk.xrspacewarp           E  OpenXR error: xrDestroySwapchain(frameBuffer->MotionVectorDepthSwapChain.Handle): 
XrSpaceWarp             com.oculus.sdk.xrspacewarp           E  OpenXR error: xrDestroySwapchain(scene->QuadSwapChain.Handle): 
XrSpaceWarp             com.oculus.sdk.xrspacewarp           E  OpenXR error: xrDestroySpace(appState.HeadSpace): 
XrSpaceWarp             com.oculus.sdk.xrspacewarp           E  OpenXR error: xrDestroySpace(appState.LocalSpace): 
XrSpaceWarp             com.oculus.sdk.xrspacewarp           E  OpenXR error: xrDestroySpace(appState.FakeStageSpace): 
XrSpaceWarp             com.oculus.sdk.xrspacewarp           E  OpenXR error: xrDestroySession(appState.Session): `-Jt
OpenXR-Loader           com.oculus.sdk.xrspacewarp           E  Error [GENERAL | xrDestroyInstance | OpenXR-Loader] : Instance handle is XR_NULL_HANDLE.
XrSpaceWarp             com.oculus.sdk.xrspacewarp           E  OpenXR error: xrDestroyInstance(appState.Instance): oyInstance
 BpTransact...edListener surfaceflinger                       E  Failed to transact (-32)

 

I have tried the same thing with AndroidStudio's template projects of Native activity and Native GameActivity (that draws some simple android logo with OpenGL) and they work, so its definitely not because its a native activity or trouble with GL context, its the Immersive mode causing the problem and the fact that I am starting it from a 2D app.

I would apricate if someone could help me to make this solution work or share their experience. Is it even possible to switch to OpenXR app from a 2D app at all?

5 REPLIES 5

avolodin
Explorer

I'm looking for achieving exactly the same, would be great to receive some comments from Meta on this

karthiikk
Explorer

Facing the same isssue, did you find any solution??

avolodin
Explorer

I thought I would share this link that I stumbled upon: https://stackoverflow.com/questions/76970641/how-can-i-mix-vr-mode-and-2d-mode-activities-in-the-sam...

 

I didn't try it myself yet but maybe it will help us to get there! SteamLink definitely achieves that so we have to find out if that's a private API that Valve received from Meta or a cleverly combination of system calls.

does the solution on stackoverflow work for you??

diamondvar
Honored Guest

I was able to launch a 3D app from a 2D app with the following code:

val intent = context.packageManager.getLaunchIntentForPackage(packageName)
if (intent == null) {
    Log.d("MyApp", "No launch intent for ${packageName}")
    return
}
intent.putExtra("intent_cmd", "")
intent.putExtra("intent_pkg", "com.oculus.vrshell")
context.startActivity(intent)