Repository navigation
perf(android): probe each running device with one getprop batch and one feature list - #5138
Conversation
…ne feature list Device discovery spawned 9 adb processes per running Android device: separate getprops for the boot state, the AVD name, the characteristics and the description, four `cmd package has-feature` calls, and `pm list features`. The target probe alone took four round trips in a row. Read every property in one `getprop` batch and the feature list in a second adb shell, run together. The feature list stays its own call because a busy device can stall it (callstack#4765), and that stall still takes only the target with it. `cmd package has-feature` is dropped: it reads the same PackageManager feature table that `pm list features` prints, and the feature list was already asked whenever has-feature said no. `adb emu avd name` is still asked only when no property names the AVD.
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/platform-android/src/inventory-parsers.ts">
<violation number="1" location="packages/platform-android/src/inventory-parsers.ts:48">
P3: The `flatMap` callback has no tuple return type, so `Object.fromEntries` falls back to returning `any` and the declared `AndroidDeviceProps` return type stops checking the result. Annotate the callback's return as a typed tuple array.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
| export function parseAndroidDeviceProps(rawOutput: string): AndroidDeviceProps { | ||
| const lines = rawOutput.split(/\r?\n/); | ||
| return Object.fromEntries( | ||
| ANDROID_INVENTORY_PROPS.flatMap((prop, index) => { |
There was a problem hiding this comment.
P3: The flatMap callback has no tuple return type, so Object.fromEntries falls back to returning any and the declared AndroidDeviceProps return type stops checking the result. Annotate the callback's return as a typed tuple array.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/platform-android/src/inventory-parsers.ts, line 48:
<comment>The `flatMap` callback has no tuple return type, so `Object.fromEntries` falls back to returning `any` and the declared `AndroidDeviceProps` return type stops checking the result. Annotate the callback's return as a typed tuple array.</comment>
<file context>
@@ -27,16 +27,29 @@ export function parseAndroidDeviceEntries(rawOutput: string): AndroidDeviceEntry
+export function parseAndroidDeviceProps(rawOutput: string): AndroidDeviceProps {
+ const lines = rawOutput.split(/\r?\n/);
+ return Object.fromEntries(
+ ANDROID_INVENTORY_PROPS.flatMap((prop, index) => {
+ const value = lines[index]?.trim();
+ return value ? [[prop, value]] : [];
</file context>
| ANDROID_INVENTORY_PROPS.flatMap((prop, index) => { | |
| ANDROID_INVENTORY_PROPS.flatMap((prop, index): [(typeof ANDROID_INVENTORY_PROPS)[number], string][] => { |
|
Thanks for the change, no blocking problem was found at 9b5b581. CI is green: every check that was not skipped passes at this commit, including the latest Body rules run. The thread on callback typing does not apply and can be resolved: The live evidence relied on is your API 36 before/after run at this commit and the CI Android smoke run (API 36 emulator, CLI built from this commit, fixture E2E and one replay passed). Not verified here: the match between No blocking finding remains before merge. |
Summary
Android device discovery spawned 9 adb processes per running device (separate
getprops, fourcmd package has-feature,pm list features), and the target probe took four round trips in a row.Each running device now gets two adb shells, in parallel:
getpropbatch printing every property discovery reads;pm list features, kept separate because a busy device can stall it (Android discovery feature probe on other emulators can time out an unrelated open #4765). A stall still costs only that device's target.cmd package has-featureis dropped. It reads the same PackageManager feature table thatpm list featuresprints, and the old code already read the list whenever has-feature said no, so the result is unchanged.adb emu avd nameis still asked only when no property names the AVD.Before / after (Pixel 9 emulator, API 36)
agent-device devices --platform android --json, warm daemon, 15 interleaved runs:3e0814c574)9b5b581b2e)devicesThe JSON output is identical. The device answered
has-feature android.hardware.wifitrue and listed it; it answeredleanbackfalse and did not list it.Validation
inventory.test.tsandinventory-parsers.test.ts: 28 passed. 8 mutants each fail a test.9b5b581b2e:format,lint,typecheck,layering,fallow,build,vitest-related, andprovider-integration(324 passed) passed.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.