Repository navigation
perf(wda): send coordinate gestures with snapshotMaxDepth 1 - #272
Open
luka-vladika-happening-xyz wants to merge 1 commit into
Open
luka-vladika-happening-xyz wants to merge 1 commit into
luka-vladika-happening-xyz wants to merge 1 commit into
Conversation
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 Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
On a real iPhone every tap of the WDA driver reads the whole app before it touches.
/wda/tap,/wda/doubleTap,/wda/touchAndHold,/wda/dragfromtofordurationand the W3C/actionsmake the point anXCUICoordinateon the app, and XCTest snapshots the app down tosnapshotMaxDepth(the driver's 62) before it sends the touch, though the touch needs only the app's frame. So everytapOnreads 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 setssnapshotMaxDepthto 1, sends the gesture and setswdaSnapshotMaxDepth()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,TestSwipeandTestTapOnStaleElementRecoverynow 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/tapwent 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/tapitself 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, andsnapshotMaxChildren0 or 1, were no faster than depth 1.