Repository navigation
perf(wda): a lookup reads the page source without visible and accessible - #266
Merged
omnarayan merged 1 commit intoNov 9, 2026
Conversation
A lookup that WebDriverAgent's own query does not settle falls back to the page source (GET /source), and so do relative selectors, an index, a size, copyTextFrom and the keyboard checks. WebDriverAgent computes `visible` and `accessible` for every element of that tree, `visible` with an accessibility call each, and the page-source matcher reads neither: it keeps an element by its bounds (FilterOutOfBounds), and `visible` only chose a report note. Those reads now ask for the source with excluded_attributes=visible,accessible, which WebDriverAgent supports on /source (FBDebugCommands). On an iPhone 17 (iOS 27) on a screen of a few thousand elements the source took 23 s whole and 2.5 s without the two. Every element of such a source parses as displayed, so a match it finds no longer carries the "visible=false but within the viewport" note. Hierarchy() still reads the whole source, for the report and the hierarchy command.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 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 the WDA driver falls back to
GET /sourcewhenever WebDriverAgent's own query does not settle a lookup: a selector that matches nothing yet (every poll of an optional step or awhen: visible), a text whose first match is off screen, and always for relative selectors,index:, a size,copyTextFromand the keyboard checks.WebDriverAgent computes
visibleandaccessiblefor every element of that tree,visiblewith an accessibility call each. The page-source matcher does not decide on either: it keeps an element by its bounds (FilterOutOfBounds);visibleonly picked the "visible=false but within the viewport" note, andaccessibleis not read. WebDriverAgent's/sourcecan leave attributes out (excluded_attributes,FBDebugCommands.m); Appium's XCUITest driver exposes the same thing as itspageSourceExcludedAttributessetting, for the same reason.This PR asks for those reads with
excluded_attributes=visible,accessible.Hierarchy()still reads the whole source, so the report and thehierarchycommand keep every attribute. A match found in such a source no longer carries the note above.Measured with WebDriverAgent 11.4.1 on a real app's heavy screen (a page source of about 830 KB), raw
GET /sourcecalls in alternating order:accessiblevisibleThe same with WebDriverAgent 16.17.5 (the version this repository bundles under
drivers/ios/WebDriverAgent): on an iPhone 14 Pro (iOS 27.2), a heavy screen of the same kind (a page source of about 830 KB), rawGET /sourcealternated between 11.4.1 and 16.17.5 installed side by side, ten reads each: whole, 25.2 s on 11.4.1 and 24.9 s on 16.17.5; withexcluded_attributes=visible,accessible, 2.2 s and 2.0 s. A lighter screen (about 180 KB): 7.0 s whole on both, 0.4 s trimmed on both. The attribute computations are the same code in both versions (XCUIElement+FBIsVisible.mis unchanged), so the gain does not depend on which WebDriverAgent the driver talks to.And two flows on the iPhone 17, our build of v1.1.30 (with #263) without and with this change, four runs each in alternating order, all passed (medians):
runFlow: when: visibleon an id that is not thereOn an iPhone 13 Pro Max (iOS 18.4.1), the same series: the first flow 313 → 173 s; the second unchanged (115 → 118 s), since its lookups of absent elements there ended at their steps' timeouts either way.
There are more page sources after the change because each poll of a waiting step is cheap now, so a step looks more often within the same timeout.
Tested with a fake WebDriverAgent (
lookup_source_test.go: a lookup asks for the trimmed source and still matches, andHierarchy()asks for the whole one).go test ./pkg/driver/wda/passes; golangci-lint v2.13.2: 0 issues.