From 62fe227b6b028c3fd65379226686d0118ad79965 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Sun, 14 Jun 2026 19:25:23 +0900 Subject: [PATCH] taut: crash when viewing metainst on tab 2+ --- assets/disk0/tvdos/bin/taut.js | 11 ++++++++--- terranmon.txt | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/assets/disk0/tvdos/bin/taut.js b/assets/disk0/tvdos/bin/taut.js index 702f20d..2a9bf7f 100644 --- a/assets/disk0/tvdos/bin/taut.js +++ b/assets/disk0/tvdos/bin/taut.js @@ -5349,8 +5349,12 @@ function resolveHairlineHits(hits) { } // Pull the envelope object + JSR223 getter pair for the active inst sub-tab. Returns null -// for tabs without a graph (Gen.1 / Gen.2). +// for tabs without a graph (Gen.1 / Gen.2) AND for Metainstruments, whose decoded record has +// no vol/pan/pf envelopes (it carries a layer table instead) — drawInstTabMeta renders every +// sub-tab for them, so without this guard the VOL/PAN/PIT branches return { env: undefined } +// and the cursor walker dereferences env.terminatorIdx on undefined. function envBundleForCurrentTab(e) { + if (e.decoded.isMeta) return null if (instSubTab === INST_TAB_VOL) return { env: e.decoded.volEnv, idxFn: 'getVoiceEnvVolIndex', timeFn: 'getVoiceEnvVolTime' } if (instSubTab === INST_TAB_PAN) return { env: e.decoded.panEnv, @@ -5429,8 +5433,9 @@ function drawEnvelopeCursor() { const e = instrumentsCache[instListCursor] if (!e) { eraseEnvCursorIfAny(); return } const bundle = envBundleForCurrentTab(e) - // Gen.1 / Gen.2 have no envelope graph — wipe any stale hairline and bail. - if (!bundle) { eraseEnvCursorIfAny(); return } + // Gen.1 / Gen.2 (and Metainstruments) have no envelope graph — wipe any stale hairline and + // bail. The !bundle.env check also covers a malformed record whose env slot is missing. + if (!bundle || !bundle.env) { eraseEnvCursorIfAny(); return } const env = bundle.env const lastIdx = (env.terminatorIdx >= 0) ? env.terminatorIdx : (env.nodes.length - 1) if (lastIdx < 0) { eraseEnvCursorIfAny(); return } diff --git a/terranmon.txt b/terranmon.txt index 22a8e07..d309f59 100644 --- a/terranmon.txt +++ b/terranmon.txt @@ -2833,7 +2833,7 @@ TODO: - Samples playblobs: only active for actually playing samples - Samples playcursor: true cursors for actually playing samples [ ] implement note-fade (0x0003) and wire it to it2taud - [ ] taut.js quit with TypeError: Cannot read property 'terminatorIdx' of undefined: + [x] taut.js quit with TypeError: Cannot read property 'terminatorIdx' of undefined: TypeError: Cannot read property 'terminatorIdx' of undefined at drawEnvelopeCursor (:5312:22) at drawInstrumentsContents (:4919:41)