Skip to content

fix(android): return from orientation once the display reports the rotation - #2356

Open
thymikee wants to merge 1 commit into
mainfrom
claude/android-orientation-settle
Open

fix(android): return from orientation once the display reports the rotation#2356
thymikee wants to merge 1 commit into
mainfrom
claude/android-orientation-settle

Conversation

@thymikee

@thymikee thymikee commented Sep 6, 2026

Copy link
Copy Markdown
Member

Summary

Android orientation wrote accelerometer_rotation and user_rotation and returned at once, while the display rotated some time later. On the loaded CI emulator that takes seconds, and accessibility reads hang meanwhile.

Evidence: the Android Smoke on #2344, https://github.com/callstack/agent-device/actions/runs/34025424834. wait text landscape right after orientation landscape-left reported wait_capture_stalled with zero readable captures: the helper session request timed out at 5s, the one-shot fallback ran into the wait's deadline, and the failed-step snapshot taken right after was already in landscape (nodes 2400px wide). The rotation had landed; the wait's whole budget went to the transition.

Change

setAndroidOrientation now polls dumpsys display for mCurrentOrientation to match the requested rotation, every 500ms up to 15s, before returning.

  • A display that reaches the rotation returns as soon as it does (about 1s on a local emulator with the fixture app foreground).
  • A display that never gets there fails the command with the observed rotation and a hint, instead of reporting success. This is a behavior change worth a look: on the launcher, which pins portrait (mCurrentAppOrientation=SCREEN_ORIENTATION_NOSENSOR), orientation landscape-left previously "succeeded" without rotating and now fails after 15s with observedRotation: 0.
  • A display that reports no mCurrentOrientation at all is left to the setting, as before.

Validation

  • Unit tests (fake adb, sleep mocked, fake clock for the budget): returns once the display reports the rotation after two stale reads; fails with requestedRotation: 1, observedRotation: 0 when it never does; leaves a display that reports nothing to the setting. Package suite 641 tests green; typecheck, oxlint, oxfmt, fallow clean.
  • Live on a local Pixel 9 Pro XL emulator with the fixture app foreground: orientation landscape-left 1s, mCurrentOrientation=1; orientation portrait 1s, mCurrentOrientation=0.

What this does not explain

The other Android Smoke failure family (the post-alert canary missing while the device is in landscape although orientation portrait had been confirmed) is still open; #2350 adds the rotation evidence for it. This change removes the transition cost from the command that starts a rotation, which is also where a later flip would be visible if it is a delayed re-application.

…tation

`orientation` wrote accelerometer_rotation and user_rotation and returned
at once, while the display rotated some time later. On the loaded CI
emulator that takes seconds, and accessibility reads hang meanwhile: the
Android smoke's `wait text landscape` right after `orientation
landscape-left` got a helper request timeout and then no readable
capture for its whole 10s budget, with the failed-step snapshot taken
afterwards already in landscape (PR #2344, run 34025424834).

The command now polls `dumpsys display` for mCurrentOrientation to
match the requested rotation, up to 15s, before returning. A display
that never gets there fails the command with the observed rotation
instead of reporting success; a display that reports no rotation at all
is left to the setting as before.
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
Installed (including dependencies) 4.50 MB 4.49 MB -680 B
Package (unpacked) 4.49 MB 4.49 MB -680 B
Package (download) 1.33 MB 1.33 MB -182 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 29.0 ms 29.2 ms +0.2 ms
CLI --help 80.9 ms 79.6 ms -1.4 ms

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.

1 participant