[FastDeploy] Verify install with 'pm path' and diagnose disk space#11960
Open
simonrozsival wants to merge 2 commits into
Open
[FastDeploy] Verify install with 'pm path' and diagnose disk space#11960simonrozsival wants to merge 2 commits into
simonrozsival wants to merge 2 commits into
Conversation
Fast Deployment relies on parsing 'pm install' stdout to detect success, treating empty output as success. When an install silently no-ops, the failure only surfaces later as an opaque XA0137 run-as 'couldn't stat /data/user/N/<pkg>' error during the post-install probe, masking the real cause as a fast-deployment race. Positively confirm the package landed via 'pm path <pkg>' after install; if it reports no package, force a single reinstall before falling through to the existing run-as probe. Adds diagnostics so build logs make the cause obvious.
…nstall A package that vanishes right after a successful-looking install is often a symptom of a full data partition (test APKs accumulate on CI emulators), which pm install does not always surface as INSTALL_FAILED_INSUFFICIENT_STORAGE. Log free space on /data (via GetAvailableSpace) and record deploy.data.free.bytes so CI logs reveal low-disk conditions. Best-effort; never throws.
Contributor
There was a problem hiding this comment.
Pull request overview
Improves Fast Deployment reliability by positively verifying that a post-pm install package actually exists on-device, and by emitting diagnostics that help distinguish genuine install failures (often disk-space related) from the known run-as data-dir materialization race.
Changes:
- After a “successful-looking” install, validate presence via
pm path <pkg>and force a single reinstall if the package is missing. - When the package is missing, log best-effort free
/dataspace and record adeploy.data.free.bytesdiagnostic property.
Show a summary per file
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Debugging.Tasks/Tasks/FastDeploy.cs | Adds pm path verification + one-time reinstall fallback and logs /data free space diagnostics when the package appears missing. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 2
Comment on lines
+573
to
+576
| string output = await Device.RunShellCommand (CancellationToken, args.ToArray ()); | ||
| LogDiagnostic ($"`pm path {packageName}` returned: {(string.IsNullOrWhiteSpace (output) ? "<no output>" : output.Trim ())}"); | ||
| return !string.IsNullOrWhiteSpace (output) && | ||
| output.IndexOf ("package:", StringComparison.OrdinalIgnoreCase) >= 0; |
Comment on lines
+327
to
+329
| try { | ||
| await InstallPackage (installed: false); | ||
| } catch (Exception ex) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR makes Fast Deployment detect and recover from a silently-failed
pm install, instead of misreporting it as an unsupported-device error many seconds later. It also adds diagnostics that reveal the most common underlying cause (a full/datapartition on CI emulators).The problem
Fast Deployment decides whether
pm installsucceeded by parsing adb's stdout, andAdbOutputParsing.CheckInstallSuccesstreats empty output as success. In practice an install can report success (or return empty/garbled output) while the package never actually materializes on the device — most often because the emulator's data partition is nearly full, whichpm installdoes not reliably report asINSTALL_FAILED_INSUFFICIENT_STORAGE.When that happens, the tooling believes the app is installed and proceeds straight to its only post-install signal: the
run-as <pkg> pwdprobe. That probe fails with:which is exactly the message emitted by the known install↔
run-asmaterialization race (#7821 / #11808). The code therefore retries for ~4.5s and, when the package still isn't visible, gives up with:So a genuine install failure is masked as a device-capability problem, with no indication of the real cause. This showed up in a CI
Package Tests > APKsDebug lane that compiled cleanly, ran zero tests, and died at deploy with thecouldn't staterror — the classic signature of this masking.The fix
1. Positively verify the install with
pm path, and reinstall once if it's missing.After a successful-looking
InstallPackage, the task now confirms the package is really present by queryingpm path <pkg>— the same techniqueAndroidDevice.WaitUntilReadyalready uses forpm path android:package:/…returned → the install genuinely landed. Any laterrun-as "couldn't stat"really is the materialization race, so the existing retry /XA0137path stays in control and behavior is unchanged.ReInstall = true→InstallPackage (installed: false)) before falling through to therun-asprobe, giving deployment a real chance to succeed rather than timing out.--useris honored whenAndroidDeviceUserIdis set. No new user-facing or localized strings are introduced: if the package is still missing after the reinstall, the existingrun-asprobe surfaces the failure just as before — now accompanied by diagnostics noting that a reinstall was already attempted.2. Log free
/dataspace when a package goes missing after install.Because a vanishing package is so often a full-disk symptom, when
pm pathreports the package missing the task logs the device's free space on/data(via the existingAndroidDevice.GetAvailableSpace) and records adeploy.data.free.bytesdiagnostic property. This is best-effort and never throws.Taken together, empty
pm path+ low/datafree space is strong evidence the failure is disk-space related (a candidate forADB0060) even whenpmnever said so.How it fits into the existing flow
The change is purely additive and gated to the post-install path:
InstallPackageruns as before.IsPackageInstalled(pm path <pkg>) confirms the package exists.deploy.reinstall.after.missing.package, reinstall once, re-check.run-asprobe / retry /XA0137logic runs unchanged.The happy path is identical apart from one extra
pm pathquery.Diagnostics added
deploy.reinstall.after.missing.package— a reinstall was triggered becausepm pathfound nothing.deploy.data.free.bytes— free bytes on/dataat the moment the package was found missing.pm pathresult and the free-space reading.Testing
Xamarin.Android.Build.Debugging.Tasks.pm pathquery.