Skip to main content
Inspiring
October 29, 2024

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

  • October 29, 2024
  • 10 replies
  • 2224 views

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>
This topic has been closed for replies.

10 replies

Meta Employee
October 30, 2024

Hi, to enable resizing, you also need to add the meta-data in the activity's manifest:

<meta-data android:name="com.oculus.vrshell.supports_free_resizing" android:value="true" />

Here's the sample hybrid app for resizing config:

https://github.com/meta-quest/Meta-Spatial-SDK-Samples/blob/b4f7b81bac7aa217cfa80598dcdf370d12b7514a/HybridSample/app/src/main/AndroidManifest.xml#L89C42-L89C64

 

Seeing is believing.
Inspiring
October 31, 2024

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?

Meta Employee
October 31, 2024

Hi, I tested it for Jetpack compose with hybrid panel, it works as expected.

It could be the layout issue within your panel. You may want to double check the hybrid app's config and your layout.

Hope these helps:

https://github.com/meta-quest/Meta-Spatial-SDK-Samples/commit/f3997c81da225d227056e9f854fcc215995023af

Seeing is believing.
New Participant
October 31, 2024

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.

Inspiring
November 1, 2024

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

 

New Participant
November 1, 2024

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.

New Participant
November 26, 2024

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 πŸ™‚ 

Inspiring
December 8, 2024

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

New Participant
January 9, 2025

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.