Skip to content

render: report Metal device failures in Release - #5076

Merged
jakildev merged 1 commit into
masterfrom
claude/4995-metal-device-errors
Nov 18, 2026
Merged

jakildev merged 1 commit into
masterfrom
claude/4995-metal-device-errors

Conversation

@jakildev

@jakildev jakildev commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • make Metal allocation, shader-library, and render-pipeline failures throw descriptive exceptions in Debug and Release
  • count command-buffer failures and drawable-starved frames in backend statistics and profile reports
  • reject profiled runs with command-buffer errors, with focused Metal and report coverage

Plan departures

  • The render-pipeline failure test uses a one-shot null pipeline-state seam after constructing a valid descriptor. An attachment mismatch aborts inside Metal when API validation is enabled, before the engine can exercise its error path; the seam reaches the same production null-result handling and verifies the emitted pipeline description.
  • After the former stack base merged, the PR was rebased onto origin/master by replaying only its own commit. The failure path and test seam now use the current MetalRenderPipelineKey API, while the merged base implementation is inherited from master.
  • Criterion 7's literal zero-delta clause is not true of the current committed macOS reference set. IRCanvasStress passes all 59 checks but carries the same inherited so3_wide_parity reading on PR head and master. IRShapeDebug has 20 failing reference rows on PR head; every one appears on same-session origin/master with identical metrics. This PR does not move either set of rows.

Acceptance evidence

Criterion Check run Observed
1. Buffer allocation failure names kind and size fleet-run IrredenEngineTest --gtest_filter='MetalDeviceErrorsTest.*:ProfileReportDeviceErrors.*' BufferAllocationFailureNamesKindAndSize passed and observed buffer plus 64 bytes.
2. 2D and 3D texture failures name dimensions same focused Debug suite TextureAllocationFailuresNameDimensions passed for 17x19x1 and 7x11x13.
3. Shader-library and render-pipeline failures are descriptive same focused Debug suite Both failure tests passed; the compiler path/error and vertex/fragment/color/depth pipeline description were observed through the current pipeline-key API.
4. Command-buffer and skipped-frame classification is reported same focused Debug suite CommandBufferAndSkippedFrameCountersAreReported passed with +1 for each counter and first error frame/text 23 / injected command failure; the headless fixture did not count its null layer as a skipped drawable.
5. Release evaluates the checks fleet-run --release IrredenEngineTest --gtest_filter='MetalDeviceErrorsTest.*:ProfileReportDeviceErrors.*' 6 tests passed in the Release tree; the Release-safe checks fired without relying on log macros.
6. Reports carry counters and repeat-profile rejects errors python3 -m unittest discover -p 'test_*.py' in scripts/perf; focused C++ suite above 167 Python tests passed, including zero/positive command-buffer rows; the C++ report test passed with zero-valued healthy rows plus first-error text.
7. ShapeDebug and CanvasStress remain visually unchanged light-verify, paired IRCanvasStress runs, and same-session paired IRShapeDebug manifests Light verification passed 46/46. CanvasStress passed 59/59 on PR head and master with the same inherited so3_wide_parity metric. On 2026-11-17, PR head 75c6ea77 job 20261117T221545Z-render-verify-7bdb33 completed 148 checks: 20 failed and 10 skipped for pending references. Current master 44955ae9 control job 20261117T224037Z-render-verify-f76179 completed 176 checks: all 20 PR-head failures reproduced with identical metrics; its additional failures belong to post-PR master changes. Both terminal jobs exited 1 for reference mismatches with an awake macOS display; no host-domain failure occurred.

Test plan

  • fleet-run IrredenEngineTest — 3,839 passed, 3 expected backend/platform skips
  • focused Debug Metal/report suite — 6 passed
  • focused Release Metal/report suite — 6 passed
  • python3 -m unittest discover -p 'test_*.py' from scripts/perf — 167 passed
  • ruff check scripts/
  • fleet-build --target header-checks — 844 headers scanned; all convention checks passed
  • fleet-build --target format-changed
  • git diff --check
  • python3 scripts/light-verify.py --if-changed — 46 checks passed on macOS Metal
  • python3 scripts/render-verify.py --target IRCanvasStress — 59/59 twice; same-session master metrics match
  • python3 scripts/render-verify.py --target IRShapeDebug — every PR-head failure reproduced on same-session current master with identical metrics

Refs #4995

Authored by Codex (GPT-5 runtime).

@jakildev jakildev added fleet:wip Work in progress — not ready for review fleet:awaiting-infra Complete-but-unverifiable PR parked until an infra blocker lands; body carries Parked-until: #N fleet:author-codex Implementation last authored by Codex; route review to Claude fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend labels Nov 12, 2026
@jakildev
jakildev added this pull request to stack #5077 November 12, 2026 11:10
Base automatically changed from claude/4993-metal-staged-buffer-patch to master November 15, 2026 23:45
@evin-mac-claude-app evin-mac-claude-app Bot removed the fleet:awaiting-infra Complete-but-unverifiable PR parked until an infra blocker lands; body carries Parked-until: #N label Nov 16, 2026
@evin-mac-claude-app evin-mac-claude-app Bot added fleet:design-unblocked Architect responded; worker resumes per the architect comment + updated plan file fleet:amending-mac-pool-2 labels Nov 16, 2026
@jakildev jakildev removed the fleet:design-unblocked Architect responded; worker resumes per the architect comment + updated plan file label Nov 16, 2026
Authored-by: Codex (GPT-5 runtime)
@jakildev
jakildev force-pushed the claude/4995-metal-device-errors branch from f34ee1e to 75c6ea7 Compare November 16, 2026 09:17
@jakildev jakildev added fleet:needs-macos-host Remaining work needs a macOS host; non-mac panes skip (dispatch, claim, amending-claim) and removed fleet:amending-mac-pool-2 labels Nov 16, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Addressed feedback: rebased only the PR-owned commit onto current master; integrated the MetalRenderPipelineKey API and the adjacent profile-report test; reran Debug, Release, full C++, Python, lint, formatting, and header validation. Visual verification remains host-blocked after two supervised attempts because the macOS display is asleep, so the PR remains WIP with fleet:needs-macos-host. — worker

@github-actions

Copy link
Copy Markdown

Perf gate

Head host slug: linux-x86_64-epyc-9v74-80-unknown

perf comparison: cc736b3 → eac59bf-ci

baseline: /home/runner/work/_temp/perf-baseline/history/linux-x86_64-epyc-9v74-80-unknown/cc736b396be3ce0e1d519d18ba1a260fffcd64da
head: /home/runner/work/IrredenEngine/IrredenEngine/save_files/perf/eac59bff6-ci

host calibration

  • host: linux-x86_64-epyc-9v74-80-unknown (matches baseline)
  • ref_ms: head 90.29 vs baseline 90.00 (load_factor 1.00×)
  • calibration target: 50.00 ms (informational)
  • baseline capture: perf-baseline@cc736b396 (branch tip); master 63ca21670, finished 2026-11-06T17:48:54Z, 9.7 d before the head run, ref_ms 90.00
  • weighting: raw (class-matched capture; load_factor 1.00×; no calibration-scaling entry)
  • attribution: no measured master improvement between capture master 63ca21670 and merge base 345dbbf25 (66 commits)

thresholds: regress ≥ 10%, improve ≥ 5%

voxel cull effectiveness

cell ratio (base→head) avg visible total avg feeder
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 1.000 → 1.000 (+0.0pp) 262144 → 262144 262144 → 1024 0 → 0
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.788 → 0.598 (-19.1pp) 156630 → 156630 262144 → 1024 50080 → 0 (0.000×)
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 1.000 → 1.000 (+0.0pp) 262144 → 262144 262144 → 1024 0 → 0
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.990 → 0.975 (-1.5pp) 255592 → 255592 262144 → 1024 3862 → 0 (0.000×)

frame timing (ms)

cell avg p99
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 387.38 → 413.61 (+6.8%) 1368.48 → 1434.50 (+4.8%)
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 930.03 → 903.04 (-2.9%) 1947.29 → 1942.02 (-0.3%)
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 487.77 → 506.95 (+3.9%) 7440.40 → 7513.80 (+1.0%)
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 1234.39 → 1294.59 (+4.9%) 2264.99 → 2321.93 (+2.5%)

GPU frame timing (ms; separate from stage samples)

cell envelope (base→head) buffer spans (base→head) coverage (base→head)
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable

GPU stage timing (avg ms per sampled invocation)

Window rows on one side and exclusive rows on the other measure different things, so these cells carry no stage marks: target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1, target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1, target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1, target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1.

cell canvasClear voxelCompact voxelStage1 voxelCardinalElect voxelStage2 voxelSunFaces textToTrixel buildLightOcclusionGrid computeVoxelAO bakeSunShadowMap computeSunShadow computeLightVolume lightingToTrixel fogToTrixel trixelToFb resolvePerAxisScreenDepth fbToScreen
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 47.68→15.28 48.06→47.87 43.97→43.79 0.77→0.86 42.78→43.60 4.81→68.48 — 0.00→0.00 2.37→2.42 11.98→22.19 17.41→17.70 15.54→15.34 3.38→3.30 1.02→1.06 0.17→0.20 — 6.28→6.54
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 85.34→15.90 293.00→223.78 179.48→182.38 2.85→2.85 160.39→163.92 4.41→111.74 — 0.00→0.00 2.03→2.03 21.15→36.54 15.59→15.94 12.94→13.31 6.58→6.81 1.16→1.20 0.16→0.16 — 5.84→5.84
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 42.27→14.18 57.38→57.99 47.95→48.23 7.49→7.41 37.51→38.42 6.98→62.74 0.74→0.79 0.00→0.00 0.84→5.49 39.22→45.03 15.63→16.54 32.55→32.87 5.30→5.29 1.39→1.41 0.16→0.16 0.00→0.00 7.05→6.95
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 91.21→15.14 358.58→358.53 291.53→297.13 4.43→4.42 252.54→257.87 4.91→117.93 0.76→0.77 0.00→0.00 0.63→2.14 18.73→48.54 16.12→17.74 12.84→14.54 5.50→5.87 1.25→1.15 0.15→0.15 0.00→0.00 5.85→5.85

top CPU systems by avg ms (head)

target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 191.271 → 222.619 (+16.4%) ⚠
RENDER ComputeLightVolume 32.541 → 32.604 (+0.2%)
RENDER ComputeSunShadow 6.420 → 16.524 (+157.4%) ⚠
RENDER CanvasToFramebuffer 15.320 → 15.239 (-0.5%)
RENDER BakeSunShadowMap 7.876 → 7.951 (+1.0%)
UPDATE PropagateTransform 3.863 → 3.899 (+0.9%)
RENDER LightingToTrixel 3.505 → 3.432 (-2.1%)
UPDATE FogRevealEval 3.191 → 3.239 (+1.5%)

target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 726.460 → 699.248 (-3.7%)
RENDER ComputeSunShadow 16.643 → 32.211 (+93.5%) ⚠
RENDER ComputeLightVolume 28.133 → 28.853 (+2.6%)
RENDER CanvasToFramebuffer 14.318 → 14.071 (-1.7%)
RENDER ComputeVoxelAO 5.987 → 7.073 (+18.1%) ⚠
RENDER LightingToTrixel 6.759 → 6.967 (+3.1%)
RENDER BakeSunShadowMap 6.498 → 6.462 (-0.6%)
UPDATE PropagateTransform 3.765 → 3.764 (-0.0%)

target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 209.862 → 240.060 (+14.4%) ⚠
RENDER ComputeSunShadow 33.923 → 39.613 (+16.8%) ⚠
RENDER ComputeLightVolume 29.755 → 30.834 (+3.6%)
RENDER LightingToTrixel 19.508 → 19.694 (+1.0%)
RENDER CanvasToFramebuffer 15.191 → 15.454 (+1.7%)
RENDER BakeSunShadowMap 10.089 → 10.203 (+1.1%)
UPDATE PropagateTransform 5.249 → 5.303 (+1.0%)
RENDER FogToTrixel 4.581 → 4.599 (+0.4%)

target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 1005.008 → 1050.956 (+4.6%)
RENDER ComputeSunShadow 14.149 → 43.640 (+208.4%) ⚠
RENDER ComputeLightVolume 28.577 → 31.863 (+11.5%) ⚠
RENDER CanvasToFramebuffer 14.045 → 13.858 (-1.3%)
RENDER BakeSunShadowMap 6.710 → 6.851 (+2.1%)
RENDER LightingToTrixel 5.644 → 6.076 (+7.7%)
RENDER ComputeVoxelAO 4.908 → 5.927 (+20.8%) ⚠
UPDATE PropagateTransform 5.189 → 5.292 (+2.0%)

@evin-mac-claude-app evin-mac-claude-app Bot added fleet:design-unblocked Architect responded; worker resumes per the architect comment + updated plan file fleet:amending-mac-pool-1 labels Nov 16, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Design-unblocked validation progress on the awake macOS host:

  • light-verify --if-changed: all 46 checks PASS (20261116T122937Z-light-verify-e8d09b, exit 0).
  • IRCanvasStress: all 59 checks PASS twice on PR head and once on a same-session origin/master control. All three report the identical inherited so3_wide_parity metric (99.9999%, max delta 32), matching the known-clean reading documented by render: restore CanvasStress output moved by rotation-picking merge #4945; this PR does not move the row.
  • IRShapeDebug: two full manifest attempts were stopped after repeated fleet quiet-window stalls before an aggregate comparison. The isolated case where the first attempt appeared stuck (glitch_subject_standard_off) exits cleanly in 4 seconds when run directly, so no PR behavior failure was observed.

The PR body now carries the exact evidence and leaves ShapeDebug unchecked. Keeping fleet:wip, fleet:design-unblocked, and fleet:needs-macos-host so a later macOS pass can finish the remaining validator. — worker

@jakildev

Copy link
Copy Markdown
Owner Author

ShapeDebug validation update on the awake-then-sleeping macOS host:

  • PR head job 20261116T134459Z-render-verify-527bf5 completed the full manifest: 128/148 checks passed, 20 reference rows failed, and 10 rows were skipped because macOS references are pending.
  • Same-session origin/master control job 20261116T140204Z-render-verify-ac823a lost the display mid-manifest at prefab_flower (RESULT=NO-DISPLAY, exit 69), so it produced no attribution verdict.
  • The one permitted domain-failure rerun, 20261116T142642Z-render-verify-cdeef0, failed preflight with one online but sleeping display (awake=0; engine monitor discovery 0), exit 69.

The PR body now records these exact results. Because the master control could not complete, the 20 PR-head rows cannot yet be classified as inherited or introduced. Keeping fleet:wip, fleet:design-unblocked, and fleet:needs-macos-host for a later awake macOS pass; no code or PR-head commit changed in this iteration. — worker (Codex)

@jakildev jakildev added fleet:changes-made Agent addressed human feedback — ready for human re-review and removed fleet:design-unblocked Architect responded; worker resumes per the architect comment + updated plan file fleet:needs-macos-host Remaining work needs a macOS host; non-mac panes skip (dispatch, claim, amending-claim) labels Nov 17, 2026
@jakildev
jakildev marked this pull request as ready for review November 17, 2026 23:07
@jakildev

Copy link
Copy Markdown
Owner Author

Addressed feedback:

  • Re-ran the complete IRShapeDebug manifest on PR head 75c6ea77: job 20261117T221545Z-render-verify-7bdb33 completed 148 checks with the known 20 reference failures and 10 pending-reference skips.
  • Ran the required same-session control on current origin/master 44955ae9: job 20261117T224037Z-render-verify-f76179 completed 176 checks; every PR-head failure reproduced with identical metrics. The additional master failures are from post-PR changes.
  • Updated the PR evidence, completed the remaining checklist item, cleared the macOS/design/WIP labels, and marked the PR ready for review. No PR-head code changed.

— worker (Codex)

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Review — Metal device errors: descriptive exceptions and command-buffer/skipped-frame counters

Verdict: approve

The change does what #4995 asked: allocation, shader-library and render-pipeline failures throw named std::runtime_errors in Debug and Release, and command-buffer errors and skipped frames flow through DeviceErrorStats into the profile report and repeat_profile.py. I found no blocker or needs-fix defect.

Nits (follow-up)

  • engine/render/src/metal/metal_runtime.cpp:645-698 — newMetalBuffer/newMetalTexture check the test-only failNextAllocationArmed_ seam on every production allocation. It is a single bool read and harmless, but the seam entry points (failNextMetalAllocationForTesting, failNextMetalRenderPipelineForTesting, compileMetalRenderPipelineForTesting) live in the public metal_runtime.hpp. Consider a detail/testing header next time this file is touched.
  • test/render/gpu_compute_dispatch_test.cpp:1074-1089 — CommandBufferAndSkippedFrameCountersAreReported asserts firstCommandBufferErrorFrame_ == 23 and the exact first-error text. recordMetalCommandBufferCompletion keeps only the first error per process, so the test passes only while no earlier test or real frame has recorded one. Today that holds. Asserting on the delta, or resetting the first-error state in the fixture, would remove the order dependence.
  • engine/render/src/metal/metal_pipeline.cpp:320-330 — the new throw for a missing shader function leaves the already-created MTL::Functions and library of earlier stages unreleased. This is a leak on a path that already terminates the run, so it is only worth tidying if the constructor is reworked.

Praise

  • Replacing IR_ASSERT with a thrown exception fixes a real Release gap: the old assert stripped its expression and condition in Release, so an allocation failure was a null dereference there.
  • firstCommandBufferError_ is a string_view into runtime-owned storage that is written once and never reassigned, so the by-value RenderDeviceStats copy in deviceStats() stays valid.
  • recordCompletedFrameBuffer runs only after waitUntilCompleted() in present()/finish(), so the counters are mutated on the render thread with no completion-handler race.
  • The report writer and World::buildAndWriteProfileReport gate the new counters on the existing deviceCountersSupported_, so OpenGL does not report zeros as measured.

Checked

  • Read the full diff and the touched call sites in metal_render_impl.cpp (beginFrame, present, finish, recordCompletedFrameBuffer) and world.cpp (recordDeviceCounters, buildAndWriteProfileReport).
  • CI, inherited red: render-harness-tests is red on this head because test_harness_dependency_contract.py flags scripts/verify_common.py importing fleet. This PR does not touch that file (empty diff vs master). I ran the test on the PR head (reproduces, 3 failures) and on current origin/master (13 tests OK, fixed upstream by #5109 after this branch's merge base, 2026-11-15). The failing run is from 2026-11-16 on this same head, so a rebase or re-run onto current master should clear it. Not held against the PR.
  • CI, all other checks on the head are green: linux-build, header-checks, format-check, fleet-tests, python-lint, perf-gate, comment-refs, closes-lint.
  • Acceptance: the body says Refs #4995, not Closes, so I did not dispatch the acceptance grader. I read the ## Acceptance evidence table against the diff: each of criteria 1-6 is backed by a test in the diff, and criterion 7's departure (inherited ShapeDebug and CanvasStress rows, same-session master control) is documented.
  • Not run by me: the Metal gtest suite, render-verify and light-verify (macOS-host; I am relying on the author's recorded job IDs).

Test plan the author should run before merge

  • Re-run render-harness-tests on a master-rebased head to confirm the inherited red clears.

Escalation: please Opus-recheck before merge (touches: engine/render, engine/world).

🤖 Reviewed by Claude Sonnet 5.5 (review-pr skill)

Opus recheck required: touches engine/render/ (Metal allocation, pipeline, and command-buffer error paths) and engine/world/ (per-frame device-counter bookkeeping); how thrown allocation failures propagate through frame init, and the lifetime of the string_view first-error handoff, deserve a core-path read.

@jakildev jakildev added fleet:needs-opus-recheck Sonnet flagged this PR for Opus recheck before merge and removed fleet:changes-made Agent addressed human feedback — ready for human re-review fleet:reviewing-mac-pool-2 labels Nov 17, 2026

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Opus recheck — Metal device errors: descriptive exceptions and command-buffer/skipped-frame counters

Verdict: approve

I agree with Sonnet's approve. I spent this pass on the two items Sonnet escalated: where the new throws land, and the lifetime of the string_view first-error handoff. I also checked counter coverage across every commit site and the per-frame cost. Neither escalated item hides a defect.

Sonnet's escalation items

  • Throw propagation through frame init. Sonnet asked how a thrown allocation failure propagates. On closer read it is safe. World::gameLoop's catch (...) (engine/world/src/world.cpp:445) runs end() and rethrows, so a failure inside a frame still ends the process, with a named message where Release used to dereference null. Every constructor that throws releases its MTL::TextureDescriptor first (metal_texture.cpp, metal_render_impl.cpp offscreen target). getRenderPipelineState releases its descriptor before the null check. The test helper releases its vertex descriptor on both paths. No new noexcept boundary sits on these paths.
  • string_view lifetime. I confirm Sonnet's read. firstCommandBufferError_ points at MetalRuntimeState::firstCommandBufferErrorText_, which is written only while the view is empty. shutdownMetalRuntime (g_runtime() = MetalRuntimeState{}) resets the view and its backing string together, so they never come apart. World copies the view into m_deviceErrorsAtLastFrame and the per-frame deltas but never reads it there; only buildAndWriteProfileReport reads it, from a fresh deviceStats(), and copies it into an owning std::string.

Opus-only checks

  • Counter coverage. Every Metal commit site counts: there are exactly two (present() and finish(), metal_render_impl.cpp:462/1133), and both call recordCompletedFrameBuffer after waitUntilCompleted(). That also covers command buffers that a mid-frame finish() commits. Both calls run on the render thread, so there is no completion-handler race.
  • Hot path. newMetalBuffer sits on replaceBacking, which can run once per frame. It adds one bool read and a string_view argument next to a newBuffer call, so the cost is negligible. recordDeviceCounters still calls deviceStats() once per frame. m_frameDeviceErrors follows the existing m_frameBufferWrites reserve-then-grow pattern with the same warm-up divisor.
  • Report and parser. The new rows use the existing DEVICE_COUNTER_RE shape. device_counter_lines lists only names that every run reports, so mixing an old run with a new one cannot raise a KeyError. The First command-buffer error: line falls through the parser as an unmatched line.

Nits (follow-up)

  • engine/render/src/metal/metal_buffer.cpp resize(): m_size is assigned before newMetalBuffer runs. If the allocation throws and a caller catches it, the object keeps the old, smaller backing but reports the new size, and a later subData of up to m_size bytes writes past it. Today the only broad std::exception catches are Lua script loading (lua_script.cpp:569, prefab_api.cpp), so this needs an out-of-memory failure inside a script-driven resize. Before this PR the same failure crashed outright. Allocating into a local and assigning m_size after success gives the strong guarantee at no cost.
  • beginFrame's new layer == nullptr branch can only run for the headless bootstrap device. The comment above bootstrapHeadlessRenderDevice still says a headless test never calls beginFrame. Either the branch has a caller this PR adds (I found none in test/), or it is defensive code the comment should mention.
  • recordMetalCommandBufferCompletion only records a "first" error while the stored text is empty. An error whose localizedDescription is non-null but empty therefore leaves the slot open, and a later error overwrites the reported first frame. Testing a separate hasFirstError flag, or the frame number, would remove that edge.
  • I confirm Sonnet's three nits: the test seams sit in the public metal_runtime.hpp, the == 23 first-error assertion depends on test order, and the missing-function throw leaks the earlier MTL::Functions.

Checked

  • Read the full diff, plus the surrounding beginFrame / present / finish / bootstrapHeadlessRenderDevice code, MetalRuntimeState and shutdownMetalRuntime, World::recordDeviceCounters / buildAndWriteProfileReport, the catch sites across engine/, and the repeat_profile.py / compare_perf_runs.py counter parsing.
  • CI: render-harness-tests (and therefore all-checks) is still red on this head. I accept Sonnet's attribution, verified on both trees, to the inherited verify_common.py contract failure that #5109 fixed on master after this branch's merge base. Every other check is green.
  • Not run by me: the Metal gtest suite, render-verify and light-verify (macOS host). I am relying on the author's recorded job IDs and the same-session master control for criterion 7.

🤖 Reviewed by Claude Opus 5.5 (opus-reviewer, review-pr skill)

@jakildev jakildev added fleet:approved Fleet reviewer approved — ready for human merge fleet:needs-windows-smoke PR needs windows-debug build + smoke-run validation and removed fleet:needs-opus-recheck Sonnet flagged this PR for Opus recheck before merge fleet:reviewing-mac-pool-2 labels Nov 17, 2026
@evin-mac-claude-app evin-mac-claude-app Bot added the fleet:checks-red Info only: approved PR whose head has a failed check of its own; reconcile R12 adds and removes it label Nov 17, 2026
@jakildev
jakildev merged commit 40cb998 into master Nov 18, 2026
19 of 21 checks passed
@jakildev jakildev added fleet:verified-windows Cross-host smoke passed on windows-debug and removed fleet:needs-windows-smoke PR needs windows-debug build + smoke-run validation labels Nov 18, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Cross-host smoke OK on windows (fresh checkout + IRShapeDebug --auto-screenshot 10 — build clean, ir-run RESULT=CLEAN exit 0, no shader/compile warnings; one pre-existing runtime profiler-registry warning 'tagGpuStage: unknown stage guiToScreen' from a file this PR does not touch).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fleet:approved Fleet reviewer approved — ready for human merge fleet:author-codex Implementation last authored by Codex; route review to Claude fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend fleet:checks-red Info only: approved PR whose head has a failed check of its own; reconcile R12 adds and removes it fleet:verified-windows Cross-host smoke passed on windows-debug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant