Enable WebGL in Anbox Cloud

Hi there, I built a platform by Anbox Cloud Appliance and run the app correctly.

But when I tried to open a webGL content by webview, the instance will crash.
The webview can work smoothly in local Android device and I confirmed the JavaScript can be executed.

And I change the link to the webGL HP and found the webview in Anbox Cloud has something wrong with the webGL.
So is there a way to make the webview to work with WebGL?

Edited:
I found the webGL works well in VM instance. So I wonder maybe some package related to the webgl removed for minimizing system size.

Log when start a webgl:
Ubuntu Pastebin

Hello @hidetorio,

Thanks for reaching out to us! Could you please answer the following queries so that we can investigate more?

  1. Do you have this on a regular/full Anbox Cloud deployment or on the Anbox Cloud Appliance? Could you share the version of the deployment, either way?
  2. What version of Android are you using?
  3. Does the deployment have GPU support?

Thanks,
Keirthana

Thanks for your response.

Here is information:

  1. Do you have this on a regular/full Anbox Cloud deployment or on the Anbox Cloud Appliance? Could you share the version of the deployment, either way?

It runs on the Anbox Cloud Appliance. The version is 1.20.1.

  1. What version of Android are you using?

I tried jammy:android13:amd64 and jammy:android12:amd64 in docker mode. Both did not works. But the WebGL can be run on a VM mode.

  1. Does the deployment have GPU support?
    The deployment has GPU support. But I tried a a4.3 and a6.3, it has the same problem with g4.3 type.

Wish the information is help for you.

Thank you for bug reporting.
We have confirmed the issue and created an internal story to track this.
We will keep you updated on any progress to this bug.

BR
Gary

1 Like

Hey hidetorio
This issue has been fixed in Anbox Cloud 1.20.2 release, which is scheduled to be released on Wednesday (17th, Jan).
To make this WebGL-based application work, alongside the fix we landed in 1.20.2, you need to explicitly disable the GL async object feature for your application, to do that:

  1. Upon creating the application, add the following feature to the application manifest file:
name: your_app
...
...
features:
  - emugl.disable_async_swap_support
  1. In the app folder, create a pre-start hook under the hooks folder:
mkdir hooks
cat << EOF > hooks/pre-start
#!/bin/sh -ex

if [ "\$INSTANCE_TYPE" != base ]; then
    exit 0
fi

echo "export ANBOX_ASYNC_SWAP_DISABLED_PACKAGES=com.canonical.anbox" > /var/lib/anbox/.env_overrides
EOF
chmod u+x hooks/pre-start

Please replace the package name com.canonical.anbox with your application package name

  1. Create the application in the AMS
    $ amc app create <your_app_folder>
  1. Once the app is created successfully in AMS, launch a new instance, start your application and check if the WebGL app works.

NOTE: We’re planning to disable the GL async object globally in the upcoming minor release(1.21.0(. Consequently, there will be no need for you to add any hooks to enable the WebGL app to work starting from the 1.21.0 release. Please refer to the roadmap for the target date for 1.21.0 release.

Any questions or concerns, please let us know.
Thanks.

Gary

1 Like

Thanks for your fix.

I followed the steps in the above, and it can run WebGL in a CPU instance.
But WebGL is still failed when runs in a GPU instance.

Is there other setting need to work on a GPU instance?

Here is some info maybe can help you find cause:

docker error logs:
https://1drv.ms/u/s!AhkKpGjamjtljPJBVZS-45xx44x1Rg?e=n6HIOE

application setting:
Ubuntu Pastebin

Looks like you forgot to replace the ANBOX_ASYNC_SWAP_DISABLED_PACKAGES environment variable with the appropriate one.
As mentioned above,

Please replace the package name com.canonical.anbox with your application package name.

BR
Gary