We’re having serious issues with the Unity 2022 LTS versions and this is blocking work for us.
What are the steps to create a working XR project in Unity now?
The issue is a black screen on Android devices. Sometimes we can get a project to work by deleting Library, removing and reinstalling all XR packages but even then it often later fails on another machine until the steps are repeated.
You can reproduce the issue with these steps:
Create a new project in Unity 2022.3.2f1 (or any other LTS version) with the 3D template
Install the Universal RP package through Package Manager
Create the Universal Render Pipeline Asset and Renderer and add the ARBackgroundRendererFeature
Install the AR package collection (5 in total) through Package Manager
Add the AR Session and XR Origin (Mobile AR) setup to the default SampleScene and remember to delete MainCamera
Remove Vulkan from Graphics API, set Minimum API Level to 24, change Target Architecture to ARM64
Build for Android
The app will open with a black screen with my test phone with Android 11 and errors. The log is attached to this post. Curiously locking the screen and reopening the device seems to help.
To fix this:
Remove all AR packages
Close Unity, delete Library,
Install only Google ARCore XR Plugin
Build for Android
The errors are gone and everything works.
How can we set up the project so it could also support Magic Leap?
Also, what’s up with the jello effect when using the new XR Origin instead of the deprecated AR Session Origin?
There’s a noticeable jello effect with Android devices where AR content follows a frame or a few late behind the camera image. I have video footage if it’s needed but I’ve seen this happening on all Android builds if they are upgraded to use XR Origin.
I’ll file a bug report but would be nice to know if others experience this issue too. Happens with all 2022 LTS versions of Unity.
Below is some errors from logcat. This was repeated nonstop. And, as mentioned in above comment, trying to switch app back and forth or switch device off/on make it work. But open it for the first time will generated these errors, like it was not initialized properly when open it up, only when it was re enabled or refocus that it could work properly
My project is trying to introduce AR into the unity’s BoatAttack sample island project
2023/06/25 16:14:46.815 26774 26839 Error libEGL eglPresentationTimeANDROIDImpl:2221 error 300d (EGL_BAD_SURFACE)
2023/06/25 16:14:46.816 26774 26839 Error libEGL eglSwapBuffersWithDamageKHRImpl:1352 error 300d (EGL_BAD_SURFACE)
2023/06/25 16:14:46.830 26774 26774 Warn UnityMain type=1400 audit(0.0:44941): avc: denied { getattr } for name="dmabuf:" dev="dmabuf" ino=1 scontext=u:r:untrusted_app:s0:c8,c256,c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=filesystem permissive=0 app=com.UnityTechnologies.BoatAttack
2023/06/25 16:14:46.839 26774 26798 Info Unity Skipped rendering frame because GfxDevice is in invalid state (device lost)
2023/06/25 16:14:46.849 26774 26839 Error libEGL eglPresentationTimeANDROIDImpl:2221 error 300d (EGL_BAD_SURFACE)
2023/06/25 16:14:46.849 26774 26839 Error libEGL eglSwapBuffersWithDamageKHRImpl:1352 error 300d (EGL_BAD_SURFACE)
2023/06/25 16:14:46.862 26774 26774 Warn UnityMain type=1400 audit(0.0:44942): avc: denied { getattr } for name="dmabuf:" dev="dmabuf" ino=1 scontext=u:r:untrusted_app:s0:c8,c256,c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=filesystem permissive=0 app=com.UnityTechnologies.BoatAttack
2023/06/25 16:14:46.871 26774 26798 Info Unity Skipped rendering frame because GfxDevice is in invalid state (device lost)
2023/06/25 16:14:46.882 26774 26839 Error libEGL eglPresentationTimeANDROIDImpl:2221 error 300d (EGL_BAD_SURFACE)
2023/06/25 16:14:46.882 26774 26839 Error libEGL eglSwapBuffersWithDamageKHRImpl:1352 error 300d (EGL_BAD_SURFACE)
2023/06/25 16:14:46.894 26774 26774 Warn UnityMain type=1400 audit(0.0:44943): avc: denied { getattr } for name="dmabuf:" dev="dmabuf" ino=1 scontext=u:r:untrusted_app:s0:c8,c256,c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=filesystem permissive=0 app=com.UnityTechnologies.BoatAttack
2023/06/25 16:14:46.903 26774 26798 Info Unity Skipped rendering frame because GfxDevice is in invalid state (device lost)
2023/06/25 16:14:46.916 26774 26839 Error libEGL eglPresentationTimeANDROIDImpl:2221 error 300d (EGL_BAD_SURFACE)
2023/06/25 16:14:46.916 26774 26839 Error libEGL eglSwapBuffersWithDamageKHRImpl:1352 error 300d (EGL_BAD_SURFACE)
2023/06/25 16:14:46.930 26774 26774 Warn UnityMain type=1400 audit(0.0:44944): avc: denied { getattr } for name="dmabuf:" dev="dmabuf" ino=1 scontext=u:r:untrusted_app:s0:c8,c256,c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=filesystem permissive=0 app=com.UnityTechnologies.BoatAttack
2023/06/25 16:14:46.942 26774 26798 Info Unity Skipped rendering frame because GfxDevice is in invalid state (device lost)
2023/06/25 16:14:46.949 26774 26839 Error libEGL eglPresentationTimeANDROIDImpl:2221 error 300d (EGL_BAD_SURFACE)
2023/06/25 16:14:46.949 26774 26839 Error libEGL eglSwapBuffersWithDamageKHRImpl:1352 error 300d (EGL_BAD_SURFACE)
2023/06/25 16:14:46.966 26774 26774 Warn UnityMain type=1400 audit(0.0:44945): avc: denied { getattr } for name="dmabuf:" dev="dmabuf" ino=1 scontext=u:r:untrusted_app:s0:c8,c256,c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=filesystem permissive=0 app=com.UnityTechnologies.BoatAttack
2023/06/25 16:14:46.976 26774 26798 Info Unity Skipped rendering frame because GfxDevice is in invalid state (device lost)
I’m travelling and don’t have my Android test device with me now. I’ll try to get someone from our team try the AR Foundation samples.
I know that just by creating a new project in 2022 LTS from the 3D template, converting to URP, and importing the AR packages was enough to introduce the issues
I tested the AR Foundation samples in Unity 2022.3.3f1 LTS. Following the steps 2 and 3 by adding the URP package and changing the graphics pipeline did not cause the black screen to appear.
I then installed the AR Feature from the Package Manager (Step 4), which updated the AR Foundation, Apple ARKit XR plugin and Google ARCore XR plugin packages to 5.0.6, and the OpenXR plugin package to 1.8.1. This now caused the black screen issue to appear.
This is occurring for us after updating an existing project from 2022.3.1f1 to 2022.3.3f1.
This change also updated the OpenXR plugin from 1.7.0 to 1.8.1, but reversing this change in the manifest does not resolve the issue so I suspect it is with the UnityEngine version. Google ARCore XR plugin is 5.0.6 in both versions.
There are no mentions of ARCore/Presto in the logs (i.e. ArPresto::ArPresto_initialize) which are present when things are functioning correctly, so I suspect there’s an issue initializing ARCore in this Unity version.
In our specific scenario:
This occurs in our in CI builds (no cache, ubuntu)
Local/sideload builds (windows editor) do not reproduce the issue
Checking/unchecking “OpenXR” from the plug-in providers in XR Plug-in Management has no effect.
Downgrading Unity back to 2022.3.1f1 works around the issue (keeping OpenXR plugin at 1.8.1).
We are investigating some issues with selecting the AR Feature in the Package Manager that sound related. This seems silly but do you see the same issues when you add the packages individually instead of selecting the AR Feature?
This is no longer occurring for me after updating to 2022.3.4f1. Much else has changed in the project, so unsure if it was only a result of the version upgrade.
Ignore that - it still occurs intermittently in 2022.3.4f1. Attempting to tell the difference between project configuration for CI runs that would cause it to work only sometimes.
@andyb-unity This issue (black screen; no XR plugin loaded at runtime) can occur on at least both iOS and Android - and appears to be the result of preloaded assets for XR not being correctly loaded/configured on my ubuntu (CI, clean) builds.
My preloaded assets looked like the following (in idle editor, not during build):
While configured in this way, Android builds would succeed in CI and iOS builds would not work correctly (black screen, no permissions requested). Visa-versa Android builds would not work correctly when this got ‘stuck’ with iPhone/ARKit settings.
Observations (running an ubuntu CI build on github actions)
When preloaded assets are empty (in source control), ARCore is not correctly added to android builds (no session/subsystem starts) - black screen, no permissions request, but other UI works.
If I manually add the relevant android settings and shaders to the editor configuration, the build works. However, if I have added the android configurations, the iOS build will exhibit the symptoms and visa versa.
The correct settings are loaded during local builds (windows editor).
Temporary workaround: use a separate branch for each platform that has different preloaded assets.
Note: this appears to be a separate issue from the thread topic… (which also does reproduce for me on the ARFoundation samples)
Thanks @camogram . FYI the search feature on Unity forums is not the best, so it’s easy for us to lose track of these threads to follow up.
If you wouldn’t mind taking each of these bug numbers and posting in our GitHub issues: Issues · Unity-Technologies/arfoundation-samples · GitHub, that would be the easiest way for us to follow up with you and others who may want to follow these issues as we are able to investigate them.
@Lib_one Thanks for letting us know. I see that @camogram included the same information in their bug report. QA team is currently reviewing this issue.