Repository navigation
Keep the encoder quality cap for a small change to a sharpened tile, so typing is not 3 ms slower on the shipped encoder (851-4476) - #1484
Merged
pondorasti merged 5 commits intoNov 27, 2026
Conversation
…just sharpened (851-4476) Co-Authored-By: Claude Fable 5.2 <[email protected]>
…51-4476) Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
… the new metrics (851-4476) From the code review of #1484: the host no longer scans a sharpened tile to its end when the encoder in use cannot keep its cap; each plane of a capture is held to the limit on its own; changeEncoded leaves out refreshes; tilesChangedSmall and changesKeptSharp count only encodes that went through. Co-Authored-By: Claude Fable 5.2 <[email protected]>
pondorasti
deleted the
alexandru/851-4476-screen-sharing-typings-worst-cases-are
branch
November 27, 2026 03:37
This was referenced Nov 27, 2026
pondorasti
added a commit
that referenced
this pull request
Nov 27, 2026
…#1505) #1484 added --small to every host-lab variant's arguments; this test still listed the old ones, so main's checks-swift failed. Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Fixes 851-4476
What was wrong
On the encoder the app ships with (VCP behind the rate switch), a keystroke at normal typing speed took about 4 ms longer from capture to ready on the viewer than on the fallback encoder (17 ms against 13). After each keystroke the host runs a sharpening pass with the session's quality cap lowered (QP 6), and the next keystroke set it back (QP 28). The call that moves the cap is cheap (0.4 ms), but the first frame a session encodes after the cap moved takes about 3 ms longer (lab runs 45725747447 and 45726853454 on tamale). At a small display offset between the two Macs that cost a whole refresh (weekly run 44473660542: 36 against 20 ms median).
What changes
changeEncoded(a change's capture callback to the encoder's output),tilesChangedSmall,changesKeptSharp,encoderQPCapChanges. The host lab takessmall=<pixels>(0 turns the rule off).Threshold and before/after on the mini (host only)
Lab run 45736432148 on tamale: shipped encoder, 4K virtual display, 20 s per run, each scene run without the rule, with it (16,384), and without it again. Typing was played twice from the start.
Updates/s is captures a second; kbit/s leaves out the first keyframes.
Threshold choice (lab runs 45733097776 and 45734977598, an earlier build that measured every tile): at 4,096 pixels the bench's typing changes were almost never small (22 of 626 tiles; the barcode alone spans more), at 16,384 nearly all were (671 of 684; idle cursor 519 of 526), and 65,536 added nothing on these scenes while allowing larger sharp frames. So 16,384. That earlier build also showed why only sharpened tiles are measured: measuring every changed tile cost window drag 0.4 ms per capture.
Two Macs
Run 45737633389: Apple High Performance, the shipped encoder with the rule and the shipped encoder without it, alternating in one dispatch (from the throwaway branch
alexandru/851-4476-typing-lab-t2, which adds a lab system that turns the rule off). 4K virtual display, good network, 2 repetitions of 30 s, 22 runs, none skipped, display offset between the minis 5.2 ms. Image age in ms, repetition 1 / repetition 2:Sharpness (test cards on two Macs, viewer on a 4K virtual display so the picture is 1:1): run 45741611237, 2 repetitions each. With and without the rule every repetition gave the same: luma PSNR 61.2 dB (53.3 on the text), SSIM 0.9999, colour PSNR 57.2 dB, ΔE00 0.33 mean. A card change is large, so it takes the unchanged path.
Confirmation on the final code (run 45925610081, attempt 2; the fix with the review changes, b628ffe; typing only, 3 repetitions, display offset 10.3 ms):
Tests
ScreenSharingVCPSmallChangeTests(hardware): the stack the app ships, built byScreenSharingV2Encoders.make(ScreenSharingV2EncoderKind.configured(), …)on a manual clock and moved to the fast route. A small change after a sharpening pass leaves the cap alone (one cap change in the session); a large one sets it back (two). Fails without the fix (two cap changes for the small change).ScreenSharingVCPEncoderStateTests: the cap for a small change after a sharpening pass, for a large change, another tile's small change, a refresh, the second change in a row, and after the bitrate fell below Apple's ladder. Two of them fail without the fix.ScreenSharingV2TileComparerTests,ScreenSharingV2CaptureSlotTests,ScreenSharingV2HostSmallChangeTests: what counts as small, how long a waiting tile stays small, and that the host only calls a change small when its tile was sharpened last.Checked by hand and not
ScreenSharingV2Testsbundle locally (154 tests without the hardware suites, plus the VCP hardware suites) on an M1 Pro.Code review (medium) and what changed after it
Five findings, all fixed in b628ffe, each with a test where there is behaviour to test:
keepsItsCapForSmallChanges) and the host measures only then.changeEncodedalso timed refreshes of an old capture (a loss refresh after an idle screen would add seconds). It now leaves out refreshes.tilesChangedSmallandchangesKeptSharpcounted before the encode went through, and a refreshed tile counted as small. They count after, and a refreshed tile is not passed as small.🤖 Generated with Claude Code