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

Look at supporting anbox in some form #9

Closed
MerlijnWajer opened this issue Oct 18, 2017 · 31 comments
Closed

Look at supporting anbox in some form #9

MerlijnWajer opened this issue Oct 18, 2017 · 31 comments
Assignees

Comments

@MerlijnWajer
Copy link
Member

https://github.com/anbox/anbox

@dderby
Copy link
Member

dderby commented Feb 21, 2018

Packaging for Debian is being worked on by Debian Project Leader Chris Lamb:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=884797
https://github.com/lamby/pkg-anbox

@MerlijnWajer
Copy link
Member Author

Great, I wasn't looking forward to snaps...

@MerlijnWajer
Copy link
Member Author

Seems like it is in sid now. I wonder if we could use it on ascii (stretch).

@dderby
Copy link
Member

dderby commented Dec 20, 2018

It's in ascii-backports and beowulf:
https://pkginfo.devuan.org/cgi-bin/d1pkgweb-query?search=anbox&release=any

I tried to install it on my Devuan ascii desktop but it conflicted with packages I already have installed. Hopefully a fresh Leste install won't have this problem.

@dderby
Copy link
Member

dderby commented Jan 15, 2019

There are a few things we'll need to do to before this will run under Maemo.

Anbox has a couple of daemons which have systemd service files but the Debian package is missing rc scripts (*sigh*), so we'll need port these to OpenRC.

The kernel config will need to be updated to enable these modules:

/lib/modules/`uname -r`/kernel/drivers/android/binder_linux.ko
/lib/modules/`uname -r`/kernel/drivers/staging/android/ashmem_linux.ko

Since Anbox uses LXC, so we'll need to ensure namespaces, etc. are enabled in the kernel too.

@MerlijnWajer
Copy link
Member Author

Did you get some of it to work? I could help with porting the init scripts if that helps.

@ollieparanoid
Copy link

Maybe this is useful: we had an init script here, and done some more WIP work in the branch linked below.

https://github.com/postmarketOS/pmbootstrap/blob/feature/anbox/aports/main/anbox/anbox-container-manager.initd

https://github.com/postmarketOS/pmbootstrap/tree/feature/anbox

"After some patching we have it compiling and displaying the "Starting..." screen, but the way it configures LXC does not work out of the box for us."

@dderby
Copy link
Member

dderby commented Jan 15, 2019

@MerlijnWajer, I've not really tried very hard to get it working yet. I didn't get as far a rebuilding the kernel yet. To be honest, I'd rather look at other stuff first before getting heavily involved in this.

@ollieparanoid, thanks! I've run into issues in the past when starting a container under Devuan as the way LXC was set up on Debian expected systemd, although I think I managed to work around them. I'm not sure what the current state of affairs is for LXC under Devuan.

@dderby
Copy link
Member

dderby commented Jan 30, 2019

It's actually very easy to get Anbox from ascii-backports running under Devuan with a backported kernel (which has already been built with all of the required modules). I don't envisage any real difficulties in getting this running under Leste once we've enabled the all of the goodies in the kernel config.

It does however seem to be a bit picky about needing video acceleration. I couldn't get it to work in a Devuan VirtualBox VM, even with VirtualBox's "3D acceleration" option enabled. Anbox does have an option for software rendering but it doesn't seem to work either.

@MerlijnWajer
Copy link
Member Author

Do you have some instructions on how to do this on devuan?

@dderby
Copy link
Member

dderby commented Feb 9, 2019

I should be able to cobble something together. I might have a go at building a new kernel with LXC and those two modules for the N900 first. ;)

@MerlijnWajer
Copy link
Member Author

Will be interesting to see if the hw accel on the n900 suffices then.

@dderby
Copy link
Member

dderby commented Feb 9, 2019

It looks like it doesn't suffice. :/

I built a new kernel for the N900 with the two Android drivers and full LXC support. I also needed to enable some SquashFS decompression options that were needed to mount the Android image. The Container Manager starts. When starting the Anbox Session Manager, there are a bunch messages related to the keyboard layout being unknown to SDL, followed by this error:

[ 2019-02-09 15:32:05] [Renderer.cpp:115@initialize] EGL doesn't support surfaceless context
[ 2019-02-09 15:32:05] [Renderer.cpp:141@initialize] Failed to create context: error=0x3005

Then it prints a Successfully acquired DBus service name message and then it hangs. After that it should print a message to confirm that Android successfully booted but it doesn't.

I'll write up instructions for Devuan later.

@dderby
Copy link
Member

dderby commented Feb 9, 2019

@dderby
Copy link
Member

dderby commented Feb 9, 2019

How to run Anbox under Devuan ascii amd64 (with notes for N900 differences)

Commands to be run as a regular user and root are denoted below by the shell prompt, $ and #.

  1. Enable ascii-backports and update the local package index:
# echo "deb https://pkgmaster.devuan.org/merged/ ascii-backports main contrib" >> /etc/apt/sources.list
# apt-get update
  1. Install anbox and a recent kernel (greater than 4.17) from backports:
# apt-get -t ascii-backports install anbox linux-image-4.19.0-0.bpo.1-amd64
  1. Reboot your system or kexec the new kernel.

  2. Download the latest Android image and verify its integrity:

$ curl -O https://build.anbox.io/android-images/2018/07/19/android_amd64.img
$ curl -O https://build.anbox.io/android-images/2018/07/19/android_amd64.img.sha256sum
$ sha256 android_amd64.img
$ cat android_amd64.img.sha256sum

(If you're trying this on the N900, the latest armhf image is available here: https://build.anbox.io/android-images/2017/06/12/)

  1. Place the Android image where Anbox expects to find it:
# mv android_amd64.img /var/lib/anbox/android.img
  1. Load the two kernel modules:
# modprobe binder_linux
# modprobe ashmem_linux

(This step is not required when using my N900 kernel config from the comment above. They will be built into the kernel. make menuconfig insisted on not building these as modules and I couldn't find the dependency that was causing this.)

  1. Set up the network bridge interface to enable networking under LXC:
# /usr/share/anbox/anbox-bridge.sh start
  1. Start the Anbox Container Manager:
# ANBOX_LOG_LEVEL=debug anbox container-manager --daemon --privileged --data-path=/var/lib/anbox
  1. Anbox Session Manager requires the $XDG_RUNTIME_DIR environment variable to be set. On one of my Devuan installs, this was already set up, by elogind I believe. Other installs, Leste for example, do not set it up so you will need to set it manually.
    In a new shell session, with $XDG_RUNTIME_DIR set, you will be able to start the Anbox Session Manager which will boot the Android container:
$ ANBOX_LOG_LEVEL=debug anbox session-manager
  1. In another new shell session, you will be able to start an Android app. The follow command will launch the Anbox Application Manager:
$ ANBOX_LOG_LEVEL=debug anbox launch --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity

You can also start a shell inside the Android container with this wrapper script /usr/share/anbox/anbox-shell.sh which basically runs an lxc-attach. From there, you can get Android system logs by running logcat.

@MerlijnWajer
Copy link
Member Author

To be clear, does this work on the N900 now, or not?

@dderby
Copy link
Member

dderby commented Feb 11, 2019

Unfortunately not.

@jonsger
Copy link

jonsger commented Feb 11, 2019

I think in general it would make sense to add a Wiki page about Anbox, collecting all the infos from this issue. Maybe I get this done this week, if not then on the Week-end :P

@dderby
Copy link
Member

dderby commented Feb 22, 2019

For what it's worth, this is the message you get if you try to start the Session Manager with software rendering:

$ ANBOX_LOG_LEVEL=debug anbox session-manager --software-rendering
[ 2019-02-22 03:29:40] [daemon.cpp:61@Run] Software rendering is not available outside of a snap build

@MerlijnWajer
Copy link
Member Author

@MerlijnWajer
Copy link
Member Author

So you could look at setting SWIFTSHADER_PATH?

@dderby
Copy link
Member

dderby commented Feb 22, 2019

Thanks for finding this. It looks promising but I see a couple of issues:

  1. The fix relies on SwiftShader which is not yet packaged for Debian.
  2. The version of Anbox currently in ascii-backports is missing the fix.

Although these issues are overcomable, it seems like a lot of effort just to get software rendering working.

@MerlijnWajer
Copy link
Member Author

In virtual machines, you're likely to have just software rendering. We might switch over to beowulf/buster in a month or so, so then it might become easier.

@dderby
Copy link
Member

dderby commented Mar 16, 2019

A bit more information...

EGL doesn't support surfaceless context is a debug message and is not necessarily a deal breaker. Anbox can apparently initialise EGL without it.

The error code from Failed to create context: error=0x3005, seems to translate to EGL_BAD_CONFIG which would occur here:

https://github.com/anbox/anbox/blob/master/android/opengl/system/egl/egl.cpp#L919

Unless anyone has any idea as to why it thinks OpenGL ES 1 or 2 isn't avaiable, I'm going to have a go at building it for debug and attach a debugger to find out what going on.

@freemangordon
Copy link

on what device is that error generated? or this is VM? If in VM, I guess you need GLES2 libs installed.

@dderby
Copy link
Member

dderby commented Mar 16, 2019

This is on the N900.

@MerlijnWajer
Copy link
Member Author

Have you dist-upgraded?

@dderby
Copy link
Member

dderby commented Mar 16, 2019

I haven't tried it for a while.

@android-808
Copy link

Purely off the top of my head, are you using the GLES libs provided by the driver? From what I recall of building SDL2 for Fremantle, I had to patch the source to get it to find the libs. Unfortunately I can't find the post on TMO. It may even have been for love2d.

Another bit was the GL header files provided defined a function parameter as size_t instead of unsigned int. QT IIRC had a patch to work around that.

I'll have to go on laptop to see if I can find the full details.

@android-808
Copy link

OK, I've taken a quick look at my SDL2 package.

  • Fremantle & Harmattan are missing typedef for GLchar - that's the fix from QT source.
  • I had to add LLONG_MIN/MAX and ULLONG_MAX but I think they should be OK now we have updated toolchain.
  • I couldn't build for GLES1 and GLES2 at the same time - can't remember why but probably SDL issue.
  • I had to change paths from libGLESv2.so.2 and libGLES_CM.so.1 to just libGLESv2.so and libGLES_CM.so

Outside of SDL:
I was wrong regarding size_t/unsigned int issue, it was a GLenum to GLint, parameter 3 of glTexImage2D (internal format) in GL2.h. My fix/hack came from an Android app as some device drivers were defining as enum, some as int and this way it worked for both. It may throw a warning on some devices but better than an error. I also changed last param from GLvoid* to void*. Not sure why. I created a small GLES header package using dpkg-divert to fix these two so other packages would hopefully build easier.

@parazyd parazyd self-assigned this Jul 5, 2020
@parazyd
Copy link
Member

parazyd commented Jan 18, 2021

@parazyd parazyd closed this as completed Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants