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

Update Readme & Provide current context on Hardware Acceleration on Github #279

Merged
merged 8 commits into from
Oct 26, 2022

Conversation

mrk-han
Copy link
Collaborator

@mrk-han mrk-han commented Oct 19, 2022

The current readme felt a bit disingenuous & outdated given the current situation with Github's Hosted Runners.

This PR is a general update & rephrasing of the README to provide more clarity, and is an attempt to give a more accurate representation of the state of the action.

See: actions/runner-images#6388 , actions/runner-images#183 (comment)

Copy link
Member

@ychescale9 ychescale9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just 1 comment on Ubuntu support.

README.md Outdated
@@ -4,14 +4,18 @@
<a href="https://github.com/ReactiveCircus/android-emulator-runner"><img alt="GitHub Actions status" src="https://github.com/ReactiveCircus/android-emulator-runner/workflows/Main%20workflow/badge.svg"></a>
</p>

A GitHub Action for installing, configuring and running hardware-accelerated Android Emulators on macOS virtual machines.
A GitHub Action for installing, configuring and running Android Emulators on macOS and Ubuntu virtual machines.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's still important to distinguish between macOs and Ubuntu support. Being able to run in swiftshader_indirect mode is still way faster than -accel off. When people read this without any caveat they would expect running the action on linux VMs to be feasible, which is far from the reality.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in commit: e860dce

README.md Outdated
The **macOS** VM provided by **GitHub Actions** has **HAXM** installed so we are able to create a new AVD instance, launch an emulator with hardware acceleration, and run our Android
tests directly on the VM. You can also achieve this on a self-hosted Linux runner, but it will need to be on a compatible instance that allows you to enable KVM - for example AWS EC2 Bare Metal instances.
The **macOS** 10.x VM provided by **GitHub Actions** had **HAXM** [pre-installed](https://github.com/actions/runner-images/blob/main/images/macos/macos-10.15-Readme.md) so we were able to create a new AVD instance, launch an emulator with hardware acceleration and run our Android
tests directly on the VM. However, Github's [macOS-11](https://github.com/actions/runner-images/blob/main/images/macos/macos-11-Readme.md) and [macOS-12](https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md) VMs **no longer** come pre-installed with HAXM. See [here](https://github.com/actions/runner-images/issues/183#issuecomment-610723516) and [here](https://github.com/actions/runner-images/issues/6388) for more info.
Copy link
Contributor

@mattjohnsonpint mattjohnsonpint Oct 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading this and checking the links - I find myself asking, "So, how do I install HAXM then, and do I need to?" We should either point at how to do that (if possible), or explain why we don't need it (if that's so).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattjohnsonpint Good call. Will add this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in commit: e860dce

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm even more confused now, as the gist shows scripting the emulator directly instead of using the react-android-emulator action.

FWIW, I'm not installing HAXM, and for the most part, react-android-emulator is working.

Copy link
Collaborator Author

@mrk-han mrk-han Oct 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattjohnsonpint Oh whoops, good call! I accidentally linked the wrong gist (same thing but without android-emulator-runner) Thank you!

fixed in 592f866

@mattjohnsonpint
Copy link
Contributor

mattjohnsonpint commented Oct 24, 2022

Sorry, but I'm still quite confused about what's actually being said here.

According to https://developer.android.com/studio/run/emulator-acceleration, the flag -gpu swiftshader_indirect is a software acceleration mode. This is what I've been using, and it appears to work the same regardless of whether or not I go out of my way to install haxm on the GitHub Actions macOS 12 runner.

I tried installing haxm and then setting the flag to -gpu host to use hardware acceleration, but that gives a warning:

WARNING | Your GPU drivers may have a bug. If you experience graphical issues, please consider switching to software rendering.

... and then the AVD fails to boot.

So if we can't use hardware acceleration, why are you recommending we install haxm?

@mattjohnsonpint
Copy link
Contributor

Looking closer at the existing readme, on the first line:

A GitHub Action for installing, configuring and running hardware-accelerated Android Emulators on macOS virtual machines.

If we have to use software acceleration with -gpu swiftshader_indirect, Is this just blatantly false then? What am I misunderstanding?

Don't get me wrong - I'd still much rather use this action than to script all the emulator commands myself, but does it actually support hardware-accelerated emulators?

@mattjohnsonpint
Copy link
Contributor

Oh, wait a sec. I think I was confused between the GPU acceleration mode and the VM acceleration mode.
https://developer.android.com/studio/run/emulator-acceleration#accel-vm

Am I understanding correctly then, that the GPU mode must stay software accelerated with -gpu switfshader_indirect, but by installing HAXM we can set -accel on to force hardware acceleration for the VM?

@mrk-han
Copy link
Collaborator Author

mrk-han commented Oct 25, 2022

@mattjohnsonpint Yes, my understanding is that you can choose between CPU vs GPU for Graphics Acceleration, and this is different from VM Acceleration.

You can utilize VM-Acceleration if there is Hypervisor + enabled IVT(Intel Virtualization Technology (VT, VT-x, vmx) extensions), and if the emulator is not inside another VM -- which means VM-Acceleration is usually not possible on Ubuntu agents scaled with something like VMSphere. So, if we have swiftshader_indirect enabled for the Graphics Rendering, then we can still have intel-haxm installed on the macos-12 agent to help with the VM Acceleration portion. (emulator -accel on)

From what I can tell, for some reason host is not a viable option on Github's standard macOS runners, and returns an error. (emulator -gpu swiftshader_indirect)

One question I need to test is using SKIA rendering. I'm not sure if SKIA completely replaces host/swiftshader_indirect for screen rendering, or if it can be used with both of them. My assumption is that SKIA will be an option to use instead of swiftshader_indirect and eventually will be passable as a -gpu option, but I am not sure of that.I will test this when I can.

I also wish there was a way for me to more easily communicate with the Google Emulator team to clear this up, so if anyone has suggestions on that please let me know.

I will add more clarity to the readme regarding this.

README.md Outdated
@@ -6,12 +6,21 @@

A GitHub Action for installing, configuring and running hardware-accelerated Android Emulators on macOS virtual machines.

The old ARM-based emulators were slow and are no longer supported by Google. The modern Intel Atom (x86 and x86_64) emulators require hardware acceleration (HAXM on Mac & Windows, QEMU on Linux) from the host to run fast. This presents a challenge on CI as to be able to run hardware accelerated emulators within a docker container, **KVM** must be supported by the host VM which isn't the case for cloud-based CI providers due to infrastructural limits. If you want to learn more about this, here's an article I wrote: [Running Android Instrumented Tests on CI](https://dev.to/ychescale9/running-android-emulators-on-ci-from-bitrise-io-to-github-actions-3j76).
The old ARM-based emulators were slow and are no longer supported by Google. The modern Intel Atom (x86 and x86_64) emulators can be fast, but rely on two forms of hardware acceleration to reach their peak potential: [Graphics Acceleration](https://developer.android.com/studio/run/emulator-acceleration#accel-graphics), e.g. `emulator -accel on` and [Virtual Machine(VM) Acceleration](https://developer.android.com/studio/run/emulator-acceleration#accel-vm), e.g. `emulator -gpu host`. Note: GPU and VM Acceleration are two different and non-mutually exclusive forms of Hardware Acceleration.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the examples given are reversed?

Copy link
Collaborator Author

@mrk-han mrk-han Oct 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattjohnsonpint Thank you so much for catching this!! I really appreciate it. Addressed in 8f64fa8

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great now. Thanks!

@mrk-han
Copy link
Collaborator Author

mrk-han commented Oct 25, 2022

Note: This PR also helps address #270

@mrk-han
Copy link
Collaborator Author

mrk-han commented Oct 25, 2022

See also: intel/haxm#403 for info on installing HAXM

@mrk-han
Copy link
Collaborator Author

mrk-han commented Oct 26, 2022

One of the jobs failed due to an emulator timeout on boot. Since I couldn't rerun the tests I tried to add a method in which contributors could comment "run tests" on a PR to re-run the main.yml workflow. However, I'm not positive the context of that triggered run will be the PR. There might have to be an additional commit added which uses the checkout action with ref: specific_sha before running the workflow again, or else I believe it defaults to the main branch. We can test it out and if that is true, then I'll create another PR to address that.

Ideally the comment would run the workflow against the latest commit of the PR, and update the failed checks. Even better would be a method to rerun all failed or cancelled jobs, instead of running all of them -- but I do not believe that is currently supported. (I put in a discussion post here) to request that, or see if it is possible.

@ychescale9 ychescale9 merged commit a47c099 into ReactiveCircus:main Oct 26, 2022
@mrk-han mrk-han deleted the mrk-han/update-readme-1 branch October 26, 2022 17:25
ychescale9 added a commit that referenced this pull request Oct 28, 2022
* main:
  Prepare for release 2.27.0.
  Clean up action description.
  Update dependencies (#282)
  Update Readme & Provide current context on Hardware Acceleration on Github (#279)
  Pre Emulator Launch Script (#247)
  Update to Node 16 (#276)
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

Successfully merging this pull request may close these issues.

3 participants