Add [BP-DIAG] back-pressure instrumentation for Phase 21.4 browser run

Temporary, grep-tagged diagnostics at the read-loop pause, the scheduler
latch, and the chunk-result path to show whether ProductionPaused latches,
reaches C#, and parks the loop. Strip once the cause is confirmed.
This commit is contained in:
daniel-c-harvey
2026-06-24 09:00:38 -04:00
parent c7629c15a4
commit 369cb86437
3 changed files with 99 additions and 2 deletions
+28 -2
View File
@@ -269,13 +269,19 @@ export class AudioPlayer {
const headerParsed = decoder.ready;
const canStart = headerParsed && this.scheduler.hasMinimumBuffers(this.minBuffersForPlayback);
// [BP-DIAG] Phase 21.4 — value of productionPaused actually placed on the Opus chunk
// result handed to C#. Confirms the flag is populated on THIS path (not just the WAV
// path). TEMPORARY — strip once confirmed.
const opusPaused = this.scheduler.evaluateProductionPause();
this.bpDiagLogChunkResult('opus', canStart, opusPaused);
return {
success: true,
canStartStreaming: canStart,
headerParsed,
bufferCount: this.scheduler.getBufferCount(),
duration: this.duration,
productionPaused: this.scheduler.evaluateProductionPause()
productionPaused: opusPaused
};
} catch (error) {
return { success: false, error: (error as Error).message };
@@ -314,13 +320,18 @@ export class AudioPlayer {
const canStart = this.streamDecoder.headerParsed &&
this.scheduler.hasMinimumBuffers(this.minBuffersForPlayback);
// [BP-DIAG] Phase 21.4 — value of productionPaused actually placed on the WAV/MP3/FLAC
// chunk result handed to C#. TEMPORARY — strip once confirmed.
const formatPaused = this.scheduler.evaluateProductionPause();
this.bpDiagLogChunkResult('format', canStart, formatPaused);
return {
success: true,
canStartStreaming: canStart,
headerParsed: this.streamDecoder.headerParsed,
bufferCount: this.scheduler.getBufferCount(),
duration: this.duration,
productionPaused: this.scheduler.evaluateProductionPause()
productionPaused: formatPaused
};
} catch (error) {
return { success: false, error: (error as Error).message };
@@ -731,6 +742,21 @@ export class AudioPlayer {
// ==================== Private Methods ====================
// ─────────────────────────────────────────────────────────────────────────────────────────
// [BP-DIAG] Phase 21.4 back-pressure diagnostic. TEMPORARY — strip once confirmed in Daniel's
// browser run. Logs the productionPaused flag on the chunk result handed back to C#, throttled
// to ~4 Hz so it does not flood. Grep "[BP-DIAG] chunk-result" in the browser console.
private bpDiagChunkResultLastMs = 0;
private bpDiagLogChunkResult(path: 'opus' | 'format', canStart: boolean, paused: boolean): void {
const now = (typeof performance !== 'undefined' ? performance.now() : Date.now());
if (now - this.bpDiagChunkResultLastMs < 250) return;
this.bpDiagChunkResultLastMs = now;
console.log(
`[BP-DIAG] chunk-result path=${path} productionPaused=${paused} canStart=${canStart} ` +
`bufCount=${this.scheduler.getBufferCount()} streamingStarted=${this.streamingStarted} isPlaying=${this.isPlaying}`);
}
// ─────────────────────────────────────────────────────────────────────────────────────────
private resetState(): void {
this.isPlaying = false;
this.isPaused = false;