Skip to content

Commit d1ae801

Browse files
committed
refactor(ios): one CGRect-to-SnapshotRect conversion; ADR names the real reason the frontier went
Review follow-ups on #2669. - Every CGRect becomes a SnapshotRect through SnapshotRect.init(_:). The runner's snapshotRect(from:) and the package's private SnapshotPresentationInvariant.snapshotRect(from:) were field-for-field copies; both are deleted and their nine call sites use the initializer. - ADR 0004 attributes the frontier removal to its cause: a post-walk normalization pass cannot feed a decision the walk already took, so the fold-consulting frontier had to go; the mis-cut keyboard band was the symptom. The measured cost of dropping it (form, catalog: p50 within 4 %, p95 within 10 % of main, in the branch's favour) is recorded there. - CHANGELOG line for the presentation-cut route and the capability rename.
1 parent ed75ffb commit d1ae801

8 files changed

Lines changed: 25 additions & 32 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
## Unreleased
44

5+
- Changed (ios): a regular `snapshot --depth N` on the XCTest runner is a presentation cut over a
6+
full acquisition, not a bound on the walk. Acquisition publishes the frames the platform reported,
7+
one normalization pass turns geometry into the app's orientation space and recomputes `hittable`,
8+
and the visibility fold and depth cut run on that array. Presented trees are unchanged on the
9+
screens measured; a boundary container under `--depth N` now carries its scroll hints from its real
10+
children. The runner's regular-depth capability is `presentation-cut` (was `presented-frontier`),
11+
and every `CGRect` becomes a `SnapshotRect` through one initializer (#2661).
512
- Fixed (daemon): `close` now stops an active app-log stream (and audio probe / perf capture /
613
recording) on an implicitly cwd-scoped session. Teardown addressed those resources by
714
`session.name` (`default`) instead of the store address (`cwd:<hash>:default`), so the record

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ extension RunnerTests {
242242
label: label.isEmpty ? nil : label,
243243
identifier: identifier.isEmpty ? nil : identifier,
244244
value: valueText.isEmpty ? nil : valueText,
245-
rect: snapshotRect(from: element.frame),
245+
rect: SnapshotRect(element.frame),
246246
enabled: element.isEnabled,
247247
focused: nil,
248248
selected: element.isSelected ? true : nil,

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+PrivateAXPresentation.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ extension RunnerTests {
7070
label: fields.label.isEmpty ? nil : fields.label,
7171
identifier: fields.identifier.isEmpty ? nil : fields.identifier,
7272
value: fields.value.isEmpty ? nil : fields.value,
73-
rect: snapshotRect(from: fields.rect), enabled: fields.enabled,
73+
rect: SnapshotRect(fields.rect), enabled: fields.enabled,
7474
focused: fields.focused, selected: fields.selected,
7575
hittable: false,
7676
depth: depth, parentIndex: parentIndex, hiddenContentAbove: nil, hiddenContentBelow: nil,

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ extension RunnerTests {
812812
label: nil,
813813
identifier: nil,
814814
value: nil,
815-
rect: snapshotRect(from: rect),
815+
rect: SnapshotRect(rect),
816816
enabled: true,
817817
focused: nil,
818818
selected: nil,
@@ -833,15 +833,6 @@ extension RunnerTests {
833833
return CGRect(x: 0, y: 0, width: max(1, maxX), height: max(1, maxY))
834834
}
835835

836-
func snapshotRect(from frame: CGRect) -> SnapshotRect {
837-
return SnapshotRect(
838-
x: Double(frame.origin.x),
839-
y: Double(frame.origin.y),
840-
width: Double(frame.size.width),
841-
height: Double(frame.size.height)
842-
)
843-
}
844-
845836
// MARK: - Snapshot Filtering
846837

847838
func makeSnapshotTraversalContext(
@@ -1017,7 +1008,7 @@ extension RunnerTests {
10171008
label: evaluation.label.isEmpty ? nil : evaluation.label,
10181009
identifier: evaluation.identifier.isEmpty ? nil : evaluation.identifier,
10191010
value: evaluation.valueText,
1020-
rect: snapshotRect(from: snapshot.frame),
1011+
rect: SnapshotRect(snapshot.frame),
10211012
enabled: snapshot.isEnabled,
10221013
focused: evaluation.focused ? true : nil,
10231014
selected: evaluation.selected ? true : nil,
@@ -1203,7 +1194,7 @@ extension RunnerTests {
12031194
label: label.isEmpty ? nil : label,
12041195
identifier: identifier.isEmpty ? nil : identifier,
12051196
value: valueText,
1206-
rect: snapshotRect(from: frame),
1197+
rect: SnapshotRect(frame),
12071198
enabled: element.isEnabled,
12081199
focused: elementHasFocus(element) ? true : nil,
12091200
selected: element.isSelected ? true : nil,
@@ -1359,7 +1350,7 @@ extension RunnerTests {
13591350
label: label.isEmpty ? nil : label,
13601351
identifier: identifier.isEmpty ? nil : identifier,
13611352
value: valueText,
1362-
rect: snapshotRect(from: frame),
1353+
rect: SnapshotRect(frame),
13631354
enabled: enabled,
13641355
focused: elementHasFocus(element) ? true : nil,
13651356
selected: element.isSelected ? true : nil,

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ extension RunnerTests {
756756
label: label,
757757
identifier: identifier,
758758
value: nil,
759-
rect: snapshotRect(from: .zero),
759+
rect: SnapshotRect(.zero),
760760
enabled: true,
761761
focused: nil,
762762
selected: nil,

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ extension RunnerTests {
232232
label: label.isEmpty ? nil : label,
233233
identifier: identifier.isEmpty ? nil : identifier,
234234
value: nil,
235-
rect: snapshotRect(from: element.frame),
235+
rect: SnapshotRect(element.frame),
236236
enabled: element.isEnabled,
237237
focused: nil,
238238
selected: nil,

‎apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationInvariant.swift‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public enum SnapshotPresentationInvariant {
6363
throw SnapshotPresentationFailure.regularNodeOutsideCumulativeClip(
6464
index: node.raw.index,
6565
frame: node.effectiveRect,
66-
clip: snapshotRect(from: ancestorClip)
66+
clip: SnapshotRect(ancestorClip)
6767
)
6868
}
6969
}
@@ -80,12 +80,4 @@ public enum SnapshotPresentationInvariant {
8080
&& frame.maxY <= clip.maxY + tolerance
8181
}
8282

83-
private static func snapshotRect(from rect: CGRect) -> SnapshotRect {
84-
SnapshotRect(
85-
x: Double(rect.minX),
86-
y: Double(rect.minY),
87-
width: Double(rect.width),
88-
height: Double(rect.height)
89-
)
90-
}
9183
}

‎docs/adr/0004-ios-snapshot-backend-strategy.md‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,15 @@ node at reported traversal depth and the frame the platform reported. #2661 also
310310
coordinate space (`geometrySpace` / `parentIsWindow`) that #2612 had threaded through every walker;
311311
the one coordinate-space decision is now a single post-acquisition pass over the flat array
312312
(`SnapshotGeometrySpace.normalized`, run in `captureWithBackend`) that keys on ancestry instead of a
313-
value carried down the stack. An earlier visible-depth frontier consulted the shared fold mid-walk, so
314-
its presented-depth increment was measured against un-normalized geometry: a turned keyboard band
315-
reported in the device's native space could be cut at the wrong presented depth before the single pass
316-
ever ran. Dropping it means no reported rect can prune a subtree the fold would keep. The visibility
317-
fold and the presented-depth cut both happen inside `SnapshotPresentation`, on the normalized array,
318-
at `maximumDepth`. De-duplication drops a repeated node and re-parents its children onto that node's
313+
value carried down the stack. That pass is why the earlier visible-depth frontier had to go: the
314+
frontier consulted the shared fold mid-walk, and a post-walk normalization pass cannot feed a decision
315+
the walk has already taken — the fold would read reported geometry, and a turned keyboard band in the
316+
device's native space could be cut at the wrong presented depth before the pass ever ran. With the
317+
frontier gone, no acquisition-time decision reads geometry, the walk is bounded only by raw traversal
318+
depth and the node cap, and the visibility fold and the presented-depth cut both happen inside
319+
`SnapshotPresentation`, on the normalized array, at `maximumDepth`. Measured on the recursive tier
320+
(form, catalog; 7 warm captures each) the frontier bought nothing: acquisition p50 within 4 % and p95
321+
within 10 % of `main`, in the branch's favour, with identical presented trees. De-duplication drops a repeated node and re-parents its children onto that node's
319322
own parent, so identical rows collapse under one addressable owner instead of splitting a subtree
320323
across two nodes with the same identity. Scoped captures remain broad because depth is relative to the
321324
scope root selected in presentation.

0 commit comments

Comments
 (0)