Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: name the macOS Metal command-buffer watchdog behind SIGABRT render aborts (#3101)

[._.]/ Adam Eivy57be24383cb6
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 25c83152b0..a40b178570 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -75,6 +75,7 @@
## Video generation
- **[issue-3100] New Control mode for local video generation** — feed a control clip (a depth pass, a pose track, edges) alongside your prompt and the render follows its structure and motion instead of inventing them. The reference can be a fresh upload or any prior render from your history, and a strength slider dials how tightly the output tracks it. A half-res preview toggle skips the refinement pass so you can check whether a control clip fits before committing to a full render. Requires an LTX-2 model; the ~654 MB Control weight downloads with progress from the mode panel and is covered by the existing model verify/repair buttons.
+- **[issue-3101] A local render that dies on a signal now says what actually killed it.** The most common way an Apple Silicon render aborts is the macOS Metal command-buffer watchdog killing an over-long GPU command buffer, and it used to surface as a bare `Killed by signal SIGABRT` — no cause, no next step, and easy to mistake for a bug in the model or in PortOS. That failure now names the watchdog and tells you to lower the resolution and/or frame count and keep the display asleep; `SIGBUS`/`SIGSEGV` are reported as a native crash in the MLX/Metal layer with a runtime-reinstall pointer, and out-of-memory `SIGKILL` reads as before. Every signal failure also quotes the runtime fingerprint it died on (runtime, mlx/mlx-metal versions, chip, macOS build), so the report stands on its own. A signal PortOS doesn't have a diagnosis for is still reported verbatim rather than mis-attributed.
## Layered Intelligence
diff --git a/server/services/videoGen/generateVideoHelpers.js b/server/services/videoGen/generateVideoHelpers.js
index cf2bda81af..737a7fcae4 100644
--- a/server/services/videoGen/generateVideoHelpers.js
+++ b/server/services/videoGen/generateVideoHelpers.js
@@ -112,10 +112,7 @@ export function makeVideoGenLineHandler({ job, jobId, pythonNoiseRe }) {
try {
const fp = JSON.parse(line.slice('RUNTIME:'.length));
job.runtime = fp;
- const vers = fp.versions && typeof fp.versions === 'object'
- ? Object.entries(fp.versions).map(([k, v]) => `${k} ${v}`).join(', ')
- : '';
- console.log(`🏷️ runtime [${jobId.slice(0, 8)}] ${fp.runtime || '?'}${vers ? ` | ${vers}` : ''}${fp.chip ? ` | ${fp.chip}` : ''}${fp.os ? ` | ${fp.os}` : ''}`);
+ console.log(`🏷️ runtime [${jobId.slice(0, 8)}] ${formatRuntimeFingerprint(fp) || '?'}`);
return true;
} catch {
// Malformed fingerprint line — fall through to raw-logging so the
@@ -221,6 +218,68 @@ export function makeVideoGenLineHandler({ job, jobId, pythonNoiseRe }) {
};
}
+/**
+ * Render a runtime fingerprint (either the `RUNTIME:` payload a helper script
+ * emits — `{ runtime, versions, chip, os, python }` — or the Node-side
+ * `hostRuntimeFingerprint()` block) as one human-readable line:
+ * `ltx2 | mlx 0.22.0, torch 2.5.1 | Apple M4 Max | macOS-15.4-arm64`.
+ * Shared by the startup log line and by signal-death failure messages so a
+ * crash report self-documents the exact stack it crashed on. Pure; tolerates a
+ * missing/partial payload (returns '' when nothing is known).
+ * @param {object|null|undefined} fp
+ * @returns {string}
+ */
+export function formatRuntimeFingerprint(fp) {
+ if (!fp || typeof fp !== 'object') return '';
+ const versions = fp.versions && typeof fp.versions === 'object' ? fp.versions : {};
+ const vers = Object.entries(versions).map(([k, v]) => `${k} ${v}`).join(', ');
+ return [fp.runtime, vers, fp.chip, fp.os].filter(Boolean).join(' | ');
+}
+
+// Signal → actionable cause for a render child that died on a signal.
+//
+// Apple Silicon reality drives this map. The dominant real-world render abort is
+// the macOS Metal command-buffer watchdog killing an over-long GPU command
+// buffer (`kIOGPUCommandBufferCallbackErrorImpactingInteractivity`), which the
+// MLX/Metal layer surfaces as SIGABRT (exit -6) — NOT as a Python-level
+// assertion. Reporting that as a bare `Killed by signal SIGABRT` (or as a
+// "C-level assertion failed" hint, the mistake upstream made) sends users
+// hunting a model/PortOS bug when the fix is to shrink the work per command
+// buffer. SIGBUS/SIGSEGV are the other native-crash arrivals from the same
+// layer. SIGKILL stays the OOM message it has always been.
+//
+// Keys are the signal NAMES Node reports on `close` (spawnDetached decodes the
+// supervisor's 128+signum status back into the same names).
+const nativeCrashCause = (signal) => `Render crashed (${signal}) — a native fault inside the MLX/Metal layer, not a PortOS-level error. Retry with a lower resolution/frame count; if it repeats on the same model, reinstall that runtime from Settings → Video (a mismatched mlx / mlx-metal pair in the venv is the usual cause).`;
+
+const SIGNAL_DEATH_CAUSES = Object.freeze({
+ SIGKILL: 'Process killed (likely out of memory — try a smaller model or resolution)',
+ SIGABRT: 'Render aborted (SIGABRT) — on Apple Silicon this is almost always the macOS Metal command-buffer watchdog killing an over-long GPU command buffer (kIOGPUCommandBufferCallbackErrorImpactingInteractivity), not a bug in the model or PortOS. Lower the resolution and/or frame count so each command buffer does less work, and keep the display asleep (or drive the machine headless) so the render is not competing with WindowServer compositing.',
+ SIGBUS: nativeCrashCause('SIGBUS'),
+ SIGSEGV: nativeCrashCause('SIGSEGV'),
+});
+
+/**
+ * Failure reason for a render child that exited on a signal. Pure.
+ *
+ * Unmapped signals keep the historical `Killed by signal <SIG>` wording so a
+ * novel signal is still reported verbatim rather than mis-attributed. The
+ * resolved runtime fingerprint is appended when known, so the report names the
+ * mlx / mlx-metal / chip / macOS stack that died without the user having to go
+ * look it up (matching what RuntimeFingerprint.jsx surfaces on the page).
+ *
+ * @param {string|null} signal - signal name from `proc.on('close', (code, signal))`
+ * @param {object} [opts]
+ * @param {object|null} [opts.fingerprint] - runtime fingerprint (see `pickDeathFingerprint` in runtimes.js)
+ * @returns {string|null} reason, or null when the child did not die on a signal
+ */
+export function describeSignalDeath(signal, { fingerprint = null } = {}) {
+ if (!signal) return null;
+ const cause = SIGNAL_DEATH_CAUSES[signal] || `Killed by signal ${signal}`;
+ const fp = formatRuntimeFingerprint(fingerprint);
+ return fp ? `${cause} [runtime: ${fp}]` : cause;
+}
+
/**
* Whether a PortOS-fired SIGKILL should be treated as success rather than a
* failure. Two Node-side watchdogs can SIGKILL a render:
diff --git a/server/services/videoGen/generateVideoHelpers.test.js b/server/services/videoGen/generateVideoHelpers.test.js
index c2de7f082b..0b90db2447 100644
--- a/server/services/videoGen/generateVideoHelpers.test.js
+++ b/server/services/videoGen/generateVideoHelpers.test.js
@@ -2,7 +2,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
import { writeFileSync, rmSync } from 'fs';
import { tmpdir } from 'os';
import { join } from 'path';
-import { makeVideoGenLineHandler, isWatchdogSuccess, finalizeGeneratedVideo, parseByteProgress, formatBytes, formatDownloadMessage } from './generateVideoHelpers.js';
+import { makeVideoGenLineHandler, isWatchdogSuccess, finalizeGeneratedVideo, parseByteProgress, formatBytes, formatDownloadMessage, describeSignalDeath, formatRuntimeFingerprint } from './generateVideoHelpers.js';
describe('parseByteProgress', () => {
it('parses single byte value (e.g., "2.5G")', () => {
@@ -246,6 +246,79 @@ describe('finalizeGeneratedVideo runtime persistence', () => {
});
});
+describe('formatRuntimeFingerprint', () => {
+ it('renders runtime | versions | chip | os', () => {
+ expect(formatRuntimeFingerprint({
+ runtime: 'ltx2',
+ versions: { mlx: '0.22.0', mlx_metal: '0.22.0' },
+ chip: 'Apple M4 Max',
+ os: 'macOS-15.4-arm64',
+ })).toBe('ltx2 | mlx 0.22.0, mlx_metal 0.22.0 | Apple M4 Max | macOS-15.4-arm64');
+ });
+
+ it('omits missing segments rather than leaving empty separators', () => {
+ expect(formatRuntimeFingerprint({ chip: 'Apple M4 Max', os: 'macOS-15.4-arm64' }))
+ .toBe('Apple M4 Max | macOS-15.4-arm64');
+ });
+
+ it('returns empty string for a missing/non-object payload', () => {
+ expect(formatRuntimeFingerprint(null)).toBe('');
+ expect(formatRuntimeFingerprint(undefined)).toBe('');
+ expect(formatRuntimeFingerprint('ltx2')).toBe('');
+ expect(formatRuntimeFingerprint({})).toBe('');
+ });
+});
+
+describe('describeSignalDeath (#3101 signal → actionable cause)', () => {
+ it('returns null when the child did not die on a signal', () => {
+ expect(describeSignalDeath(null)).toBeNull();
+ expect(describeSignalDeath(undefined)).toBeNull();
+ expect(describeSignalDeath('')).toBeNull();
+ });
+
+ it('names the macOS Metal command-buffer watchdog for SIGABRT and points at resolution/frame count', () => {
+ const reason = describeSignalDeath('SIGABRT');
+ expect(reason).toMatch(/SIGABRT/);
+ expect(reason).toMatch(/Metal command-buffer watchdog/i);
+ expect(reason).toMatch(/kIOGPUCommandBufferCallbackErrorImpactingInteractivity/);
+ expect(reason).toMatch(/resolution/i);
+ expect(reason).toMatch(/frame count/i);
+ // Must NOT send the user hunting a model/PortOS bug (the upstream mistake).
+ expect(reason).toMatch(/not a bug in the model or PortOS/i);
+ expect(reason).not.toMatch(/assertion/i);
+ });
+
+ it('names a native MLX/Metal crash for SIGBUS and SIGSEGV', () => {
+ for (const sig of ['SIGBUS', 'SIGSEGV']) {
+ const reason = describeSignalDeath(sig);
+ expect(reason).toMatch(new RegExp(sig));
+ expect(reason).toMatch(/MLX\/Metal/);
+ expect(reason).toMatch(/native fault/i);
+ }
+ });
+
+ it('keeps the existing OOM wording for SIGKILL', () => {
+ expect(describeSignalDeath('SIGKILL')).toBe('Process killed (likely out of memory — try a smaller model or resolution)');
+ });
+
+ it('falls back to the verbatim signal name for an unmapped signal', () => {
+ expect(describeSignalDeath('SIGTERM')).toBe('Killed by signal SIGTERM');
+ expect(describeSignalDeath('SIGPIPE')).toBe('Killed by signal SIGPIPE');
+ });
+
+ it('appends the runtime fingerprint when one is known', () => {
+ const reason = describeSignalDeath('SIGABRT', {
+ fingerprint: { runtime: 'ltx2', versions: { mlx: '0.22.0', mlx_metal: '0.22.0' }, chip: 'Apple M4 Max', os: 'macOS-15.4-arm64' },
+ });
+ expect(reason).toMatch(/\[runtime: ltx2 \| mlx 0\.22\.0, mlx_metal 0\.22\.0 \| Apple M4 Max \| macOS-15\.4-arm64\]$/);
+ });
+
+ it('omits the fingerprint suffix entirely when nothing is known (no empty brackets)', () => {
+ expect(describeSignalDeath('SIGSEGV', { fingerprint: null })).not.toMatch(/runtime:/);
+ expect(describeSignalDeath('SIGSEGV', { fingerprint: {} })).not.toMatch(/runtime:/);
+ });
+});
+
describe('isWatchdogSuccess', () => {
// The non-fs short-circuits are pure; the on-disk branch is gated on a real
// existsSync + non-empty statSync, exercised against actual temp files.
diff --git a/server/services/videoGen/local.js b/server/services/videoGen/local.js
index 2be55bc49c..a1684ed16f 100644
--- a/server/services/videoGen/local.js
+++ b/server/services/videoGen/local.js
@@ -28,7 +28,7 @@ import { getVideoModels, getDefaultVideoModelId, getTextEncoderRepo } from '../.
import { findFfmpeg, safeUnder, generateThumbnail, optimizeForStreaming, upscaleVideo2x, extractEvaluationFrames } from '../../lib/ffmpeg.js';
import { hfChildEnv } from '../../lib/hfToken.js';
import { safeChildProcessEnv } from '../../lib/processEnv.js';
-import { makeVideoGenLineHandler, finalizeGeneratedVideo, isWatchdogSuccess } from './generateVideoHelpers.js';
+import { makeVideoGenLineHandler, finalizeGeneratedVideo, isWatchdogSuccess, describeSignalDeath } from './generateVideoHelpers.js';
import { assertSafeLoraFilename } from '../loras.js';
import { isMlxVideoLtxLoraCapable } from '../../lib/runners.js';
import {
@@ -48,6 +48,7 @@ import {
BYOV_VIDEO_RUNTIMES,
assertByovRuntimeInstalled,
invalidateByovReadyCache,
+ pickDeathFingerprint,
} from './runtimes.js';
import { loadHistory, saveHistory, mutateVideoHistory } from './history.js';
// Re-export the extracted runtime + history surface so existing deep imports
@@ -1236,10 +1237,14 @@ export async function generateVideo({ pythonPath, prompt, negativePrompt = '', m
// SIGKILL, but this one means the render produced NO output for the
// whole idle window and we terminated it to free the GPU lane.
reason = `Render stalled — no output for ${Math.round(IDLE_STALL_DEADLINE_MS / 1000)}s; terminated to free the GPU queue (raise VIDEOGEN_IDLE_STALL_MS if this was a legitimately slow render)`;
- } else if (signal === 'SIGKILL') {
- reason = 'Process killed (likely out of memory — try a smaller model or resolution)';
} else if (signal) {
- reason = `Killed by signal ${signal}`;
+ // Signal → actionable cause (SIGABRT = the macOS Metal command-buffer
+ // watchdog, SIGBUS/SIGSEGV = a native MLX/Metal crash, SIGKILL = OOM),
+ // stamped with the runtime fingerprint that died so the report is
+ // self-documenting. See describeSignalDeath in generateVideoHelpers.js.
+ reason = describeSignalDeath(signal, {
+ fingerprint: await pickDeathFingerprint({ emitted: job.runtime, runtimeId: model.runtime }),
+ });
} else {
reason = `Exit code ${code}`;
}
diff --git a/server/services/videoGen/local.test.js b/server/services/videoGen/local.test.js
index 57c20c9585..b5d4d06b10 100644
--- a/server/services/videoGen/local.test.js
+++ b/server/services/videoGen/local.test.js
@@ -1633,6 +1633,111 @@ describe('generateVideo — chunk-boundary marker parsing (#2463)', () => {
});
});
+describe('generateVideo — signal-death diagnosis (#3101)', () => {
+ // The dominant real-world Apple-Silicon render abort is the macOS Metal
+ // command-buffer watchdog, which arrives as SIGABRT. Before #3101 every signal
+ // except SIGKILL fell through to a bare `Killed by signal SIGABRT` with no
+ // cause and no next step. These assert the close handler's signal→message map
+ // AND that the precedence above it (missingPyModule → idleStallFired → signal)
+ // is preserved.
+ function makeSignalProc() {
+ const listeners = {};
+ let stdoutData = null;
+ let stderrData = null;
+ const proc = {
+ pid: 3101,
+ exitCode: null,
+ signalCode: null,
+ killed: false,
+ stdout: { on: vi.fn((event, fn) => { if (event === 'data') stdoutData = fn; }) },
+ stderr: { on: vi.fn((event, fn) => { if (event === 'data') stderrData = fn; }) },
+ on(event, fn) { listeners[event] = fn; return proc; },
+ kill: vi.fn((signal) => { proc.killed = true; proc.signalCode = signal; }),
+ };
+ return {
+ proc,
+ emitStdout: (text) => stdoutData?.(Buffer.from(text)),
+ emitStderr: (text) => stderrData?.(Buffer.from(text)),
+ fireClose: (code, signal) => listeners.close?.(code, signal),
+ };
+ }
+
+ // Start a render, kill it with `signal`, and return the terminal 'failed' event.
+ async function failWithSignal(jobId, signal, { onStarted } = {}) {
+ vi.resetModules();
+ const { generateVideo: gv } = await import('./local.js');
+ const { videoGenEvents: events } = await import('./events.js');
+ const { spawnDetached } = await import('../../lib/detachedSpawn.js');
+
+ // No output on disk, so isWatchdogSuccess can never treat the kill as success.
+ const { existsSync, statSync } = await import('fs');
+ vi.mocked(existsSync).mockReturnValue(true);
+ vi.mocked(statSync).mockReturnValue({ size: 0 });
+
+ const ctrl = makeSignalProc();
+ vi.mocked(spawnDetached).mockImplementationOnce(async () => ctrl.proc);
+
+ const failed = new Promise((resolve) => events.once('failed', resolve));
+ await gv({
+ jobId,
+ pythonPath: '/usr/bin/python3',
+ modelId: 'ltx2_unified',
+ prompt: 'crash on a signal',
+ width: 512, height: 512, numFrames: 25, fps: 24,
+ mode: 'text',
+ });
+ onStarted?.(ctrl);
+ ctrl.fireClose(null, signal);
+ return failed;
+ }
+
+ it('SIGABRT names the macOS Metal command-buffer watchdog with a resolution/frame-count next step', async () => {
+ const evt = await failWithSignal('signal-sigabrt', 'SIGABRT');
+ expect(evt.error).toMatch(/Metal command-buffer watchdog/i);
+ expect(evt.error).toMatch(/kIOGPUCommandBufferCallbackErrorImpactingInteractivity/);
+ expect(evt.error).toMatch(/resolution/i);
+ expect(evt.error).toMatch(/frame count/i);
+ // The old bare wording must be gone.
+ expect(evt.error).not.toMatch(/Killed by signal SIGABRT/);
+ });
+
+ it('SIGBUS and SIGSEGV name a native MLX/Metal crash', async () => {
+ for (const [i, sig] of ['SIGBUS', 'SIGSEGV'].entries()) {
+ // eslint-disable-next-line no-await-in-loop
+ const evt = await failWithSignal(`signal-native-${i}`, sig);
+ expect(evt.error).toMatch(new RegExp(sig));
+ expect(evt.error).toMatch(/MLX\/Metal/);
+ expect(evt.error).not.toMatch(new RegExp(`Killed by signal ${sig}`));
+ }
+ });
+
+ it('SIGKILL keeps the out-of-memory wording', async () => {
+ const evt = await failWithSignal('signal-sigkill', 'SIGKILL');
+ expect(evt.error).toMatch(/out of memory/i);
+ });
+
+ it('an unmapped signal still reports verbatim (never mis-attributed)', async () => {
+ const evt = await failWithSignal('signal-unmapped', 'SIGTERM');
+ expect(evt.error).toMatch(/Killed by signal SIGTERM/);
+ });
+
+ it('stamps the runtime fingerprint the child emitted into the signal-death message', async () => {
+ const fp = { runtime: 'ltx2', versions: { mlx: '0.22.0', mlx_metal: '0.22.0' }, chip: 'Apple M4 Max', os: 'macOS-15.4-arm64' };
+ const evt = await failWithSignal('signal-fingerprint', 'SIGABRT', {
+ onStarted: (ctrl) => ctrl.emitStderr(`RUNTIME:${JSON.stringify(fp)}\n`),
+ });
+ expect(evt.error).toMatch(/\[runtime: ltx2 \| mlx 0\.22\.0, mlx_metal 0\.22\.0 \| Apple M4 Max \| macOS-15\.4-arm64\]/);
+ });
+
+ it('a missing python module still wins over the signal map (precedence preserved)', async () => {
+ const evt = await failWithSignal('signal-module-precedence', 'SIGABRT', {
+ onStarted: (ctrl) => ctrl.emitStderr("ModuleNotFoundError: No module named 'ltx_pipelines_mlx'\n"),
+ });
+ expect(evt.error).toMatch(/ltx_pipelines_mlx/);
+ expect(evt.error).not.toMatch(/Metal command-buffer watchdog/i);
+ });
+});
+
describe('generateVideo — IC-LoRA remix arg threading (#3100)', () => {
// 704×448 is divisible by the Control weight's referenceDownscaleFactor of 2,
// so these renders clear the resolution gate. Frames stay small so the FFLF
diff --git a/server/services/videoGen/runtimes.js b/server/services/videoGen/runtimes.js
index 37bbb490ce..34e4f26c5d 100644
--- a/server/services/videoGen/runtimes.js
+++ b/server/services/videoGen/runtimes.js
@@ -253,3 +253,27 @@ export async function resolveRuntimeFingerprint() {
}
return { host: hostRuntimeFingerprint(), runtimes };
}
+
+/**
+ * Single runtime fingerprint to quote in a crash/failure report. Prefers the
+ * fingerprint the dead child itself emitted (`RUNTIME:` line → `job.runtime`) —
+ * that's the exact venv that just crashed. Falls back to the /status probe's
+ * already-resolved entry for this render's runtime, then to host-only info, so
+ * even the bare `mlx_video.generate_av` path (which emits no `RUNTIME:` line)
+ * still names the chip + OS build.
+ *
+ * Non-blocking and non-throwing by construction: resolveRuntimeFingerprint()
+ * returns only cached runtime entries (warming the rest in the background), so a
+ * cold or wedged venv can never stall a failure message.
+ *
+ * @param {object} [ctx]
+ * @param {object|null} [ctx.emitted] - fingerprint the child emitted (job.runtime)
+ * @param {string|null} [ctx.runtimeId] - BYOV runtime id of the model being rendered
+ * @returns {Promise<object|null>}
+ */
+export async function pickDeathFingerprint({ emitted = null, runtimeId = null } = {}) {
+ if (emitted && typeof emitted === 'object') return emitted;
+ const block = await resolveRuntimeFingerprint().catch(() => null);
+ if (!block) return null;
+ return (runtimeId && block.runtimes?.[runtimeId]) || block.host || null;
+}