Skip to content

fix: gate background preview rendering on system resources - #6

Merged
MoraesGil merged 2 commits into
mainfrom
codex/preview-resource-gate
Nov 14, 2026
Merged

MoraesGil merged 2 commits into
mainfrom
codex/preview-resource-gate

Conversation

@MoraesGil

@MoraesGil MoraesGil commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

What changes

Finder and the background indexer share one nonblocking slot for heavy 3MF and G-code geometry work. They check host CPU and GPU usage before starting and at checkpoints during long mesh and toolpath reads. Busy Quick Look requests can display a cached or embedded image. The indexer retries deferred geometry on a later eligible pass.

Why

A two-second sample of the installed preview extension showed six concurrent panorama requests inside the XML mesh parser. Painted triangle parsing repeatedly copied Swift array storage.

How it was checked

Before After
The isolated parser took 1.70 seconds for 120,000 painted triangles (median of three optimized runs). Reading the triangle count before mutating the paint arrays took 0.43 seconds on the same synthetic input. This benchmark measures the parser only.
Six heavy callbacks could overlap in the sampled extension. The regression suite exercises exclusive admission, lease release, resource thresholds, interrupted XML parsing and deferral without a partial cache entry.

Notes for the reviewer

Both measured loads must be below 30%. The memory admission estimate must leave 25% available. Serious thermal state and Low Power Mode block geometry. If a GPU counter is unavailable, three minutes of user inactivity is also required. The optional unattended indexer retains its AC and idle checks. These are admission thresholds with cooperative rechecks, not instantaneous hardware quotas.

The final native XCTest run passed all 71 tests. A standalone macOS probe signed with the preview extension’s sandbox entitlements acquired the shared slot, rejected an overlapping acquisition and reacquired it after release. Both extensions receive write access to a single empty lock file in the user’s Application Support directory. Finder interaction under load has not been visually recorded.

@MoraesGil MoraesGil added the bug Something isn't working label Nov 14, 2026
@MoraesGil
MoraesGil merged commit 36d9fd5 into main Nov 14, 2026
1 check passed
@MoraesGil
MoraesGil deleted the codex/preview-resource-gate branch November 14, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant