Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix xr_v2 OpenXR Android #222

Closed
billyquith opened this issue Feb 13, 2022 · 16 comments · Fixed by #237
Closed

Fix xr_v2 OpenXR Android #222

billyquith opened this issue Feb 13, 2022 · 16 comments · Fixed by #237
Assignees
Labels
bug Something isn't working
Milestone

Comments

@billyquith
Copy link

billyquith commented Feb 13, 2022

The xr_v2 branch has a broken Android build. Notes on fixing.

The build appears to compile and link without error. It can be installed on a device but there appears to be no launch activity, so it it just hangs on the loading screen. The expected activity is com.unity3d.player.UnityPlayerActivity .

@billyquith billyquith added the bug Something isn't working label Feb 13, 2022
@billyquith
Copy link
Author

billyquith commented Feb 13, 2022

If we use the AndroidManifest.xml in plugins/Android (player project override) we can build and install our Android package, but it won't launch. This appears to be because the main activity has not launch intent.

If we untick the project override, and let Unity automatically make a manifest we get a compilation error. GoogleVR appears to conflicting with the Unity generated manifest. The keyboard properties conflict.

Note: Currently GoogleVR is what is used for all of the default audio (I think, regardless of the platform).


The solution to this was to remove GVR, as Unity merges manifests and GVR contains old keyboard manifest which clashes with Unity. Also I think the GVR main intent hijacks the Unity one.

Ideally, what we want to do is use the default Unity generated manifest and merge in any additional permissions that we require, e.g. passthrough.

@billyquith
Copy link
Author

I'm using my Unity adb wrapper uadb to help debug this. Using Cygwin on Windows. https://github.com/billyquith/bash_common

@billyquith
Copy link
Author

billyquith commented Feb 13, 2022

OpenXR Android requires ARM64, which requires IL2CPP. ARM64 is broken because of some assemblies that don't support it, e.g. NewtonSoft JSON, and PNGCs. - See #209. We can update the above assemblies to fix this problem.

The problem then becomes building ARM64. There currently issues with Gradle.
image

It seems other people have encountered this error. Gradle was upgraded in Unity 2020.3.14f1.

Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
  • Tried increasing JVM heap size. Same error.
  • The above "Gradle Daemon" message is apparently not an error. Also see gradle docs on this.

So the error which appears to be causing the problem is:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':launcher:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> More than one file was found with OS independent path 'lib/arm64-v8a/libopenxr_loader.so'. If you are using jniLibs and CMake IMPORTED targets, see https://developer.android.com/studio/preview/features#automatic_packaging_of_prebuilt_dependencies_used_by_cmake

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 7s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

UnityEditor.BuildPipeline:BuildPlayer (string[],string,UnityEditor.BuildTarget,UnityEditor.BuildOptions)
BuildTiltBrush:DoBuild (BuildTiltBrush/TiltBuildOptions) (at Assets/Editor/BuildTiltBrush.cs:1394)
BuildTiltBrush:MenuItem_Build () (at Assets/Editor/BuildTiltBrush.cs:324)
TiltBrush.BuildWindow:<MakeBuildActionsGui>b__41_0 () (at Assets/Editor/BuildWindow.cs:414)
UnityEditor.EditorApplication:Internal_CallDelayFunctions ()

In task launcher:mergeDebugNativeLibs - "More than one file was found with OS independent path lib/arm64-v8a/libopenxr_loader.so If you are using jniLibs and CMake IMPORTED targets, see"

OpenBrushMp/Temp> find . -name 'libopenxr_loader.so'
./gradleOut/unityLibrary/build/intermediates/library_jni/debug/jni/arm64-v8a/libopenxr_loader.so
./gradleOut/unityLibrary/build/intermediates/merged_jni_libs/debug/out/arm64-v8a/libopenxr_loader.so
./gradleOut/unityLibrary/build/intermediates/merged_native_libs/debug/out/lib/arm64-v8a/libopenxr_loader.so
./gradleOut/unityLibrary/build/intermediates/stripped_native_libs/debug/out/lib/arm64-v8a/libopenxr_loader.so
./gradleOut/unityLibrary/src/main/jniLibs/arm64-v8a/libopenxr_loader.so
./StagingArea/libs/arm64-v8a/libopenxr_loader.so

This problem goes away if you uninstall the Unity OpenXR plugin whilst the Oculus XR plugin is installed.

@billyquith
Copy link
Author

billyquith commented Feb 13, 2022

With GoogleVR removed, the GvrAudioSource is removed. This has been renamed (temporarily?) to the Unity AudioSource. Related issue #185.

OpenXR has audio on the way.: https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XR_OCULUS_audio_device_guid

@mikeskydev
Copy link
Member

gvr code was partially restored in 53c2cf2 and select classes removed in d43bb15

Also making a note of the warnings generated by switching to unity's internal newtonsoft JSON:
image

@mikeskydev
Copy link
Member

Noting that we've changed over to IL2CPP during this process but we have noted issues that were previously reverted: #209

Updated with new data: #209 (comment)

@billyquith
Copy link
Author

billyquith commented Feb 19, 2022

We currently have a lack of consistency. Mike can run on Android but I get a black screen. Still getting silent problems, removing all of GVR doesn't work so there must be something in there being used, but if you remove it there are no warnings or errors at compilation or runtime. Or at least, nothing that looks relevant. Mike is on 2020.3.27. I am on 2020.3.22. I will update to see if there are Unity Android changes, that perhaps make a difference.


I updated to Unity 2020.3.29 but still have issues. Oculus link mode not working, or Android. Runs in editor but no link preview in device. Android compiles and runs but black screen. - UnityXR mode, Oculus OpenXR mode, with and without Unity OpenXR plugin.

@billyquith
Copy link
Author

billyquith commented Feb 19, 2022

PC version (standalone and Unity) contains the following error which looks to stop brushes being created. So you can run the PC version but can't draw. - Controller rotations are wrong in PC version so we may have to rotate per version.

TypeLoadException: Could not find method due to a type load error
TiltBrush.MasterBrush..ctor () (at Assets/Scripts/Brushes/MasterBrush.cs:103)
System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) (at <695d1cc93cca45069c528c15c9fdd749>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Activator.CreateInstance[T] () (at <695d1cc93cca45069c528c15c9fdd749>:0)
TiltBrush.Pool`1[T].Get () (at Assets/Scripts/Util/Pool.cs:70)
TiltBrush.QuadStripBrush.InitBrush (TiltBrush.BrushDescriptor desc, TiltBrush.TrTransform localPointerXf) (at Assets/Scripts/Brushes/QuadStripBrush.cs:166)
TiltBrush.QuadStripBrushStretchUV.InitBrush (TiltBrush.BrushDescriptor desc, TiltBrush.TrTransform localPointerXf) (at Assets/Scripts/Brushes/QuadStripBrushStretchUV.cs:48)
TiltBrush.BaseBrushScript.Create (UnityEngine.Transform parent, TiltBrush.TrTransform xfInParentSpace, TiltBrush.BrushDescriptor desc, UnityEngine.Color color, System.Single size_PS) (at Assets/Scripts/Brushes/BaseBrushScript.cs:82)
TiltBrush.PointerScript.CreatePreviewLine () (at Assets/Scripts/PointerScript.cs:645)
TiltBrush.PointerScript.UpdatePointer () (at Assets/Scripts/PointerScript.cs:473)
TiltBrush.PointerManager.Update () (at Assets/Scripts/PointerManager.cs:505)

This appears to happen because we switched to Net 2.0 support. If I revert back to Net 4.x standalone works and has brushes. Oculus link still not previewing with this setting.

Moving back to Oculus XR and not Unity OpenXR fixes Oculus link.

@billyquith
Copy link
Author

billyquith commented Feb 19, 2022

Oh joy, now I'm getting an error on building Android,

_btb_ BuildPipeline.BuildPlayer() returned: "Errors:
Build player
  Building Player failed
Exporting project
  DirectoryNotFoundException: Could not find a part of the path "Temp\StagingArea\raw\Support\shaders\brushes\CoarseBristles-1161af82-50cf-47db-9706-0c3576d43c43\CoarseBristles-1161af82-50cf-47db-9706-0c3576d43c43-v10.0-MainTex.png" or "C:\Code\Public\Builds\UnityXRMobile_Debug_OpenBrush_Il2cpp_FromGui\com.icosa.openbrush.apk\unityLibrary\src\main\assets\Support\shaders\brushes\CoarseBristles-1161af82-50cf-47db-9706-0c3576d43c43\CoarseBristles-1161af82-50cf-47db-9706-0c3576d43c43-v10.0-MainTex.png""
UnityEngine.Debug:LogFormat (string,object[])
BuildTiltBrush:Note (string,object[]) (at Assets/Editor/BuildTiltBrush.cs:1683)
BuildTiltBrush:DoBuild (BuildTiltBrush/TiltBuildOptions) (at Assets/Editor/BuildTiltBrush.cs:1408)
BuildTiltBrush:MenuItem_Build () (at Assets/Editor/BuildTiltBrush.cs:324)
TiltBrush.BuildWindow:<MakeBuildActionsGui>b__45_0 () (at Assets/Editor/BuildWindow.cs:421)
UnityEditor.EditorApplication:Internal_CallDelayFunctions ()

Initial guess: I think this is due to a filepath being too long. 🤦

"C:\Code\Public\Builds\UnityXRMobile_Debug_OpenBrush_Il2cpp_FromGui\com.icosa.openbrush.apk\unityLibrary\src\main\assets\Support\shaders\brushes\CoarseBristles-1161af82-50cf-47db-9706-0c3576d43c43\CoarseBristles-1161af82-50cf-47db-9706-0c3576d43c43-v10.0-MainTex.png""


Looks like other people had similar issue. Trimmed root length appears to work now.

Apparently in Win 10 the MAX_PATH = 260 limit has been removed, but you have to opt-in.

@mikeskydev
Copy link
Member

Initial guess: I think this is due to a filepath being too long. 🤦

I think this is the case, @PerlinWarp had a similar issue i think?

@mikeskydev
Copy link
Member

image

ExportFbx relies on the vendor name being present in App.cs, which was changed in 234624f. This will only be caught in editor if the FBX_SUPPORTED FBXSDK_RUNTIME defines are enabled.

@billyquith
Copy link
Author

billyquith commented Feb 20, 2022

With current work UnityXR PC build appears to work, using Oculus XR plugin, and Oculus link works. However Android, builds, installs but does not display.

Getting this error spamming a lot:

02-20 22:11:29.210  2036  2343 W Telemetry: [OpenXR] xrGetReferenceSpaceBoundsRect: unsupported reference space; 

xrGetReferenceSpaceBoundsRect docs. "The runtime must return XR_ERROR_REFERENCE_SPACE_UNSUPPORTED if the XrReferenceSpaceType passed in createInfo is not supported by this session."

A similar issue.

A reference space appears to be created without error. Not sure if this is the same reference space as the one in the error spam.

02-20 22:37:53.921  2578  2657 I OpenXR  : xrCreateReferenceSpace: Spaces info
02-20 22:37:53.921  2578  2657 I OpenXR  : xrCreateReferenceSpace: Local version=57
02-20 22:37:53.921  2578  2657 I OpenXR  : xrCreateReferenceSpace: RawFromLocal       = (-0.000, -0.245, -0.000, 0.970), (-0.11, -0.08, -0.80)
02-20 22:37:53.921  2578  2657 I OpenXR  : xrCreateReferenceSpace: RawFromLocalTilted = (-0.216, -0.253, -0.126, 0.935), (-0.11, -0.08, -0.80)
02-20 22:37:53.921  2578  2657 I OpenXR  : xrCreateReferenceSpace: Stage IsValid=true
02-20 22:37:53.921  2578  2657 I OpenXR  : xrCreateReferenceSpace: Stage Width=1.523281, Depth=1.446754
02-20 22:37:53.921  2578  2657 I OpenXR  : xrCreateReferenceSpace: RawFromStage       = (0.000, -0.477, 0.000, 0.879), (-0.26, -0.88, -0.03)
02-20 22:37:53.921  2578  2657 I GuardianInput: GuardianInput::Resume ... intializing session bound objects.
02-20 22:37:53.921  2578  2657 I OpenXR_Actions: ------------ xrCreateActionSpace -----------
02-20 22:37:53.921  2578  2657 I OpenXR_Actions: ------------ xrCreateActionSpace -----------
02-20 22:37:53.921  2578  2657 I OpenXR_Hands: ------------ xrCreateHandTrackerEXT -----------
02-20 22:37:53.921  2578  2657 I OpenXR_Hands: ------------ xrCreateHandTrackerEXT -----------

Upgraded to Unity 2020.3.29 from 2020.3.22, reset Library, and then this eventually worked. There are fixes in 23-29. Also had to uninstall 22 and reset Library again.

@billyquith
Copy link
Author

This mostly seems to be working now. The final issue, and why the launch intent wasn't found was that the package name was wrong. Unity appends "unityeditor" to the name. This is fixed in the branch. You can use apkanalyser manifest print to see the manifest used in the APK.

@billyquith billyquith self-assigned this Mar 12, 2022
@billyquith billyquith changed the title Fix xr_v2 Android Fix xr_v2 OpenXR Android Mar 12, 2022
@billyquith
Copy link
Author

@mikeage is having issues with Oculus spatializer building for CI. Need a repro.

@mikeskydev mikeskydev linked a pull request Apr 30, 2022 that will close this issue
@mikeskydev
Copy link
Member

We discovered TB didn't use the Oculus Spatializer as the README didn't specify importing it for builds.

@mikeskydev
Copy link
Member

@billyquith Do you feel this is in a good place to close out w.r.t compatibility on quest 2? I feel other android headsets deserve their own issues to track, but this should be fairly stable on quest now.

@mikeskydev mikeskydev added this to the v2.0 milestone Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants