Skip to content

Fix brightness races, display resource leaks, and DDC/build errors - #4

Merged
shay2000 merged 2 commits into
mainfrom
codex/fix-display-reliability
Sep 12, 2026
Merged

shay2000 merged 2 commits into
mainfrom
codex/fix-display-reliability

Conversation

@shay2000

@shay2000 shay2000 commented Sep 12, 2026 •

Copy link
Copy Markdown
Owner

A brightness restore after waking could overwrite newer user input. Repeated display discovery retained resources, Intel DDC replies lost their high bytes, and failed builds could be accepted as usable app bundles.

  • Cancel superseded software-brightness ramps, apply their exact endpoint on the main queue, and stop queued steps during sleep or reconfiguration. Keep semaphore permits balanced.
  • Release IOKit handles, temporary buffers, and closed shade windows along their ownership paths, including optimized builds and failure exits.
  • Keep I2C buffers valid throughout synchronous requests and preserve all 16 bits of Intel DDC values.
  • Roll back failed EDR setup before applying an XDR gamma boost.
  • Require successful compilation, an existing app bundle, and a valid final signature before reporting build success; preserve the ad-hoc signing fallback.

Validation: 22 XCTest tests passed with no reported runtime warnings, including stale-write, endpoint, cancellation, shade-deallocation, semaphore, and DDC-decoding regressions. All five build-script cases passed; the partial-output case reproduced false success before the fix. A universal Release build using Xcode 27 beta contains x86_64 and arm64 and passes deep, strict codesign verification. GitHub CI passed build/test and universal DMG jobs for c6a41c0.

Physical monitor adjustment and hot-plug behavior were not exercised. The Metal setup failure guard was reviewed and compiled, but that failure was not injected at runtime.

@greptile-apps

greptile-apps Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR improves display-state correctness, resource ownership, DDC communication, and build artifact validation.

  • Cancels superseded software-brightness ramps and prevents queued writes during sleep or display reconfiguration.
  • Releases IOKit objects, temporary allocations, and closed shade windows along their ownership paths.
  • Keeps I2C buffers alive during synchronous requests and correctly decodes 16-bit DDC values.
  • Rolls back incomplete EDR setup before attempting an XDR gamma boost.
  • Rejects failed, missing, or incorrectly signed build outputs and adds regression coverage in CI.

Confidence Score: 5/5

The PR appears safe to merge, with no accepted new findings or outstanding review issues provided for re-evaluation.

The current head is identical to the previous review SHA, so there are no changes since the previous review that introduce a new actionable issue; the full diff also contains no confirmed repository-rule violations.

Important Files Changed

Filename Overview
MonitorControl/Model/Display.swift Adds generation-based cancellation, balanced semaphore handling, main-thread ramp steps, and exact software-brightness endpoints.
MonitorControl/Support/IntelDDC.swift Corrects I2C buffer lifetimes, preserves both bytes of DDC words, and closes IOKit ownership leaks.
MonitorControl/Support/Arm64DDC.swift Releases traversed registry entries and temporary path storage while preserving ownership of returned entries.
MonitorControl/Support/DisplayManager.swift Removes permanent retention of closed shade windows and explicitly controls AppKit close behavior.
MonitorControl/Support/XDREngine.swift Stops and rolls back incomplete EDR setup before applying an XDR boost.
build/build.sh Requires successful compilation, an existing bundle, and a valid final signature before reporting success.
build/test-build.sh Adds isolated regression cases for partial builds, successful builds, signing fallback, missing artifacts, and invalid signatures.
.github/workflows/ci.yml Runs build-script failure-handling regression tests in CI.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Brightness request] --> B[Increment request generation]
  B --> C{Smooth request?}
  C -- No --> D[Apply exact value]
  C -- Yes --> E[Queue next main-thread step]
  E --> F{Current generation and system active?}
  F -- No --> G[Cancel queued ramp]
  F -- Yes --> H[Apply bounded step]
  H --> I{Target reached?}
  I -- No --> E
  I -- Yes --> J[Exact endpoint applied]
Loading

Reviews (3): Last reviewed commit: "Fix stale brightness ramps and Intel DDC..." | Re-trigger Greptile

@shay2000 shay2000 changed the title Fix display resource leaks and brightness/build reliability Fix brightness races, display resource leaks, and DDC/build errors Sep 12, 2026
@shay2000

Copy link
Copy Markdown
Owner Author

@greptileai

@shay2000
shay2000 merged commit 873fb89 into main Sep 12, 2026
3 checks passed
@shay2000
shay2000 deleted the codex/fix-display-reliability branch September 12, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant