GodotVR / godot_openxr_vendors

Godot 4 wrapper for OpenXR vendors loaders and extensions
MIT License
92 stars 19 forks source link

XR_LOADER_DEBUG=all support on godot android #26

Open hammerandtongs opened 1 year ago

hammerandtongs commented 1 year ago

Exposing XR_LOADER_DEBUG might be useful for android XR debugging but android has restrictions on env use (each process has its own freestanding env).

https://registry.khronos.org/OpenXR/specs/1.0/loader.html#loader-debugging

I think the cleanest way to do that would be to modify the gradle build target something like

buildConfigField "String", "XR_LOADER_DEBUG", "\"${System.env.GODOT_ANDROID_XR_LOADER_DEBUG}\""

Then add GODOT_ANDROID_XR_LOADER_DEBUG to the build environment.

This could be checked in godotscript by

https://docs.godotengine.org/en/stable/classes/class_os.html#class-os-method-get-environment

*Warning this is untested as I don't have an android XR device.

BastiaanOlij commented 1 year ago

Is there any serious down side, performance wise or other, to including this switch?

Else I'd suggest instead of reacting to GODOT_ANDROID_XR_LOADER_DEBUG we react to the debug build system already build into the AAR build scripts.

There is a problem here that needs to be solved in Core, unlike GDExternal, the gdap file does not allow for specifying whether a debug or runtime build of a plugin should be included in the export. That is something that was discussed with the android team but currently on the list of todos for a future version.

That said, we can change the CI to make both runtime and debug builds and just have a godotopenxrloaders-runtime.zip and godotopenxrloaders-debug.zip that includes the different versions.

hammerandtongs commented 1 year ago

I think it makes a lot of sense to add this to debug builds but I was hoping for someone/anyone with a device to tell us it was ok and didn't fill up logs with silly spam :)

But also it would be kind of nice to find a place to document this "hack" to get working android environment variables for godot. Is there a faq or tips section for it?

ArchLinus commented 8 months ago

I've been trying to hack in XR_LOADER_DEBUG=all by calling setenv("XR_LOADER_DEBUG", "all", 1); at the core initialization level, but it just doesn't seem like the loader on android is picking it up at all.

Since the environment variable situation is a bit of a mess on android, it might be better to just implement the XR_EXT_debug_utils extension. This extension allows you to register a callback for debug messages, giving you much better control over the logging than the environment variable.