Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
to_the_cosmic_end's avatar
1 year ago

2D screen goes black when resizing the window (jetpack compose)

Hi, I am trying to build a simple hybrid app but the problem is as soon as I resize my window, it goes completely black.

here is the Basic MainActivity:

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent {
            App()
        }
    }
}

@Composable
fun App() {
    Column {
        Text("Hello World!", color = Color.White)
    }
}

and here is the manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:horizonos="http://schemas.horizonos/sdk">

    <horizonos:uses-horizonos-sdk
        horizonos:minSdkVersion="69"
        horizonos:targetSdkVersion="69"
        />

    <uses-feature
        android:name="android.hardware.vr.headtracking"
        android:required="true"
        />

    <uses-feature
        android:name="oculus.software.handtracking"
        android:required="false"
        />
    <uses-permission android:name="com.oculus.permission.HAND_TRACKING" />

    <uses-feature
        android:name="com.oculus.experimental.enabled"
        android:required="true"
        />

    <uses-feature
        android:name="com.oculus.feature.PASSTHROUGH"
        android:required="false"
        />

    <uses-feature
        android:name="com.oculus.feature.VIRTUAL_KEYBOARD"
        android:required="false"
        />

    <uses-feature
        android:name="oculus.software.vr.app.hybrid"
        android:required="false"
        />

    <uses-feature android:glEsVersion="0x00030001" />

    <uses-feature
        android:name="oculus.software.overlay_keyboard"
        android:required="false"
        />

    <uses-feature
        android:name="com.oculus.feature.RENDER_MODEL"
        android:required="false"
        />
    <uses-permission android:name="com.oculus.permission.RENDER_MODEL" />

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:label="@string/app_name"
        android:theme="@style/Theme.PanelAppThemeTransparent"
        android:supportsRtl="true">

        <meta-data
            android:name="com.oculus.supportedDevices"
            android:value="quest2|questpro|quest3"
            />
        <meta-data
            android:name="com.oculus.handtracking.version"
            android:value="V2.0"
            />
        <meta-data android:name="com.oculus.vr.focusaware" android:value="true" />

        <uses-native-library
            android:name="libossdk.oculus.so"
            android:required="true"
            />

        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:screenOrientation="landscape">

            <meta-data android:name="com.oculus.vrshell.free_resizing_lock_aspect_ratio"
            android:value="true" />
            <layout android:defaultHeight="800dp" android:defaultWidth="800dp" />
            <meta-data
                android:name="com.oculus.vrdesktop.control_bar_config"
                android:value="{'show_title':false,'show_report_bug':false,'with_back_button':false, 'use_activity_label':false}"
                />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="com.oculus.intent.category.2D" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

</manifest>

10 Replies

Replies have been turned off for this discussion
    • to_the_cosmic_end's avatar
      to_the_cosmic_end
      Protege

      This solution does not work on my project. 
      Here is the screenshot when the app is first launched:App launched

      and here is after the window is resized:
      After window is resized

      I am guessing maybe spatial SDK works with XML for initial 2D screen and the Jetpack compose can be embedded only in the 2D panel inside the 3D screen?

  • JadeBird's avatar
    JadeBird
    Honored Guest

    How do you start the app? I had a similar issue, if I start the app using Android Studio or adb, resize would make the app go black. But if I start it from the shell then it works fine.

    • to_the_cosmic_end's avatar
      to_the_cosmic_end
      Protege

      I've been running it from Android Studio. Can you tell me how to start the app from the shell? I tried this command but with same result: 

      adb shell am start -n com.meta.spatial.samples.hybridsample/com.meta.spatial.samples.hybridsample.Ma
      inActivity

       

  • JadeBird's avatar
    JadeBird
    Honored Guest

    Sorry, I meant the Meta UI shell πŸ˜€. In the headset go to the Applications Library and launch it from there. Or you might already have in the taskbar.

  • I had the same issue and fixed by adding the following attributes to the hybrid activity:

     

     

    android:configChanges="screenSize|screenLayout|orientation|keyboardHidden|keyboard|navigation|uiMode"

     

     


    My activity block ended up looking like this:

     

     

           <activity
                android:name=".HomeActivity"
                android:exported="true"
                android:launchMode="singleTask"
                android:resizeableActivity="true"
                android:configChanges="screenSize|screenLayout|orientation|keyboardHidden|keyboard|navigation|uiMode"
                android:screenOrientation="landscape">
                <meta-data
                    android:name="com.oculus.vrshell.supports_free_resizing"
                    maxSizeX="1600"
                    maxSizeY="1000"
                    minSizeX="800"
                    minSizeY="500"
                    android:value="true" />
    
                <layout
                    android:defaultWidth="1100dp"
                    android:defaultHeight="650dp" />
    
                <meta-data
                    android:name="com.oculus.vrdesktop.control_bar_config"
                    android:value="{&apos;show_title&apos;:false,&apos;show_report_bug&apos;:false,&apos;with_back_button&apos;:false, &apos;use_activity_label&apos;:false}" />
    
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.DEFAULT" />
                    <category android:name="com.oculus.intent.category.2D" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>

     

     


    Really hope this helps πŸ™‚ 

  • I'm not exactly sure what worked but now in Quest v71, it seems to be working as expected. 

  • kane7832's avatar
    kane7832
    Honored Guest

    The 2D screen going black during window resizing could be due to rendering issues. Check your graphics settings or update drivers. Similar to resolving homeworkify not working common issues and find solutions when Homeworkify isn’t working effectively, troubleshooting often involves identifying compatibility issues and updating software to ensure seamless performance without disruptions.