Skip to content

[build-tools] Early stop eas/start_android_emulator when Android emulator host setup is invalid#3580

Open
gwdp wants to merge 20 commits intomainfrom
gwdp/build-tools-early-emum-stop
Open

[build-tools] Early stop eas/start_android_emulator when Android emulator host setup is invalid#3580
gwdp wants to merge 20 commits intomainfrom
gwdp/build-tools-early-emum-stop

Conversation

@gwdp
Copy link
Copy Markdown
Contributor

@gwdp gwdp commented Apr 7, 2026

Why

Starting an Android emulator without nested virtualization support always fails, but today that failure happens later and with less actionable context.
Adding nested virtualization detection to start_android_emulator allows us to fail fast with a clearer error message when the VM does not support emulator hardware acceleration.

How

Add an early preflight check in start_android_emulator to detect whether emulator acceleration prerequisites are present (including VMX/SVM support).
If acceleration is not available, fail fast with a clear, user-friendly error explaining that nested virtualization is required and how to enable it.

Test Plan

Screenshot 2026-04-09 at 1 58 26 PM

Ref ENG-17446

… emulator when not on nested virtualization enabled host
@gwdp gwdp self-assigned this Apr 7, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.44%. Comparing base (8c170af) to head (074633b).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3580      +/-   ##
==========================================
+ Coverage   54.26%   54.44%   +0.18%     
==========================================
  Files         821      821              
  Lines       35327    35348      +21     
  Branches     7363     7369       +6     
==========================================
+ Hits        19166    19240      +74     
+ Misses      16074    16017      -57     
- Partials       87       91       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@linear
Copy link
Copy Markdown

linear bot commented Apr 7, 2026

@gwdp
Copy link
Copy Markdown
Contributor Author

gwdp commented Apr 7, 2026

gwdp added 5 commits April 8, 2026 09:56
Align Android emulator nested-virtualization detection with step runtime metadata instead of Node process platform, and expand tests to assert early failure on non-Linux runtime platforms.
Return a typed user-facing error when Android emulator virtualization requirements are not met so this early-stop path avoids noisy unknown-error stack output.
@gwdp gwdp requested a review from sjchmiela April 8, 2026 18:31
@gwdp gwdp marked this pull request as ready for review April 8, 2026 18:31
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

Subscribed to pull request

File Patterns Mentions
**/* @douglowder

Generated by CodeMention

@gwdp gwdp changed the title [build-tools] early stop android emum when not nested virtualization [build-tools] early stop eas/start_android_emulator when emulator hardware acceleration is not available Apr 9, 2026
gwdp added 3 commits April 9, 2026 13:36
Keep the startAndroidEmulator test helper aligned with main by removing the temporary runtime platform override from createStep.
@gwdp gwdp requested a review from sjchmiela April 9, 2026 21:25
});
}

async function assertNestedVirtualizationIsAvailableAsync({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

question: now that I'm thinking about it maybe this check should not force-fail the job, but instead only print a helpful warning? We can then add an annotation on the log to make it even more prominent. https://expo.dev/admin/annotations

What happens if a user does start_android_emulator on non-virtualized VM? Does emulator return a non-zero code or do we just "fail, waiting"?

EDIT: Ok looking more, judging by https://staging.expo.dev/accounts/gwdp/projects/coin-flip/workflows/019d73d1-261b-793a-9db7-98cfa335c197 we don't even install emulator on non-nested VMs which means emulator should fail which means start_android_emulator step fails with ENOENT or sth like that which is not too helpful. so maybe your solution is good, but maybe let's rename stuff to indicate that we're checking emulator is set up correctly or what

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Took this path of the early failure since my reproduction did show 9m+ of execution into the start emulator function until failure on non nested environment and thought about potential savings with the early path. Renamed things slightly, let me now if aligned

}
}

async function getIsNestedVirtualizationEnabledAsync(env: NodeJS.ProcessEnv): Promise<boolean> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

now that it's returning false if we don't have ANDROID_HOME set let's rename it to something different?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually, reasoning further, failure pattern when/if ANDROID_HOME is missing would be quite obscure, since spawn would not produce any logs and just assertion would be raised.

If you are aligned, I modified it to use empty sdk path and actually execute with it, so failure is more visible to us if that ever happen. Thoughts?

@gwdp gwdp force-pushed the gwdp/build-tools-early-emum-stop branch from ccc1dc3 to 69a110b Compare April 10, 2026 16:49
@github-actions
Copy link
Copy Markdown

✅ Thank you for adding the changelog entry!

@gwdp gwdp changed the title [build-tools] early stop eas/start_android_emulator when emulator hardware acceleration is not available [build-tools] Early stop eas/start_android_emulator when Android emulator host setup is invalid Apr 10, 2026
@gwdp gwdp requested a review from sjchmiela April 10, 2026 18:01
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.

2 participants