Skip to content

perf(wda): send coordinate gestures with snapshotMaxDepth 1 - #272

Open
luka-vladika-happening-xyz wants to merge 1 commit into
devicelab-dev:mainfrom
luka-vladika-happening-xyz:perf/wda-tap-without-app-snapshot
Open

luka-vladika-happening-xyz wants to merge 1 commit into
devicelab-dev:mainfrom
luka-vladika-happening-xyz:perf/wda-tap-without-app-snapshot

Conversation

@luka-vladika-happening-xyz

Copy link
Copy Markdown
Contributor

On a real iPhone every tap of the WDA driver reads the whole app before it touches. /wda/tap, /wda/doubleTap, /wda/touchAndHold, /wda/dragfromtoforduration and the W3C /actions make the point an XCUICoordinate on the app, and XCTest snapshots the app down to snapshotMaxDepth (the driver's 62) before it sends the touch, though the touch needs only the app's frame. So every tapOn reads the screen once more after its find has read it, and on a heavy screen that read takes seconds.

The change: the client's coordinate gestures (Tap, DoubleTap, LongPress, Swipe, Flick, DragFromTo) go through one helper, gesture, which sets snapshotMaxDepth to 1, sends the gesture and sets wdaSnapshotMaxDepth() again, so finds and page sources still see the whole tree. If WebDriverAgent refuses the depth, the gesture goes as before; a refused restore is tried once more, then logged. WebDriverAgent keeps settings process-wide, and the driver sends a gesture and its two settings calls one after the other (its only concurrent requests are inside a launch and a find), so nothing else reads at depth 1. It is on for every session with no option, since the touch lands where it did; happy to put it behind a variable if you prefer.

Cost: two settings calls per gesture, 4-5 ms each at the median from the runner on a real iPhone.

Tests: TestGesturesRunAtDepthOne: each of the six gestures goes out between depth 1 and depth 62, a refused depth sends the gesture alone, a refused restore is sent again; it fails without the change. TestTap, TestDoubleTap, TestLongPress, TestSwipe and TestTapOnStaleElementRecovery now answer the settings calls. go test -race ./pkg/driver/wda/ ./pkg/executor/ ./pkg/flow/ passes; golangci-lint v2.13.2: 0 issues.

On devices: measured on our build of 1.1.30 (with our open #263 and #265), the same change behind a variable. Five real iPhones (iOS 17.7, 18.3, 26.2, 27.0, 27.2) ran 20 flows of our suite three times with the change and three times without, alternating: 600 flow runs. On every phone a /wda/tap went from a median of 0.7-1.2 s to 0.31-0.38 s, and a swipe from 1.1-1.3 s to 0.77-0.84 s. The flows got 2-4 % faster, since in a tap step the touch is a third of a second next to the find and the settle. Both arms answered the same permission prompts, and 252 and 249 of 300 runs passed; the 17 that differ go both ways, on the flows' own flaky waits.

On a heavy screen the gain is larger. With a long live list on screen, /wda/tap itself took 3.5-4.1 s on an iPhone 13 (iOS 18.3) at depth 50 and 0.9 s at depth 1; on an iPhone 11 Pro (iOS 17.7) it took 7-11 s, freezing the app for 1.4-2.6 s at a time, against 0.46-0.64 s at depth 1. On six iOS 27 simulators with the WDA driver, a tap on a long list went from 0.6 s to 0.32 s, but flows an hour did not change: the Mac takes the snapshot quickly. Depth 0, and snapshotMaxChildren 0 or 1, were no faster than depth 1.

A tap, double tap, long press, swipe, flick or drag at x,y is an
XCUICoordinate on the app in WebDriverAgent, and XCTest snapshots the app
down to snapshotMaxDepth before it touches, though the touch needs only the
app's frame. On a heavy screen of a real iPhone that read takes seconds
before every touch. Each gesture now goes out with the depth at 1 and the
session's depth (wdaSnapshotMaxDepth) set again after it, so finds and page
sources still see the whole tree. A refused depth sends the gesture as
before; a refused restore is tried once more, then logged.
@codecov

codecov Bot commented Nov 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/driver/wda/client.go 85.71% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

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