Issue with Game Rendering Over Notch on Android 15 in Unity 2022.3 LTS

Hi,

I am using Unity 2022.3 LTS with URP, and I have a problem. On Android devices running Android 15, my game renders over the notch. However, the game works fine on devices with older Android versions.

If I use Unity 2020.3 LTS and run the build on the same Android 15 device, the notch is handled correctly.

I’m not sure what to do to fix this in Unity 2022.3. Can you help me?

Thank you!

There’s a setting Render Outside Safe Area in Player Settings, what value it holds?

hi @Tomas1856 , attaching the screenshot of the settings
Render outside the safe area is False

I also found this on google :

AND
Reddit - Dive into anything

I think this is related to change from Google as part of new Android 15 behavior, mainly this - Behavior changes: Apps targeting Android 15 or higher  |  Android Developers. Without repro it’s a bit hard to say. If you want, you can submit a bug with small repro attached, so our QA can look at it.

@Tomas1856 , I have reported a bug, here is the link to it :
https://unity3d.atlassian.net/servicedesk/customer/portal/2/IN-90986

We’re using 2022.3.38, and it works on that version. I’m not sure exactly which version introduced this issue, but 38 is fine, and 42 and later are not working

Hi @paradizlsCool , Thanks for your help, seems like it works fine on this ver “2022.3.38”

You’re welcome! Do you have any updates about the bug you reported?

The bug is in review state.
you can check it here :

https://unity3d.atlassian.net/servicedesk/customer/portal/2/IN-90986

Hi, I do not have permission to view this request. It seems I can only see mine and my organization’s.

Hi, The bug status is in review

This issue happens on the built-in render pipeline as well.
Basically any Android 15 phone cuts out parts of the screen of an Unity application.

Is there a fix in the works or?

I think ,there is no fix for this issue now.. I moved to previous version : “2022.3.38” . It does not have notch issue. @raydekk

I saw the workaround above - but I would like Unity to actually fix this and not just put a tooltip in the settings “This does not work for Android 15”

I found a way to fix this.

As you may know, Android 15 enforces edge-to-edge by default. This should only affect apps targeting Android 15. However, for some reason, it also affects apps that are not targeting Android 15 but are running on Android 15 when built with Unity. It seems to be related to windowLayoutInDisplayCutoutMode not being properly set or interpreted, I’m not entirely sure.

So, when targetSdkVersion < 15 (I’m targeting 14 in my case, but this should work for others as well), add a GameObject to your first loaded scene and attach the following code:

using UnityEngine;

[DefaultExecutionOrder(-1000)]
public class CutoutFix : MonoBehaviour
{
    void Awake()
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        try
        {
            using (var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
            {
                var activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");

                using (var version = new AndroidJavaClass("android.os.Build$VERSION"))
                {
                    int sdkInt = version.GetStatic<int>("SDK_INT");

                    if (sdkInt >= 35)
                    {
                        activity.Call("runOnUiThread", new AndroidJavaRunnable(() =>
                        {
                            using (var window = activity.Call<AndroidJavaObject>("getWindow"))
                            {
                                using (var layoutParams = window.Call<AndroidJavaObject>("getAttributes"))
                                {
                                    int LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER = 2;
                                    layoutParams.Set("layoutInDisplayCutoutMode", LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER);
                                    window.Call("setAttributes", layoutParams);
                                }
                            }
                        }));
                    }
                }
            }
        }
        catch (System.Exception e)
        {
            Debug.LogWarning("AndroidCutoutFix failed: " + e);
        }
#endif
    }
}

And that’s it. This sets layoutInDisplayCutoutMode to LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER. In my case, I needed LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER, but you can adapt the code to suit your needs.

Now, if you’re targeting Android 15, there’s one more thing you need to handle. Android 15 gives you a final opportunity to opt out of their edge-to-edge enforcement. After that, once you target Android 16, none of these workarounds will function anymore, and you’ll need to properly adapt your game to support edge-to-edge layouts.

To opt out of edge-to-edge, there appear to be several ways to do it. I tried many of them and will share the method that worked for me. Maybe I overcomplicated things a bit, but you’ll get the idea.

First, check which theme your game is using. I originally started my project in Unity 5 (2015), so things might be different now. Look for android:theme in your AndroidManifest.xml. In my case, it was:
android:theme="@style/UnityThemeSelector"

I decompiled my APK using apktool to inspect the styles.xml files inside the res/values folders. The highest versioned folder I found was values-v28, which means that this file is used for SDK >= 28 since no folder with a higher version exists. I copied this folder to create a new one called values-v35.

Inside styles.xml, I located the BaseUnityTheme (which is the parent of UnityThemeSelector) and added the following line:

<item name="android:windowOptOutEdgeToEdgeEnforcement">true</item>

I then created an .aar module in Android Studio, containing only the values-v35 folder, and added it to my project under Assets\Plugins\Android.

Additional information for windowOptOutEdgeToEdgeEnforcement :
https://stackoverflow.com/questions/78832459/how-to-preserve-the-space-of-the-status-bar-android-15

Erm I am targetting Android 15 on Unity 2022.3.62 for current and future android changes this year (16 KB page aligned etc).
It is rendering outside the safe area it seems.
Is it broken or not as this thread is not too clear? :slightly_smiling_face:

So Android 16 targeting is coming soon. Has anyone discovered any way of adapting the status bar inside a “Full Screen” mode? (since A16 enforces full screen) Maybe a workaround so that the status bar height is always respected depending on the phone screen size/resolution? Thank you.