Skip to content

fix: iPad landscape orientation support#2980

Merged
amanjeetsingh150 merged 4 commits intomobile-dev-inc:mainfrom
leggomuhgreggo:fix/ipad-landscape-orientation
Mar 5, 2026
Merged

fix: iPad landscape orientation support#2980
amanjeetsingh150 merged 4 commits intomobile-dev-inc:mainfrom
leggomuhgreggo:fix/ipad-landscape-orientation

Conversation

@leggomuhgreggo
Copy link
Contributor

@leggomuhgreggo leggomuhgreggo commented Feb 5, 2026

Summary

Fixes #2701 — iPad landscape mode causes coordinate mapping failures + element detection failures.

Problem

Maestro commands (taps, swipes, key presses, text input) fail or land on incorrect coordinates when targeting iPad apps running in landscape orientation.

The iOS XCTest driver assumes portrait orientation in several places, causing coordinate transforms and event synthesis to produce wrong results.

Solution

Identified and fixed four interrelated bugs in the iOS XCTest driver's orientation handling:

  1. Hardcoded .portrait in EventRecord — Touch, swipe, and key press handlers passed .portrait by default. Now uses a currentInterfaceOrientation() helper that correctly maps UIDeviceOrientationUIInterfaceOrientation (accounting for Apple's landscape inversion convention).
    • Note: Required updating TextInputHelper with @MainActor
  2. Double-swap in actualScreenSize() — Dimensions were swapped even when the framework already returned landscape-correct values. Added a dimsAlreadyMatchOrientation guard.
  3. Incorrect orientationAwarePoint() transform — Coordinate mapping was wrong for landscape. Fixed the transformation logic with the same dimension-awareness guard.
  4. ViewHierarchyHandler offset corruption — Springboard-vs-app frame mismatch in landscape introduced incorrect coordinate offsets. Added detection to skip offset adjustment when frames differ only by orientation.

@leggomuhgreggo leggomuhgreggo marked this pull request as draft February 5, 2026 08:45
@leggomuhgreggo leggomuhgreggo force-pushed the fix/ipad-landscape-orientation branch from aa10a91 to 0545430 Compare February 5, 2026 09:02
@leggomuhgreggo leggomuhgreggo marked this pull request as ready for review February 5, 2026 10:20
Copy link

@nabs-m nabs-m left a comment

Choose a reason for hiding this comment

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

🚀

@leggomuhgreggo leggomuhgreggo force-pushed the fix/ipad-landscape-orientation branch 4 times, most recently from 438c8fa to 9f7768e Compare February 6, 2026 19:13
@leggomuhgreggo
Copy link
Contributor Author

leggomuhgreggo commented Feb 6, 2026

@nabs-m thanks for the review!

Wanted to give a heads up — I made one additional fix after your initial approval.

FWIW my team and I have been validating this change for the past couple days and everyone is saying what a joy it is to finally be able to use maestro for our project — like taking a first breath of fresh air.

LMK if there's anything I can do to help facilitate integration. 🙏

@nabs-m
Copy link

nabs-m commented Feb 9, 2026

@leggomuhgreggo That's great! I'm not one of the maintainers though, just happened to be looking for iPad landscape support around the same time and noticed your PR. My team is also anxious to get their hands on it, so I'd love to see this merge soon.

Looking at some other PRs, seems like @Fishbowler and @amanjeetsingh150 tend to review PRs if you wanna add them to this.

@Fishbowler
Copy link
Contributor

We're already looking :)

leggomuhgreggo and others added 4 commits February 10, 2026 10:24
Fix four bugs in the iOS XCTest runner that break landscape mode on iPad:

1. EventRecord hardcoded .portrait orientation — replaced with dynamic
   ScreenSizeHelper.currentInterfaceOrientation() across all 6 event
   synthesis call sites (touch, swipe v1/v2, text input x2, press key)

2. actualScreenSize() double-swapped dimensions — on modern iOS (13.1+),
   physicalScreenSize() already returns orientation-correct values; added
   dimsAlreadyMatchOrientation check to skip redundant swap

3. orientationAwarePoint() incorrect coordinate transform — rotation
   formulas assumed portrait-ordered dimensions; now uses effective
   dimensions (swapped width/height) when physicalScreenSize() returns
   landscape-correct values, ensuring correct landscape→portrait space
   mapping for EventRecord

4. ViewHierarchyHandler offset corruption — springboard frame (always
   portrait: 1024x1366) vs app frame (landscape: 1366x1024) caused a
   spurious (-342, +342) offset on all element positions; added
   isSameAreaDifferentOrientation check to skip offset when frames are
   the same size but different orientation

Tested on iPad Air 13-inch (M3), iOS 26.2:
- Portrait simulator + responsive app: 13/13 steps pass
- Landscape simulator + responsive app: 13/13 steps pass
- Landscape simulator + orientation-locked app: 13/13 steps pass

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Was crashing when trying to call `ScreenSizeHelper.currentInterfaceOrientation()`
@leggomuhgreggo leggomuhgreggo force-pushed the fix/ipad-landscape-orientation branch from 9f7768e to 4e95c02 Compare February 10, 2026 19:59
@outcomes-keyan-hardman
Copy link

This fix is much appreciated. I'm begging for this change to be merged :) This is preventing me from utilizing Maestro for our application. I would really really like this fix ASAP.

@leggomuhgreggo
Copy link
Contributor Author

@outcomes-keyan-hardman if you're very eager, and don't mind using a duct-taped dependency, you can use the release build from my fork:
https://github.com/leggomuhgreggo/Maestro/releases/tag/cli-2.1.0-ipad-landscape-fix

@outcomes-keyan-hardman
Copy link

@leggomuhgreggo You're a legend, thanks.

@divan
Copy link

divan commented Feb 17, 2026

@leggomuhgreggo thanks, it seems to work. But Maestro Studio goes bananas in inspect mode (when iPad simulator is in portrait mode).

@nabs-m
Copy link

nabs-m commented Feb 19, 2026

Any remaining blockers for this before merging it and creating a new release with it?

@amanjeetsingh150
Copy link
Collaborator

Hey @nabs-m we would be merging this for next release.

@outcomes-keyan-hardman
Copy link

@amanjeetsingh150 is there any update on this? do you have an estimated release date?

@amanjeetsingh150 amanjeetsingh150 merged commit 1712019 into mobile-dev-inc:main Mar 5, 2026
14 of 15 checks passed
@amanjeetsingh150
Copy link
Collaborator

amanjeetsingh150 commented Mar 9, 2026

@amanjeetsingh150 is there any update on this? do you have an estimated release date?

Doing CLI release this week, that would have this fix.

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.

Maestro does not work in iPad landscape mode

6 participants