Friday, April 19, 2019

Emulator 29.0.3 Canary

Emulator 29.0.3 is now available in the Canary and Dev channels. Changes:
  • Fixed keyboard input focus issue on xfce. Issue 1 Issue 2
  • Foldable UI: Added console commands to fold/unfold foldable AVDs:
    • adb emu fold
    • adb emu unfold
  • AR Macro UI: Fixed displayed state in the UI when macro stops playing.
  • Removed message qemu_ram_alloc_user_backed on startup.
  • More logging added when OpenGL initialization fails.
  • Fixed several crashes and synchronization issues.
Linux emulator: gRPC service

We'd like to make the emulator as versatile as possible, allowing host GPU rendering and interactivity in the widest range of running contexts.

CI and remote desktop users have the following long-standing pain points:
  • Programmatically sending input commands to the emulator involves running adb shell commands which can be high overhead, or using the telnet console, which is faster, but may not work with certain network setups.
  • CI users often run emulators headless, which can make it difficult to notice issues that require the screen being visible or even interactive.
  • Remote desktop users often cannot run with host GPU rendering and also interact with the emulator as GPU rendering is often set up to be tied to the non-virtual displays.

To address this, we've added the capability for the Linux emulator to also serve a gRPC service. gRPC is a general framework for RPC that works over HTTP.

Note: This is still experimental stage and is meant to be used from the same machine the emulator is running on; please do not run the service truly remotely unless you know the security implications!
The emulator gRPC service is disabled by default but can be activated via the command line

-grpc <port>

where <port> is the port over which to serve gRPC requests, usually 5556. Like with anything else that is starting a server, do not run the service if you do not have <port> secured from remote users!

Once the service is started, gRPC commands can then be issued from clients. The set of commands is captured in the protobuf here. The current set of commands allows both sending input events and receiving screenshots, addressing the pain points:
  • Input commands can be sent to the emulator with low overhead over HTTP which will work across more network setups.
  • Even if the emulator is running headless, screenshot gRPC requests can be sent to query the current screen. For interactivity, input events can also be sent back to the emulator.
  • Remote desktop users can then run the emulator headless on the main display with GPU accelerated rendering while using gRPC to get screenshots and send input events in order to interact with the emulator.
To get started, we also provide a few example clients here. There is:
  • A Go-based service that can be used to query emulator states.
  • A React app that demonstrates remote interactivity via screenshot and input RPCs. Note: the React example requires that protobuf version 3.7.0+ be built and found on the system.
In the near term, we will work on a higher performance streaming solution to getting screenshots.