Repository navigation
fix(macos): give snapshot nodes with a non-finite AX rect no rect - #3324
Conversation
|
The macOS change is small and reads correctly, but nothing yet shows it fixes the reported failure at 38fb7bf. Not blocking: The one failing check is the |
|
Ran it live. Target was Stim Desktop built before our fix that gave lazy containers a finite frame, with the repo CLI, native macOS backend and
Full output is in the collapsed section below. Only +inf appeared live. NaN and -inf are covered by unit tests. I took the optional suggestion. The guard is now a pure Live snapshot evidence |
|
This PR is ready. The earlier review at 38fb7bf was waiting on evidence, and the live macOS run you pasted now covers it. At the reviewed commit 6ddff25 the non-finite rect fix and its tests look correct, and all 13 checks pass. The earlier I did not re-run the live snapshot or the Swift tests. I relied on your pasted output. The live helper was built from 099be379a, which I could not check out here. I took it as equivalent to 6ddff25 because the delta is a pure extraction. Only +inf occurred live. NaN and -inf are covered by the unit tests only. Not blocking, and you can take or leave these: the tests in |
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix is correct, comprehensively tested, and supported by live macOS validation.
0 open findings
What changed in this PR
Prevents macOS snapshots from failing JSON encoding when AX elements report non-finite geometry.
Changes:
- Converts only finite AX geometry into snapshot rectangles.
- Adds coverage for infinity, negative infinity, NaN, and valid rectangles.
| File | Description |
|---|---|
SnapshotTraversal.swift |
Omits invalid AX rectangles from snapshot nodes. |
RectResponseTests.swift |
Tests finite and non-finite geometry handling. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Summary
On macOS,
rectAttributebuiltRectResponsestraight from the AX position and size. SwiftUI reports lazy containers (LazyVGrid,LazyVStack) scrolled or sized out of view as anAXOpaqueProviderGroupat (inf, inf, 0, 0).JSONEncoderthrows on that value, so one node failed the wholesnapshot:EncodingError.invalidValue: inf (Double). Path: data.nodes[N].rect.x.rectAttributenow returns nil when any component is non-finite. Nodes already allow a nil rect (they are not hittable), and the otherrectAttributecallers already handle nil. Touches 2 files inapple/macos-helper.The iOS runner and Android paths were not changed: the runner already skips null/empty frames and I found no same-pattern encoding of raw AX doubles there. I did not exercise them with a non-finite frame.
Related to #3323 (independent, no dependency). No existing issue found.
Validation
Tested at 6ddff25.
pnpm check:affected --run: all runnable checks passed (macos-helper lanes are GitHub-authoritative).pnpm test:macos-helper: passes, includingRectResponseTestson the purefiniteRectResponse(position:size:)thatrectAttributecalls: a finite rect is kept, and +inf, -inf and NaN in each component give nil.AXOpaqueProviderGroupat (inf, inf, 0, 0), a helper built from main failssnapshotwithEncodingError.invalidValue: inf; a helper built from this branch succeeds, with that node present, norect,hittable: false, and the nodes after it listed. The live helper was built from 099be379a, which has the same content as 6ddff25. Only +inf occurred live; NaN and -inf are covered by the unit tests, and only the live run covers therectAttributewiring.