Skip to content

fix(editor): keep the OS memory pressure source out of audio cache unit tests - #3029

Merged
richiemcilroy merged 1 commit into
mainfrom
fix/editor-audio-test-flake
Oct 24, 2026
Merged

richiemcilroy merged 1 commit into
mainfrom
fix/editor-audio-test-flake

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Fixes the intermittent sync-tests (macos-latest) failures in audio::tests::a_replay_resumes_a_parked_render and audio::tests::a_stale_render_is_released_once_the_next_render_finishes (added in #2521).

Cause

PlaybackAudioCache::with_idle_release calls memory_pressure::watch() (crates/editor/src/audio.rs:1786), which installs a real process-wide DISPATCH_SOURCE_TYPE_MEMORYPRESSURE source. Its handler calls release_playback_audio_caches() (audio.rs:1761), which empties every cache in the process.

The tests guard the simulated release in export_and_memory_pressure_release_every_cached_render with the CACHE_RELEASE write lock (audio.rs:4724), but nothing guards the real OS source. On a loaded macOS runner a warn-level pressure event can arrive at any time, and every test that asserts a cached render is still there fails together:

  • a_replay_resumes_a_parked_render (audio.rs:5378): the entry is gone, so from_cache misses and the replay builds a fresh render.
  • a_stale_render_is_released_once_the_next_render_finishes (audio.rs:5269): the paused render is freed before the 50 ms check.

In run 2755 both tests failed within 62 ms of each other, which fits one process-wide release and not two independent races. The product behaviour is intended: under memory pressure the parked render should be dropped and the next play renders fresh.

Fix

memory_pressure::watch() returns early under cfg!(test), so the editor's unit tests no longer receive host memory pressure events. The release path is still covered by calling on_memory_pressure directly in export_and_memory_pressure_release_every_cached_render. Non-test builds are unchanged. No assertions, sleeps or timeouts were changed.

Verification

CI on this PR: A/V Sync Tests passed on macOS, Ubuntu and Windows (45 checks green). export_and_memory_pressure_release_every_cached_render still covers the release path by calling on_memory_pressure directly. Before the fix, 3 of 14 macOS sync-tests runs on unrelated PRs failed these two tests, and two of the failures landed within 62 ms of each other in one run, which points to a single process-wide release.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; it isolates unit tests without changing production behavior.

Summary

Prevents macOS memory pressure events from clearing audio caches during editor unit tests.

  • Editor unit tests skip the host memory-pressure watcher.

Reviews (1) · Last reviewed commit: "fix(editor): keep the OS memory pressure..." · Reviewed by Greptile

@vercel

vercel Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cap-status Ready Ready Preview Oct 23, 2026 11:41pm UTC

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found no issues.

View 1 other finding in Capy.

Open in Capy

@richiemcilroy
richiemcilroy merged commit 646eac4 into main Oct 24, 2026
56 checks passed

This branch was successfully deployed

2 active deployments
Preview – cap-web — ed99d1f5 Deployed Oct 23, 2026 by vercel[bot]
Preview – cap-status — ed99d1f5 Deployed Oct 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant