Igalia / wolvic

A fast and secure browser for standalone virtual-reality and augmented-reality headsets.
https://wolvic.org
Mozilla Public License 2.0
801 stars 101 forks source link

How to create a new flavor for a new device #199

Closed lcgao closed 2 years ago

lcgao commented 2 years ago

Is your feature request related to a problem? Please describe. As issue #196 mentioned.

Describe the solution you'd like Currently, I have a new XR device(Not one of these known devices Oculus, Huawei, Pico, or VIVE...) and I would like to develop a XR browser based on Wolvic. So I guess I need to create a new flavor like other devices did for integrating my own SDK.

Describe alternatives you've considered So I would like to know what interfaces or something I should implement to let WebXR App be able to detect VR/AR by WebXR API.

WebXR Apps: https://immersive-web.github.io/webxr-samples/.

Thank you in advance.

lcgao commented 2 years ago

By the way, how Wolvic works for WebXR API isSessionSupported('immersive-vr')?

svillar commented 2 years ago

This isn't easy to reply. I guess the best you could do is to check the specific bits of some implementation (like oculusvr sdk) and then try to replicate the same structures for your own flavour. A good starting point is https://github.com/Igalia/wolvic/blob/main/app/build.gradle. There you could see exactly the build dependencies (Java) for each flavour. You'd also likely need a specific manifest file as well for your app.

Then if you're using a specific XR library you should place it in third_party and make gradle aware of that.

You'd also need assets for your device/controllers like for example textures and 3D models for your controllers.

Finally check the contents of the different folders in app/src/ where you'd see specific implementations per flavour. Very likely you'd need new implementation for the DeviceDelegate and/or a specific native-lib.cpp and/or swapchaing implementation... It'd depend a lot on your platform. On the Java side you'd likely need a specific PlatformActivity.java file.

svillar commented 2 years ago

By the way, how Wolvic works for WebXR API isSessionSupported('immersive-vr')?

Well WebXR is a JavaScript API and thus it's directly handled by the web and JavaScript engines, in the case of Wolvic it's Gecko/Spidermonkey. Then the web engines delegate on specific platform libraries to provide the XR services. In the case of Gecko when that API is called it basically asks the XR library to list the available devices. If the XR library returns at least one device then Gecko will reply positively in the returned Promise.

In the Wolvic architecture those XR calls to platform libraries are not performed by Gecko, we basically make a bypass and use the XR library specified by the Wolvic flavour. So if we build the oculus flavour then the Oculus SDK will serve those requests.

lcgao commented 2 years ago

This isn't easy to reply. I guess the best you could do is to check the specific bits of some implementation (like oculusvr sdk) and then try to replicate the same structures for your own flavour. A good starting point is https://github.com/Igalia/wolvic/blob/main/app/build.gradle. There you could see exactly the build dependencies (Java) for each flavour. You'd also likely need a specific manifest file as well for your app.

Then if you're using a specific XR library you should place it in third_party and make gradle aware of that.

You'd also need assets for your device/controllers like for example textures and 3D models for your controllers.

Finally check the contents of the different folders in app/src/ where you'd see specific implementations per flavour. Very likely you'd need new implementation for the DeviceDelegate and/or a specific native-lib.cpp and/or swapchaing implementation... It'd depend a lot on your platform. On the Java side you'd likely need a specific PlatformActivity.java file.

Appreciate for the reply!

lcgao commented 2 years ago

By the way, how Wolvic works for WebXR API isSessionSupported('immersive-vr')?

Well WebXR is a JavaScript API and thus it's directly handled by the web and JavaScript engines, in the case of Wolvic it's Gecko/Spidermonkey. Then the web engines delegate on specific platform libraries to provide the XR services. In the case of Gecko when that API is called it basically asks the XR library to list the available devices. If the XR library returns at least one device then Gecko will reply positively in the returned Promise.

In the Wolvic architecture those XR calls to platform libraries are not performed by Gecko, we basically make a bypass and use the XR library specified by the Wolvic flavour. So if we build the oculus flavour then the Oculus SDK will serve those requests.

Thanks for this explanation.

So actually WebXR API is supported by XR library right? Does it mean that the XR library(such as Oculus SDK) should call some specific functions in Gecko or somewhere else to support the WebXR API? If so, may I know which functions it is?

svillar commented 2 years ago

By the way, how Wolvic works for WebXR API isSessionSupported('immersive-vr')?

Well WebXR is a JavaScript API and thus it's directly handled by the web and JavaScript engines, in the case of Wolvic it's Gecko/Spidermonkey. Then the web engines delegate on specific platform libraries to provide the XR services. In the case of Gecko when that API is called it basically asks the XR library to list the available devices. If the XR library returns at least one device then Gecko will reply positively in the returned Promise. In the Wolvic architecture those XR calls to platform libraries are not performed by Gecko, we basically make a bypass and use the XR library specified by the Wolvic flavour. So if we build the oculus flavour then the Oculus SDK will serve those requests.

Thanks for this explanation.

So actually WebXR API is supported by XR library right? Does it mean that the XR library(such as Oculus SDK) should call some specific functions in Gecko or somewhere else to support the WebXR API? If so, may I know which functions it is?

No, the XR library does not know anything about WebXR. It's the web engine (like gecko) the one which implements the WebXR API by using some XR library in the system.

lcgao commented 2 years ago

Yes, I think so.

svillar commented 2 years ago

Closing this as it's already answered.