fix(miri): pace from where they show the windows of apps focus moves between, and hand slice photos over once shown#91

merged7
miri/v0.5.2
miri/163-focus-and-slices
opened12d agobySSamanyu Das
View on GitHubTwo-way sync enabledPR last imported 11d ago

Refs samanyudas/miri#163. Stacked on #90: the base is miri/163-pacing.

Summary

Two fixes to the pacing from #90.

1. Focus changes between apps. Helium and Beeper can turn slow right after a focus change. Before this, a window whose app kept up through the last motion still counted as prompt, so the window ahead of it ran off and the desktop showed between them.

diff
1 on(focus change)
2+ if focus moves from one app to another
3+ forget what pacing saw of every window of both apps
4+ (they pace from where the window server shows them until they keep up through a whole motion again)

A focus move between two windows of one app forgets nothing. Resetting those too made every window of a one-app row wait a frame for the window behind it (the design reverted in the combined review).

2. Slice photo handover at the shared edge (x = 0). The photo closed when the app had taken the window's move, before the window server showed the window there. The bare desktop flashed where the photo had been.

diff
1 frame
2+ place slice panels, then commit Core Animation at once
3 write window frames
4- photo sliding in: close once the AX write returns
5+ photo sliding in: close once the window server shows its window at rest
6+ (on a frame the sampler read, never on a seed), or after 250 ms

The panels used to be placed after the window writes. A layer-backed panel shows a new frame only at the next run loop pass, so the window ahead could show its move a frame before the photo grew beside it. A lab probe confirmed this, and so did a live run.

Evidence

New harness tests. Each fails on its test commit and passes after the fix:

text
1the_window_ahead_waits_for_a_prompt_window_whose_app_gains_focus
2a_photo_sliding_in_stays_up_until_its_window_shows_where_it_rests
3a_sliding_photo_takes_its_place_before_the_windows_ahead_move

These two guard the timeout and the read snapshot. They pass both before and after the fix:

text
1a_photo_sliding_in_closes_after_a_while_when_its_window_does_not_show
2a_window_counts_as_read_only_once_the_sampler_has_read_it

Checks on this branch:

  • cargo fmt --check passes.
  • cargo clippy -- -D warnings passes.
  • cargo clippy --all-targets -- -D warnings shows the base's 13 pre-existing errors.
  • cargo test passes.

Live on Sam's Mac, 30 October 2026, with fast-release engines. Both builds also have #86. The earlier build is #86 + #87 + #90, and the new build adds this PR. The measurements alternated between the builds in the same session:

measurebeforeafter
desktop between different apps, 4 rounds of 12 presses100 ms in 1 of 4 bursts0 in 4 bursts
switch apps and reverse at once (S1), 10 tries in each of 3 sessionsdesktop in 1/10 each time0/10 each time
slice crossing: frames showing wallpaper in the flash casehandover 3 to 5 ms after the write, before the window could shownone, handover about 19 ms, each on a real read
widest desktop beside a sliding photo1687 pt284 pt
busy app (#86 case), longest pause165 ms112 ms
front window starts moving from rest, median / p90116 / 411 ms107 / 405 ms
time to place p50 / max, overshoot391 / 786 ms, 0392 / 747 ms, 0
quit within 1 s of a move leaves Helium's AXEnhancedUserInterface onyesyes, 3 of 3
stopped app does not stall the rowrecoversrecovers

Costs and what is left:

  • Spotify paused 4 times mid-motion over 40 ms instead of 2, because the windows of the apps that focus moves between now pace from where they show.
  • One burst of 4 showed 33 ms of desktop between two Helium windows. A focus move within one app resets nothing, on purpose.
  • A leaving photo is still paced from where the engine put it. Focusing a stopped app still holds the engine about 0.85 s in AXRaise, in both builds.

The recordings and frame captures stay local for privacy.

Reviewed with sol-loop: 3 rounds with gpt-6.1-sol on high. Sol verdict: approved.

Merge Danger

Door: two-way

A revert restores #90's behavior. The change touches no stored state or config.

Blast Radius: animation

It changes only pacing during row animations and the slice photo handover at the shared edge. If the handover check fails, a photo stays up for at most 250 ms longer.

๐Ÿค– Generated with Claude Code

Checks

1 skipped
All checks passed
d931c56
Synced from GitHub

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

External image Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: da77d3b5-70c4-4efd-b586-acd66bb9f8e8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ๐Ÿ” Trigger review
  • 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.

โค๏ธ Share

Comment @coderabbitai help to get the list of available commands.

Added 7 commits

  • fix(miri): pace from where they show the windows of apps that focus moves between2a0079b
  • fix(miri): close a sliding photo only once the window server shows its window at rest3a3ef9b
  • test(miri): keep a sliding photo up until its window shows where it rests813ec43
  • test(miri): pace from where they show the windows of an app that gains focusd77c2f4
  • fix(miri): hand a photo over only on a frame read from the window serverd931c56
  • fix(miri): place a sliding photo before the windows ahead of it movee769404
  • test(miri): place a sliding photo before the windows ahead of it moveef17d95