Skip to content

perf: backport stability and performance fixes from upstream - #13

Merged
azarouski merged 7 commits into
developfrom
perf/upstream-backports
Oct 21, 2026
Merged

azarouski merged 7 commits into
developfrom
perf/upstream-backports

Conversation

@azarouski

Copy link
Copy Markdown

Summary

Small fixes ported from appium/WebDriverAgent that apply to this fork without changing the existing behavior. One commit per item.

Commit Upstream What it fixes
fix: apply screenshot renderer scaling only once appium#1278 With mjpegFixOrientation the scaling factor was applied twice (50% produced 25% frames)
fix: restore quiescence settings when stability waits throw appium#1281 An exception during the stability wait left waitForIdleTimeout overridden and the quiescence wait forced on for all following commands
fix: release LRU cache values when the cache is destroyed appium#1274 Neighbour nodes referenced each other strongly, so every session's element cache leaked all cached elements
perf: cache the system application for WDA's process lifetime appium#1232 The system application was requested over XPC on every alert check, active app fallback and session deletion
perf: resolve the active application once in pressAndDragWithVelocity appium#1197 The active application was resolved twice per drag
perf: avoid repeated sibling and frame scans during XML serialization appium#1283 The index attribute scanned all siblings, and every dimension attribute recalculated the element rect
fix: do not wait forever for the testmanagerd protocol version based on appium#1228 /status could hang the main thread forever if a legacy testmanagerd never replied

Notes

  • testmanagerd timeout. Unlike upstream, the reply is awaited by spinning the run loop with a timeout rather than with a semaphore, because /status runs on the main thread here. This path is only taken by legacy testmanagerd versions; on Xcode 26 it is not reached, so it is verified by build and review only.
  • Page source speed. The gain is modest. On a page with 1000 sibling buttons /source went from ~4.3s to ~4.0s; on regular screens the time is dominated by the snapshot request.

Testing

  • All 125 unit tests pass.
  • New tests ported from upstream for items 1–3; each fails without its fix and passes with it.
  • Page source is byte-identical before and after on Settings, Safari and a 1000-element page (except process ids and scroll indicators).
  • Manual run on the simulator: active app detection, alert lookups, drag with velocity, session deletion, /status.

azarouski and others added 7 commits October 20, 2026 20:22
The renderer size already includes the scaling factor, so using the same
factor as the renderer scale shrank the image twice when the orientation
was fixed (e.g. mjpegFixOrientation with mjpegScalingFactor=50 produced
25% frames). Keep the source image scale instead.

Backport of appium#1278.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
fb_waitUntilStableWithTimeout temporarily overrides waitForIdleTimeout and
forces the quiescence wait on. If the wait raised an exception, both
overrides leaked into all following commands. Restore them in @finally.

Backport of appium#1281.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Neighbour nodes referenced each other strongly, so the element cache of
every session leaked all of its cached elements. Make the backward link
weak and detach removed nodes.

Backport of appium#1274.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The system application accessibility element was requested over XPC on
every alert check, active application fallback and session deletion. Its
identity cannot change while WDA is alive, so resolve it once.

Backport of appium#1232.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Each activeApplication call queries the application state, so do not
resolve it separately for the start and end coordinates.

Backport of appium#1197.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The serializer already knows the position of each child, but the index
attribute scanned all siblings to find it, and every dimension attribute
recalculated the element rect. Pass the index down and calculate the rect
once per element.

The page source stays byte-identical. On a page with 1000 sibling buttons
/source went from ~4.3s to ~4.0s on the simulator.

Backport of appium#1283.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
FBTestmanagerdVersion spun the main run loop until testmanagerd replied,
without any timeout. All commands are served from the main thread, so a
daemon that never replied hung the whole server on the first /status.
Wait up to 20 seconds and assume the newest protocol otherwise, like
upstream does.

Only legacy testmanagerd versions that support the protocol version
exchange take this path; modern ones are not affected.

Based on appium#1228.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@azarouski
azarouski merged commit d722201 into develop Oct 21, 2026
39 of 44 checks passed
@azarouski
azarouski deleted the perf/upstream-backports branch October 21, 2026 11:01
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