You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(screen-capture): the simulator capture's seed skip moves into SeedGate (#1753) - #1771
Implement: done; fix removed SeedWatch (approved decision on #1773) Review: passed (round 1, fix-check) Hardware: n/a Gate: waiting for the stack
Next: none until the stack merges
Assumptions
Assumption: where SeedWatch dedupes against the callback — SeedWatch calls onSeed on a seed that differs from its last read, and SeedGate in FrameCapture drops one the callback already noticed; the smallest split of I3.
Assumption: what SeedWatch.watch keeps across a pick — the same surface keeps the last seed read; a different surface (or nil) resets it, so the next tick reads the new surface fresh.
Done when
swift test --package-path vendor/screen-capture passes. — run by the build and the audit (16 tests, 0 failures), by the fix run that removed SeedWatch (FrameSelectionTests 4/4), and by CI
pnpm build builds dist/bin/simlock-screen-capture. — the build ran pnpm build and found dist/bin/simlock-screen-capture; CI builds it
spec: the issue lists docs/internal/VENDORED-CODE.md under Modules touched and the diff leaves it alone [nonblocking] — the serve-sim row is generic and true as written; the per-file claims live in NOTICE.md, which the PR updated
No actionable comments were generated in the recent review.
Walkthrough
This change moves simulator frame seed tracking from FrameCapture into a new SeedGate helper. FrameCapture now stores seedGate, calls seedGate.notice(key:seed:force:) in captureFrame(force:), and resets the helper in wireUpFramebuffer() and stop(). SeedGate stores the last seed for each ObjectIdentifier, returns true for a changed seed or a forced notice, and clears state on reset(). A new test covers unchanged, forced, changed, and post-reset cases.
Merge Risk: Minimal · up to b5083
This is a behavior-preserving refactor of the simulator capture's seed skip, with a unit test for the new helper. No merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: the simulator capture's seed-skip logic moves into SeedGate. The raw summary confirms this: FrameCapture now calls seedGate.notice instead of tracking lastSeeds per de…
Description check
The description is related to the changeset. It names issue #1753, describes the SeedGate split and the removal of SeedWatch, and reports the validation commands (swift test and pnpm build). It also i…
The changes introduced by this PR, relative to merge base c0a0531, are limited to the seed-skip move: SeedGate added in FrameSelection.swift (+17), FrameCapture.swift replacing the lastSeeds c…
Full details: Title check
Explanation
The title names the main change: the simulator capture's seed-skip logic moves into SeedGate. The raw summary confirms this: FrameCapture now calls seedGate.notice instead of tracking lastSeeds per descriptor, and a new SeedGate struct is added. The title's '(#1753)' reference matches the linked issue. The title is specific and does not mention the removed SeedWatch, which is acceptable because the PR does not ship it.
Full details: Description check
Explanation
The description is related to the changeset. It names issue #1753, describes the SeedGate split and the removal of SeedWatch, and reports the validation commands (swift test and pnpm build). It also includes review and cost metadata. The description is detailed enough to pass this lenient check.
Full details: Linked Issues check
Explanation
Stack objectives (current PR #1771; stack members #1769 and #1773 are uncertain and were not inspected):
[#1753] Move the callback's seed skip into SeedGate so each new seed is noticed once. Status: Addressed. Evidence at head b508364: FrameSelection.swift defines struct SeedGate with notice(key:seed:force:) (returns lastSeeds[key] != seed || force, storing the seed) and reset(). FrameCapture.swift holds private var seedGate = SeedGate(), calls seedGate.notice(key:seed:force:) in captureFrame, and skips when frameCount > 0 and the result is false. The old per-descriptor lastSeeds bookkeeping is absent from FrameCapture.swift in the read portion. Contributing PR: #1771.
[#1753] B4 SeedGate rows: unchanged seed gives none; forced unchanged seed gives one; after reset, the next seed is news. Status: Addressed. The reviewed head contains SeedGate with this behavior, and the PR summary describes FrameSelectionTests.testASeedIsNewOnlyWhenItChangesOrIsForcedAndAfterAResetTheNextOneIsNews covering these rows. I did not read the test file directly. Contributing PR: #1771.
[#1753] Reset behavior: seedGate.reset() runs on framebuffer rewire and on stop(). Status: Addressed at head. Contributing PR: #1771.
[#1753] Remove SeedWatch and its wiring, the seenNanos hand-in of captureFrame for it, and its tests. Status: Addressed for the files read. FrameCapture.swift (read through getScreenSize/stop) and FrameSelection.swift name no SeedWatch. captureFrame still sets seenNanos for the notice/copy split (CopyStage), which the issue does not ask to remove and which is not introduced by this PR per the summary (+5/-6 in FrameCapture). I could not run a repository-wide search, so the statement that no other source or test names SeedWatch is supported by the read files only.
[#1753] Capture behavior unchanged. Status: Addressed by the summary and the seed-skip logic at head; the logic is equivalent to the prior lastSeeds check (same frameCount > 0 and force conditions).
Coding requirements are met for the current PR's scope. The docs/internal/VENDORED-CODE.md note is documentation and is not a coding requirement.
Full details: Out of Scope Changes check
Explanation
The changes introduced by this PR, relative to merge base c0a0531, are limited to the seed-skip move: SeedGate added in FrameSelection.swift (+17), FrameCapture.swift replacing the lastSeeds check with seedGate.notice and seedGate.reset() (+5/-6), and one XCTest method in FrameSelectionTests.swift (+11). Each change supports objective #1753. No unrelated change was found in the read files. The whole-PR diff tool failed, so changes in files not listed in the summary were not directly verified; the summary reports no other files.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.
The 1 ms seed check is dropped by the maintainer-approved decision on #1773 (see #1753's Scope). This PR now removes SeedWatch again and keeps only SeedGate; a fix run and a fix check follow.
V3RON
changed the title
feat(screen-capture): the simulator capture checks the screen surface's seed every millisecond (#1753)
refactor(screen-capture): the simulator capture's seed skip moves into SeedGate (#1753)
Nov 19, 2026
…at carry a new app frame (#1773)
Closes#1754
### Status
Implement: done; hardware-fix 2fdf690 (hash every 8th row, 2nd pixel)
Review: round 1, fix-check 10bf2f7, fix-check 2fdf690 passed Hardware:
pass at 2fdf690 under the amended cpu line (maintainer 2026-11-19)
Gate: waiting for the stack
Next: ready, then the stack's gate (merge-pr.sh 1773)
## Measurement
```text
Device: iPhone 17 Pro (395064D5-215C-433B-988A-6E1FED014D0E), runtime iOS 26.5 (this Mac has no iOS 26.4 runtime), `--fps 60`, 20 s each. Before is the capture built at `fb4267632`; after is this PR's head.
| Run | Reader line |
| --- | --- |
| before, scroll | `distinct/s=59.8 p95=20.1 cpu=29.6` |
| before, animation | `distinct/s=60.1 p95=19.1 cpu=27.4` |
| after, scroll | `distinct/s=59.3 p95=18.8 cpu=71.3` |
| after, animation | `distinct/s=60.1 p95=17.3 cpu=72.3` |
Attribution (scroll): #1753's head without tiles `cpu=66.2`; the same with `SeedWatch.start()` removed `cpu=27.3`. So tile hashing adds about 5 points and the 1 ms seed check about 40.
```
## Seed check interval (back to back, iPhone 17 Pro, iOS 26.5, 20 s)
```text
| Build | scroll | animation |
| --- | --- | --- |
| before (`fb4267632`) | `59.8 / 22.3 / 28.2` | `59.9 / 19.1 / 26.0` |
| seed check 1 ms | `59.8 / 18.3 / 71.3` | `60.1 / 17.5 / 69.6` |
| seed check 2 ms | `58.9 / 20.5 / 53.8` | `60.1 / 18.4 / 46.9` |
| seed check 4 ms | `59.1 / 20.6 / 40.6` | `60.0 / 18.8 / 38.5` |
| seed check 8 ms | `59.0 / 21.1 / 32.8` | `60.0 / 19.3 / 32.1` |
| no seed check (this head) | `58.1 / 23.4 / 27.1` | `60.1 / 18.9 / 26.1` |
Columns are `distinct/s / p95 / cpu`. No interval keeps cpu at or below before, so by the decision `SeedWatch` is deleted and the callback alone notices composites. On this head scroll p95 is 23.4 ms and distinct/s 58.1, but before is itself at p95 22.3 to 22.6 on this Mac, so Done when line 3 is not fully met on scroll p95 and needs the maintainer.
```
## Three-run medians (decision 3)
```text
iPhone 17 Pro, iOS 26.5, `--fps 60`, 20 s, before (`fb4267632`) and after (head `da0f7d62`) alternating back to back. Columns are `distinct/s / p95 / cpu`. Every run also covers the `fps-reader.mjs` split.
- before scroll run1: distinct/s=59.6 p95=22.3 cpu=29.3
- after scroll run1: distinct/s=58.4 p95=23.0 cpu=27.7
- before scroll run2: distinct/s=59.5 p95=22.4 cpu=27.4
- after scroll run2: distinct/s=57.2 p95=25.6 cpu=27.2
- before scroll run3: distinct/s=59.2 p95=22.6 cpu=26.6
- after scroll run3: distinct/s=58.5 p95=22.2 cpu=28.5
- before animation run1: distinct/s=60.0 p95=19.1 cpu=25.8
- after animation run1: distinct/s=60.1 p95=19.0 cpu=26.4
- before animation run2: distinct/s=59.9 p95=19.0 cpu=25.9
- after animation run2: distinct/s=60.1 p95=19.0 cpu=26.5
- before animation run3: distinct/s=59.9 p95=19.1 cpu=26.2
- after animation run3: distinct/s=60.1 p95=18.9 cpu=26.0
| Scenario | before median | after median | distinct/s >= 58 | p95 vs before | cpu vs before |
| --- | --- | --- | --- | --- | --- |
| scroll | `59.5 / 22.4 / 27.4` | `58.4 / 23.0 / 27.7` | met | 23.0 above 22.4 | 27.7 above 27.4 |
| animation | `59.9 / 19.1 / 26.0` | `60.1 / 19.0 / 26.4` | met | met (19.0 <= 20) | 26.4 above 26.0 |
Not met on medians: scroll p95 (+0.6 ms, one after run at 25.6) and cpu on both scenarios (+0.3 and +0.4 points). Per the decision the capture is not changed further.
```
## Assumptions
- Assumption: which iOS 26 runtime — measured first on iOS 26.5, when
26.4 was not installed; the final verifier runs on head used iOS 26.4
(26.4.1).
- Assumption: what is a sometimes-changing tile — one with 1 to 7
changes in the history that is not always-changing; "did not change on
the composite before" reads the newest history bit.
- Assumption: what is "last frame sent" for the 1.5-interval rule — the
seen time of the last composite `FrameSelection` committed to the grid.
- Assumption: where to test the B5 case "nothing changed 5 ms after" —
at 6 ms, because 5 ms after the warm-up's last composite is not yet due
on the grid.
## Hardware run on head (iOS 26.4)
```text
Device iPhone 17 Pro (6D08D3AF-2C60-4CAD-8324-A3D2FB5D0C7D), iOS 26.4 (26.4.1). The tile hash now reads every 8th row and every 2nd pixel (scroll cpu was +0.9 points over before with every 4th row). Before is `fb4267632`. Columns `distinct/s / p95 / cpu`, three 20 s runs each, alternating.
- scroll before: 59.7/20.2/26.0, 59.8/20.4/25.4, 59.7/20.4/24.4
- scroll after (head): 59.6/20.3/24.6, 59.7/20.3/24.9, 59.8/20.4/24.9
- scroll medians: before `59.7 / 20.4 / 25.4`, after `59.7 / 20.3 / 24.9`
- animation before (six runs): 59.7/18.8/22.7, 60.0/18.6/24.9, 60.0/18.7/26.8, 60.0/18.6/24.9, 60.0/18.8/26.0, 60.1/18.6/25.0
- animation after (six runs): 60.1/18.5/25.4, 60.1/18.4/24.9, 60.1/18.5/25.1, 60.0/18.8/25.6, 60.0/18.7/25.2, 60.1/18.7/25.2
- animation medians: before `60.0 / 18.7 / 24.95`, after `60.1 / 18.6 / 25.2` (cpu +0.2, inside the run-to-run spread of 22.7 to 26.8)
```
## Verifier run on head 2fdf690
```text
iPhone 17 Pro (6D08D3AF-2C60-4CAD-8324-A3D2FB5D0C7D), iOS 26.4 (26.4.1), `--fps 60`, 20 s, before (`fb4267632`) and after (head `2fdf69078`) alternating, three runs each. Columns are `distinct/s / p95 / cpu`.
| Scenario | Before runs | After runs | Before median | After median |
| --- | --- | --- | --- | --- |
| scroll | `59.7/20.2/27.0`, `59.6/20.5/25.8`, `59.7/20.2/26.0` | `60.0/20.1/27.8`, `60.0/20.0/26.6`, `59.7/20.2/26.2` | `59.7 / 20.2 / 26.0` | `60.0 / 20.1 / 26.6` |
| animation | `59.9/18.8/24.0`, `60.0/18.8/25.0`, `60.0/18.7/24.7` | `60.1/18.8/25.0`, `60.0/18.8/25.4`, `60.1/18.7/24.8` | `60.0 / 18.8 / 24.7` | `60.1 / 18.8 / 25.0` |
`distinct/s` and `p95` meet the line on both scenarios. `cpu` after is above before in all six pairs (+0.1 to +1.0); by medians +0.6 on scroll, +0.3 on animation.
```
## Summary
The simulator capture hashes each composite in tiles and copies a due
one only when it carries a new app frame, or when a timing fallback says
it is overdue. The tile hash reads every 8th row and every 2nd pixel.
The 1 ms seed check is gone (#1771). Adds the counter app and
`fps-reader.mjs` that measured it; the measurements are below, oldest
first.
## Done when
- [x] `swift test --package-path vendor/screen-capture` passes. — run by
the build, the audit and each fix run; CI green at `2fdf69078`
- [x] `pnpm exec vitest run --project unit
src/source-hygiene.repo.test.ts` passes. — run by the build and the
audit; CI green at `2fdf69078`
- [x] Hardware, once on this Mac (no slow-lane test), on an iPhone 17
Pro simulator with an iOS 26 runtime (26.4, or 26.5 when 26.4 is not
installed), both named in the PR body: the PR body holds the reader's
lines for both scenarios before and after, and after shows `distinct/s`
at least 58, `p95` at most 20 ms (or, on a scenario whose before `p95`
is over 20 ms, no higher than before, by medians of three back-to-back
runs each) and `cpu` at most 1 point above before, by medians of three
back-to-back runs (approved by the maintainer 2026-11-19). — verifier
run 2 at `2fdf69078`, iPhone 17 Pro on iOS 26.4 (26.4.1), medians:
scroll 60.0 / 20.1 / 26.6 against before 59.7 / 20.2 / 26.0 (before p95
over 20, after lower; cpu +0.6); animation 60.1 / 18.8 / 25.0 against
60.0 / 18.8 / 24.7 (cpu +0.3)
- [x] #1751: On this maintainer's Apple silicon Mac, with the counter
app (I4) in its scroll scenario and in its animation scenario, in an
iPhone 17 Pro simulator on iOS 26 at `--fps 60`, the reader (I4) counts
at least 58 distinct app frames a second with a p95 gap of 20 ms or
less, and the capture's CPU is no higher than the same run with the
capture built at `fb4267632`. Both runs' numbers are posted on #1754's
pull request. — met as #1754's line words it, with the two
maintainer-approved margins (scroll p95 20.1 where before is 20.2; cpu
+0.6 and +0.3 points by medians); numbers in this body
- [x] #1751: `swift test --package-path vendor/screen-capture` passes,
the #1718 grid cases among them. — same run as line 1; the grid cases
are in the suite
## Review
Spec review: 0 blocking, 0 fixed, 0 notes. Code review: 1 blocking, 1
fixed, 0 notes. Claims review: 1 blocking, 1 fixed, 1 notes.
Rounds: 1. Tokens: 0.7M.
Runs: 12. Cost USD: 3.7385. Agent seconds: 3106.
Assessment: complete
*Written by an agent.*
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
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.
Closes #1753
Status
Implement: done; fix removed SeedWatch (approved decision on #1773) Review: passed (round 1, fix-check) Hardware: n/a Gate: waiting for the stack
Next: none until the stack merges
Assumptions
SeedWatchdedupes against the callback —SeedWatchcallsonSeedon a seed that differs from its last read, andSeedGateinFrameCapturedrops one the callback already noticed; the smallest split of I3.SeedWatch.watchkeeps across a pick — the same surface keeps the last seed read; a different surface (or nil) resets it, so the next tick reads the new surface fresh.Done when
swift test --package-path vendor/screen-capturepasses. — run by the build and the audit (16 tests, 0 failures), by the fix run that removedSeedWatch(FrameSelectionTests4/4), and by CIpnpm buildbuildsdist/bin/simlock-screen-capture. — the build ranpnpm buildand founddist/bin/simlock-screen-capture; CI builds itReview
Spec review: 1 blocking, 1 fixed, 1 notes. Code review: 0 blocking, 0 fixed, 0 notes. Claims review: 0 blocking, 0 fixed, 0 notes.
Rounds: 1. Tokens: 0.8M.
Runs: 2. Cost USD: 0.3207. Agent seconds: 245.
Rejected:
docs/internal/VENDORED-CODE.mdunder Modules touched and the diff leaves it alone [nonblocking] — the serve-sim row is generic and true as written; the per-file claims live inNOTICE.md, which the PR updatedAssessment: complete
Written by an agent.