Jump to content

C++ OpenXR Application with multiple Android activities


ste-phil

Recommended Posts

Hello,

I am required to develop an OpenXR application with Java/C++ that has support for Android Activity switching. I reverse engineered the HTC unity package to determine the correct stuff that needs to be in the Android Manifest file and to be able to create this in a simple android studio project.

My project structure should look like the following. An Android application with 2 activities. The "MAIN" activity is just a 2D activity (could also be an OpenXR 'immersive' activity, depending on our future needs). This main activity is used to provide some input and latter on open the 2nd activity via an Android Intent. The second activity is basically on OpenXR application based on the hello_xr application provided by Khronos.  

Now the issue is that when it comes to switching from the main activity to the second one. I am currently switching via a simple Intent where I specify the target activity. This all works great because it calls the android_main() of the 2nd activity and executes the code (creatiion of an openxrinstance / session / etc) until  it comes to the actual rendering of the layers where the OpenXR runtime just passes the "shouldRender = false" flag in the xrWaitFrame() (https://registry.khronos.org/OpenXR/specs/1.0/man/html/xrWaitFrame.html). This stays like that forever (tested for at least a minute), so I am assuming it dead locked somewhere. 

Investigating logcat does not show any errors at all only a specific line that is printed forever while the screen stays black. Googling that line yields nothing so I am assuming it is something internal.

RENDER_ATWC: Prvious PredictedDisplay:11310562046231 >= New PredictedDisplay:11310561646160, Set New PredictedDisplay to 11310561746160

 

The application part of my android manifest looks like this: (When using the PlayerActivity as a startup activity everything works fine and the OpenXR application runs as expected)

    <application
        android:allowBackup="false"
        android:extractNativeLibs="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name">
        <activity
            android:name=".MainActivity"
            android:configChanges="screenSize|screenLayout|orientation|keyboardHidden|keyboard|navigation|uiMode|density"
            android:excludeFromRecents="false"
            android:exported="true"
            android:launchMode="singleTask"
            android:resizeableActivity="false"
            android:screenOrientation="landscape"
            android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
            tools:ignore="NonResizeableActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="org.khronos.openxr.intent.category.IMMERSIVE_HMD" />
            </intent-filter>
        </activity>
        <activity
            android:name=".PlayerActivity"
            android:configChanges="screenSize|screenLayout|orientation|keyboardHidden|keyboard|navigation|uiMode|density"
            android:excludeFromRecents="false"
            android:exported="true"
            android:launchMode="singleTask"
            android:resizeableActivity="false"
            android:screenOrientation="landscape"
            android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
            tools:ignore="NonResizeableActivity">

            <!-- Tell NativeActivity the name of the .so -->
            <meta-data
                android:name="android.app.lib_name"
                android:value="lib-name" />
            <intent-filter>
<!--                 <action android:name="android.intent.action.MAIN" />-->
<!--                 <category android:name="android.intent.category.LAUNCHER" />-->
                <category android:name="org.khronos.openxr.intent.category.IMMERSIVE_HMD" />
            </intent-filter>
        </activity>

 

If you want the full log of one run, I could also provide that. In order to reproduce the issue, its possible to use the hello_xr sample and extend it with a new Java activity that opens the hello_xr activity.

I would be glad to receive any input on that matter, because I have now been trying a lot of different stuff already and I have a feeling that it is somehow related to the underlying OpenXR runtime and I have no idea how to debug that.

 

 

Link to comment
Share on other sites

Hi,

thanks for the answer!

I am not using any SDK since I am making a native Android application. As far as I understand this is only required for Unity/Unreal projects. In my case, I am just using the required OpenXR Loader stated here (https://developer.vive.com/resources/openxr/unity/download/latest/) which then launches the already installed OpenXR Runtime already installed on the device.

I am currently just using some modified version of the hello_xr example by Khronos and Android Studio in conjunction with the Native development stuff (NDK, Cmake, Gradle, etc..) to make an APK that installs on the device.

 

 

Link to comment
Share on other sites

Sure thing, but then I will have to create a reproduction example before. I will have time to do this on Thursday/Friday. In the meantime, if you have any further suggestions feel free to let me know.

Link to comment
Share on other sites

Hi, I was able to make a sample which is based on the hello_xr project from OpenXR. Unfortunately the project was too big to upload here, so I put it on a WeTransfer https://we.tl/t-G7tnwnSVD2 where you can download it.

 

Run the project:

  • Open the android studio project located in the folder "OpenXR-SDK-Source\src\tests\hello_xr". 
  • If you want to switch to a single activity workflow to test the behaviour, just use the PlayerActivity as the Main/Launch Activity.

 

If you need any further information please let me know!

Thanks for the help.

Link to comment
Share on other sites

You should just be able to run any configuration directly. What's the issue when compiling? Maybe you need to get the required dependencies. (correct sdk version, ndk, cmake, etc)

Link to comment
Share on other sites

Hello just wanted to ask if there is any progress on this issue and if you will look into the issue at all. It would be very helpful for us to have some insight on what's going on and how to tackle this.

Thanks for the information.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...