Files
SonicForgeStudio/TEST_NOTES.md
T
admin d8f8506077 fix: GUI VST native window qua bridge + audio path bridge (SF2 preview/play câm)
- open_vst_gui: bo WebviewWindowBuilder/thread, chi push_control type=4 (hwnd=0 -> bridge tao window)
- main.cpp: create_native_vst_window (class SonicForge_Native_VST3_Class, 800x600, khong TOPMOST),
  tao trong ChannelWorker job, map guiWindows, capture arg2 by value (fix dangling)
- app.jsx: guard isBridgeActive() 8 cho -> bridge active thi moi note di router -> pushEvent -> bridge
  (truoc day SF2 cam vi HAS_PYFLUIDSYNTH=FALSE -> /soundfont-render 501; VST3 path cu dung nativeSf/Carla)
- E2E: SF2 NOTE_ON qua dispatchMidiEvent -> SHM peak 0.029745; Nexus GUI native hwnd OK (license/preset)
- docs: TASKS.md + TEST_NOTES.md ghi batch fix + ket qua; gitignore vendor/junk
2026-08-12 22:12:43 +07:00

25 KiB

TEST NOTES — NATIVE BRIDGE (test trên máy native/Windows)

Máy phát triển hiện tại (Linux, không rustc/CMake-MSVC, Python SIGILL khi import app.core.vst_engine) KHÔNG chạy được pipeline. Danh sách này là "bộ nhớ" — chạy từng mục trên máy Windows (hoặc OS native có đủ toolchain), đánh dấu khi pass.

A. C++ bridge (native_bridge/)

  • A5+A13: TRANSPORT type=3 (STOP flush / PLAY / SET_POSITION) + log mỗi load — code OK, chưa test thật (cần tauri run / G4)
  • A10: InstrumentEngineManager multi-channel — build + chạy thật Windows OK (G2 load SF2 ch0 + SFZ ch1 đồng thời, mix vào master)
  • A11: sample-accurate segment render theo sampleOffset — code OK; JS hiện gửi sampleOffset=0 (best-effort)
  • A12: CC/program/pitch bend (MidiEventIPC data2+data3) — code OK
  • A6: Vst3Instrument host thật qua vst3sdk — load mda DX10 (.vst3) → noteon → PCM peak 0.16096 (G2 3 PASS, 2026-08-12)
  • A7: Vst3Instrument tách class + openGUI(hwnd) — FIX GUI HANG 2026-08-12: attached() treo do openGUI chạy thread khác với load thread (load thread exit → COM STA apartment chết). Probe gui_probe (bridge_like treo / same_thread OK) → fix ChannelWorker (1 thread persistent/channel, load+openGUI cùng thread, pump khi idle) + message pump đầu audio loop. E2E: Nexus attached=0 → GUI attached, child editor windows visible; Scaler2 GUI attach vẫn FAILED khi window vst-<id> đã tồn tại (open_vst_gui build fail → không push control — test-script issue, không phải host bug); Scaler2 note peak 0.0062 = VST audio routing OK
  • Windows verify sfizz API names: sfizz 1.2.3 (sfizz-src) dùng hdNoteOn/hdNoteOff/cc/pitchWheel/programChange (tham số delay đầu), setSampleRate(float), setSamplesPerBlock(int), renderBlock(float**, size_t, int numOutputs) — đã sửa đúng 4 call trong NativeInstrumentEngine.cpp (bỏ no-op); velocity normalize /127 ở main.cpp:99
  • Windows verify: shm_selfcheck.exe chạy OK trên Windows — "SHM self-check OK (sizeof struct = 11160 bytes)"; cargo check + cargo test (layout_matches_c_header 12/1040/11160) PASS

B. Rust / Tauri (src-tauri/)

  • B1-B4: cargo check pass trên Windows (sau khi sửa Cargo.toml features Win32_System_Memory+Win32_Security, dep raw-window-handle=0.6, shm.rs .Value, lib.rs ok_or_else)
  • B2: SHM struct layout khớp C header — unit test layout_matches_c_header trong src-tauri/src/shm.rs PASS (12/1040/11160 bytes)
  • B2: signature commands mới đã sync JS — chưa test thật qua UI (cần tauri run)
  • B5: audio pump thread emit bridge-audio ~5ms — code: pump thread trong lib.rs (~263-330): đọc bridgeWriteIndex → emit bridge-audio; stall 3s → B10 respawn; cần chạy thật Windows
  • B8: spawn bridge kèm SF_SAMPLE_RATE=44100/SF_BLOCK_SIZE=256 + C++ main.cpp đọc env (block cố định 256, SR áp cho init engine) — code OK
  • B9: open_vst_gui tạo child WebviewWindow + HWND qua raw_window_handle → control type=4 arg1 — code OK; close_gui khi window đóng chưa làm (chờ A7)
  • B10: health monitor trong audio pump — stall 3s → respawn 1 lần → bridge-down; đếm restart vào bridge.log — code OK
  • B6: tauri.conf.json externalBin — code + sidecar thật binaries/daw_vst_bridge-x86_64-pc-windows-msvc.exe (1.34MB, build PASS từ native_bridge) đã copy; chưa tauri build verify
  • B7: capabilities — review: window VST tạo từ Rust (WebviewWindowBuilder), commands app-level, event listen nằm trong core:default — không cần permission mới
  • B9 thật trên Windows: child window hiện + HWND hợp lệ (kiểm tra log bridge nhận type=4)

C. Frontend services

  • C1-C7: node --check OK + npm run build (Babel) OK trên Windows — bundle app/static/js/app.precompiled.js 1.2MB mới
  • C5: ring buffer 8 block chống underrun thật trên Windows (âm nghe được, VU nhảy)

D. app.jsx wiring

  • D1: onmidimessage NOTE_ON/OFF → router (code + bundle OK)
  • D2: timeline → scheduleMidiNoteDispatch + transport play/stop (code + bundle OK)
  • D9: bridgePlayheadSampleRef counter + transport('set_position', playhead) ~mỗi giây trong updatePlayhead (JS là nguồn playhead duy nhất; C++ A13 cập nhật anchor) — code + bundle OK
  • D1-D2 thật: bấm keyboard + play piano roll → âm qua bridge, Stop hết âm ngân
  • D4: Carla không route khi bridge active — verified: runtime.js shouldRoute/shouldRoutePlayback return false khi NativeBridgeService.isBridgeConnected (bridge host native SF2/SF3/SFZ/VST3)
  • D5: audio routing vào track FX chain
  • D6: panic/Stop → SonicMidiRouter.panic() (bridge transport panic + fallback SonicSF.stopAll) — 4 call site app.jsx đã đổi
  • D8: track→channel map + gửi CC0/CC32/PROGRAM trước NOTE_ON khi đổi instrument (scheduleMidiNoteDispatch)
  • D7: UI Plugin Manager — badge ● Bridge ON/OFF (query GET /api/v1/bridge/status), nút "Load Bridge" trên mỗi VST + SoundFont → POST /api/v1/bridge/load (E2 resolve path) → NativeBridgeService.loadInstrument(path, type, 0); code + bundle OK — chưa test thật trên Windows
  • D10: header indicator Bridge/WASM + nút "Ép WASM" (toggle SonicMidiRouter.setForceWasm); service thêm onStatusChange(cb) — code + bundle OK

E. Backend Python

  • E1-E3: syntax OK — 38 file ast.parse OK trên Windows
  • E4: desktop_engine.py watchdog — verify: chỉ theo dõi SF_PARENT_PID (Tauri) để tự thoát; không spawn/kill gì khác → không đụng bridge (bridge do Rust spawn). Không cần sửa.
  • E5: GET /api/v1/bridge/log?lines=N tail bridge.log — thêm Query import; ast.parse OK
  • curl /api/v1/bridge/status trả connected đúng — cần chạy trên máy không SIGILL
  • POST /api/v1/bridge/load resolve sf2/vst3 → bridge load → UI nhận bridge-audio
  • SIGILL: hết — import app.core.vst_engine OK trên máy Windows này (máy dev Linux cũ không liên quan)

F. Build Windows

  • F1-F3: 3 script đã copy vào repo build/scripts/ (ASCII-only, PS5.1-safe, CRLF) — build_native_bridge (vcpkg manifest fluidsynth + sfizz source + submodule + cmake), build_windows (7 bước), test_standalone (8 bước)
  • F4: tools/verify_bundle.py --check-bridge — verify TOC + sidecar tồn tại; fail đúng cách trên Linux (chưa có exe) — test exit 1 OK
  • F5: hooks.nsh — vc_redist cài toàn máy (ExecWait /quiet) → đủ runtime cho cả daw_engine.exe + daw_vst_bridge.exe; MSI không chạy hooks → cài thủ công
  • F6: DESKTOP_INSTALL_PLAN.md §5.2 (kiến trúc 2 sidecar) + DEPLOYMENT_REPORT.md bản 1.2
  • F7: .github/workflows/build-windows.yml — windows-latest: MSVC + Rust + node + python → build_windows.ps1 → upload NSIS/MSI
  • Chạy thật trên Windows: build_windows.ps1 trọn pipeline ra NSIS+MSI (đã verify build_native_bridge.ps1 chạy end-to-end OK)

G. Test end-to-end

  • G1: shm_selfcheck pass trên Windows — "SHM self-check OK (sizeof struct = 11160 bytes)"
  • G2: bridge mở SHM → load SF2 + SFZ → MIDI note → audio ≠ 0 (script native_bridge/tests/g2_bridge_smoke.py, peak SF2=0.00109 / SFZ=0.00107) — G2 thật từ Tauri UI còn lại ở G9/G10
  • G3: load SGM-V2.01 (SF2) + SalamanderPiano (SFZ) + Vital (VST3)
  • G4: live MIDI + timeline cùng lúc, latency <10ms
  • G5: Track FX + Master FX tác động âm bridge
  • G6: kill bridge → SonicSF fallback, không crash
  • G7: test_standalone.ps1 5/5
  • G8: đo latency blockTimestamp IPC ≤0.5ms, end-to-end <10ms
  • G9: multi-instance 2 track đồng thời (A10 — 2 SF2/SFZ khác nhau, đổi live)
  • G10: sustain/CC/pitchbend qua bridge (A12 — CC64 sustain + pitch wheel + CC7 volume)

Ghi chú batch 2026-08-12 (chạy thật Windows - E2E + GỠ CARLA)

  • E2 (resolve path soundfont) fix + verify thật: _resolve_bridge_asset scan _load_user_plugin_dirs()
    • os.walk cho SF2/SF3/SFZ; JS loadTrackInstrumentToBridge luôn gọi bridgeLoad({name, path: r.path}). E2E: chèn 024_BigSymphny.sf2 (thư mục Downloads\Collections soundfont) từ Plugin Manager -> bridge.log ghi [NativeBridge] instrument loaded ch=0 type=2 C:\Users\locpham\Downloads\Collections soundfont\024_BigSymphny.sf2 (FULL PATH - không còn FAILED). NOTE_ON -> master peak -0.021314 (âm phát), NOTE_OFF -> 0 (decay).
  • GỠ CARLA (bridge host mọi instrument): xóa khỏi app.jsx - ensureCarlaForPlayback (hàm + 2 call site), nút 🎛 PM scan VST row, dropdown "Carla Bridge (mở Carla.exe)" (synth dropdown), auto-open instrumentSelector + instrumentDropdown, nút "Carla Bridge" riêng. runtime.js shouldRoute/shouldRoutePlayback -> return false vô điều kiện -> Carla KHÔNG mở, KHÔNG route khi bridge connected. GIỮ chủ đích: FX module "Load Carla Bridge" (2 call site openInCarla ở FX Rack
    • Master - VST FX ngoài, user tự cài, không phải luồng instrument).
  • Verify UI: grep app.jsx - PM không còn section Carla (state/functions pmCarlaVersion, locateCarla, saveCarlaInput còn nhưng không còn JSX render), không còn chuỗi "Carla Bridge (mở Carla.exe)", không còn call ensureCarlaForPlayback (chỉ comment). Các hàm chết còn lại (fireCarlaNote, scheduleCarlaNote, refreshCarlaStatus, shouldRouteCarla) vô hại - runtime trả false.
  • tauri build (bản cài sạch): NSIS SonicForgeDAW_1.0.0_x64-setup.exe (363MB) + MSI SonicForgeDAW_1.0.0_x64_en-US.msi (598MB). Verify: extract NSIS bằng 7z -> daw_engine/daw_engine.exe MD5 8ddc7463333a4c334d24dcb1c891546d khớp dist/daw_engine (engine bản mới); daw_vst_bridge.exe + libfluidsynth-3.dll có trong bundle.
  • Quyết định giữ FX "Load Carla Bridge": đây là VST FX ngoài (native GUI, user tự cài) - tính năng riêng của FX Rack, không liên quan luồng load instrument. Nếu muốn xóa luôn, làm sau.

Ghi chú batch 2026-08-11 (A10-A13 + D5)

  • Struct SHM đổi 10872 → 11160: MidiEventIPC +data2/data3(+reserved) = 12B; ControlEventIPC +channel = 1040B. Sync 3 nơi: SharedMemoryIPC.h, shm.rs, shm_selfcheck.cpp — đã khớp (selfcheck pass Linux).
  • Bug pre-existing tìm thấy: shm.rs push_control không ghi pathlen vào arg1 → bridge cũ đọc path rỗng. Sửa: C++ main.cpp load path dùng strnlen(arg2); helper C shm_write_control chỉ set arg1=pathlen khi type==2.
  • transport_control Rust giờ nhận playhead: Option<u32>; JS NativeBridgeService.transport(kind, playhead).
  • loadInstrument(filePath, type, channel); dispatchMidiEvent(cmd,...,data2,data3) hỗ trợ CC/PROGRAM/PITCH_BEND.
  • Khi D8 (track→channel map) chưa xong: JS loadInstrument mặc định channel=0 — multi-instance chưa kích hoạt từ UI.

Ghi chú batch 2026-08-12 (bridge build + G2 trên Windows)

  • Bridge build PASS (native_bridge/build/_bridge.bat, VS2019 x64 + vcpkg + sfizz source):
    1. CMakeLists include_directories dùng ${FLUIDSYNTH_INCLUDE_DIRS} (số nhiều) — find_path chỉ set ${FLUIDSYNTH_INCLUDE_DIR}fluidsynth.h: No such file. Sửa dùng singular.
    2. sfizz 1.2.3 class là sfz::Sfizz (KHÔNG phải sfizz::Synth) → sửa NativeInstrumentEngine.h line 56.
    3. void* synth/settings (giữ fluid types khỏi public header) → macro FS_SYNTH/FS_SETTINGS cast static_cast<fluid_synth_t*> mỗi call.
    4. LNK2038 RuntimeLibrary mismatch: sfizz ép /MT trong sfizz-src/cmake/SfizzConfig.cmake (set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded...")) nhưng vcpkg fluidsynth là /MD → patch bỏ dòng ép + _sfizz.bat thêm -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL.
    5. Bug assign(): gọi init() TRƯỚC loadSoundFontFile() — FluidSynth tạo synth trong lúc load nên init thấy null → SF2 load FAIL. Sửa thứ tự load → init (cả SF2 lẫn SFZ).
  • Runtime: fluidsynth là DLL động — copy libfluidsynth-3.dll cạnh daw_vst_bridge.exe khi chạy standalone/sidecar.
  • G2 test script: native_bridge/tests/g2_bridge_smoke.py — python tạo SHM (mirror Rust shm.rs offsets), spawn bridge với SF_PARENT_PID, push LOAD_INSTRUMENT (type=2 SOUNDFONT / 3 SFZ) + note-on, assert peak > 0.001.

Ghi chú batch 2026-08-12 (scripts build Windows - F)

  • build_native_bridge.ps1 viết lại 7 bước (chạy end-to-end PASS trên máy thật):
    1. vcpkg bootstrap (skip nếu có).
    2. vcpkg install --triplet x64-windows theo manifest native_bridge/vcpkg.json — chỉ fluidsynth + pkgconf (sfizz KHÔNG có port vcpkg).
    3. sfizz 1.2.3: clone tag 1.2.3 + git submodule update --init --recursive; patch idempotent bỏ dòng ép /MT trong SfizzConfig.cmake (regex MultiThreaded$<$<CONFIG:Debug>:Debug>); configure VS16 x64 với đủ flag SFIZZ_SHARED=OFF ... -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL; build target sfizz_static. Skip nếu build/library/lib/Release/sfizz_static.lib đã có.
    4. vst3sdk: git submodule update --init --recursive -- native_bridge/vst3sdk (submodule ĐÃ đăng ký trong repo — không dùng submodule add).
    5. CMake configure thêm -G "Visual Studio 16 2019" -A x64; build --target daw_vst_bridge -- /m (không build ALL_BUILD). 6-7. Copy sidecar daw_vst_bridge-x86_64-pc-windows-msvc.exe + libfluidsynth-3.dll (từ build/vcpkg_installed/x64-windows/bin/) vào src-tauri/binaries/ — externalBin chỉ bundle exe, DLL phải cạnh sidecar.
  • build_windows.ps1: thêm check src-tauri\binaries\libfluidsynth-3.dll sau bước bridge build.
  • tauri.conf.json: thêm "binaries/libfluidsynth-3.dll": "libfluidsynth-3.dll" vào bundle.resources → installer đặt DLL cạnh exe (cùng thư mục sidecar). LƯU Ý: tauri-build validate resource tồn tại lúc compile — phải chạy build_native_bridge.ps1 trước cargo build/tauri build.
  • lib.rs bridge_candidates: thêm 2 candidate res_dir/triple_name + exe_dir/triple_name — externalBin đặt sidecar ở INSTALL ROOT (tên có hậu tố triple), không nằm dưới binaries/ → trước đây bản cài đặt không tìm thấy bridge (WASM fallback).
  • Verify: parse PS1 OK (3 script), cargo check OK, chạy thử build_native_bridge.ps1 PASS (sfizz skip nhanh, build lại bridge + copy exe/DLL).
  • BUG CWD leak (sửa 2026-08-12): build_native_bridge.ps1Set-Location $PSScriptRoot mà không trả về — gọi từ build_windows.ps1 bằng & làm CWD bị đổi sang build/scripts → check src-tauri\binaries\daw_vst_bridge-x86_64-pc-windows-msvc.exe (relative) fail dù file tồn tại: "DONE: sidecar + DLL ..." rồi "ERROR: bridge sidecar missing". Sửa: bỏ Set-Location trong build_native_bridge.ps1 (mọi path đã absolute từ $PSScriptRoot) + build_windows.ps1 Set-Location (Join-Path $PSScriptRoot "..\..") ngay sau lệnh & (phòng thủ). Đã verify: CWD giữ nguyên, check sidecar+DLL = True.
  • LƯU Ý PS 5.1: native stderr + $ErrorActionPreference="Stop" + redirect (2>&1/*>) → PS abort "NativeCommandError" (vd cmake warning). Không redirect trong flow build_windows.ps1 nên không ảnh hưởng; chỉ ảnh hưởng khi debug redirect stderr.

Ghi chu batch 2026-08-12 (verify installer + spawn.log)

  • User bao spawn.log khong thay dau vet daw_vst_bridge -> log dang xem la log CU 2026-08-11 21:00 (%APPDATA%\SonicForgeDAW\logs\spawn.log) tu ban cai truoc lib.rs fix (bridge logging + candidates). Log cu chi co engine candidates, khong co [bridge ...] lines.
  • Installer hien tai src-tauri/target/release/bundle/nsis/SonicForgeDAW_1.0.0_x64-setup.exe (mtime 09:35) build SAU lib.rs fix (08:58) voi src-tauri/binaries/ day du (daw_vst_bridge-x86_64-pc-windows-msvc.exe 1.3M + libfluidsynth-3.dll 515K) -> tauri-bundler fail neu thieu externalBin/resource luc bundle, nen installer chac chan chua ca 2. KHONG can rebuild setup.exe.
  • Candidate ky vong exists=True sau khi cai moi: exe_dir (triple name, bundle) = <INSTALL_ROOT>\daw_vst_bridge-x86_64-pc-windows-msvc.exe (LocalAppData\SonicForgeDAW neu per-user, hoac Program Files).
  • Ghi chu: msiexec /a (administrative extract) tre tren MSI 570MB nay (0 file sau ~15 phut, phai taskkill). Khong dung duoc de verify noi dung installer; grep ten file trong setup.exe cung khong ra vi NSIS nen ca script data.
  • KET QUA (user cai setup.exe 09:35 + chay): bridge chay OK — 3 process: sonicforge-daw.exe, daw_engine.exe, daw_vst_bridge.exe (9.2MB RAM). Install dir LocalAppData\SonicForgeDAW: daw_vst_bridge.exe 1.3M + libfluidsynth-3.dll 515.5K canh nhau. spawn.log co [bridge ...] lines, exists=true tai resource_dir (bundle root) va exe_dir (portable) = \daw_vst_bridge.exe. LUU Y: externalBin cua NSIS dat sidecar o install ROOT voi TEN PLAIN (daw_vst_bridge.exe), KHONG co hau to triple -> candidates triple name deu exists=false (vo hai, plain name bat duoc). engine.log 10:02:40 listening 0.0.0.0:8001 OK.

Ghi chu batch 2026-08-12 (fix UI: mat TAURI khi redirect - trieu chung VSTi/Carla + SF2 khong am)

  • TRIEU CHUNG user: (1) goi VSTi -> app chay voi Carla bridge thay vi native host bridge; (2) goi instrument SF2 -> khong co am thanh.
  • GOC RE: src-tauri/ui/index.html la bootstrap script location.href = http://127.0.0.1:/ redirect sang engine origin -> ROI T context tauri:// -> mat window.TAURI -> nativeBridgeService._init() thay khong TAURI -> 'native bridge disabled', isBridgeConnected=false -> unifiedMidiRouter.isBridgeActive() false -> moi MIDI roi ve onFallback (SonicSF WASM cho SF2) / SonicCarlaMidi (runtime.js route Carla khi track VSTi + bridge connected=false). Rust van spawn bridge + SHM -> process song, nhung JS khong bao gio dung. Khop 100% 2 trieu chung.
  • FIX src-tauri/ui/index.html: bo location.href redirect; thay bang script async quet /health 8000-8010 tim engine, fetch(base) lay HTML UI, inject + window.API_BASE_URL sau <head>, roi document.write tren CUNG document -> origin tauri:// giu nguyen -> TAURI song -> NativeBridgeService active. (Engine chon port dong 8000-8010, engine.log thay 8001; api.js mac dinh window.location.origin -> override API_BASE_URL. Engine CORS allow_origins=[*] OK fetch cheo origin.)
  • FIX app/static/js/services/runtime.js (patch python 2 cho shouldRoute + shouldRoutePlayback): thay if (NativeBridgeService.isBridgeConnected) return false; bang check activeInstrumentType - chi chan Carla khi bridge connected VA instrument KHONG phai VST (VSTi van route Carla vi bridge chua host VST). Copy sang src-tauri/resources/daw_engine/_internal/... + dist/daw_engine/_internal/... (installer nhung tu resources; dist la nguon PyInstaller). cmp OK.
  • build/scripts/frontend_host_index.html = template = ban index.html moi; build_windows.ps1 buoc [7/7] them Copy-Item frontend_host_index.html -> src-tauri/ui/index.html truoc npx tauri build.
  • REBUILD installer 2026-08-12 10:27: setup.exe (363M) + 10:30: MSI moi. Trong release: runtime.js co activeInstrumentType (2 occurrences) = ban da patch. LUU Y: bash khong chay duoc npx (khong tim extension) -> dung cmd //c ..\node_modules\.bin\tauri.cmd build tu src-tauri.
  • USER CAN LAM: cai lai setup.exe moi -> test SF2 (phai phat qua bridge, toast 'Da load vao Native Bridge', MIDI route bridge) va VSTi (van route Carla).

Ghi chú batch 2026-08-12 (G2 3 PASS + fix VST3 dangle + installer mới)

  • G2 smoke 3 PASS trên binary sạch (md5 bb1380357c30ec931058c65c29beeb46): SF2 peak=0.04333, SFZ peak=0.02455, VST3 (mda DX10) peak=0.16096.
  • "Không ra âm" SFZ là artifact đo: g2_test.sfz dùng dummy1.wav (tone suy giảm nghe được ~120-230ms), poll cũ 0.25-0.6s bỏ lỡ. Fix: g2_bridge_smoke.py poll_peak(1.5s) mỗi 10ms track max.
  • BUG VST3 crash khi load sau instrument khác (0xC0000005): src/Vst3Instrument.cpp loadPlugin dùng const ClassInfo* trỏ vào temporary trả về by value từ factory.classInfos() (sdk module.h ClassInfos classInfos() const noexcept) → dangle sau range-for. Fix: copy ClassInfo chosen; by value trong scope { auto infos = factory.classInfos(); ... }. Verify 4 sequence sf2,vst3 / vst3,sfz / sf2,sfz,vst3 / sfz,vst3 đều ALIVE, log “[Vst3Instrument] loaded ... (mda DX10) outCh=2”.
  • runtime.js (cả 2 bản: src-tauri/resources/daw_engine/_internal + app/static/js/services): shouldRoute/shouldRoutePlayback return false khi window.NativeBridgeService.isBridgeConnected → bridge host native SF2/SF3/SFZ/VST3, không bao giờ route Carla.
  • Debug prints đã xóa khỏi NativeInstrumentEngine.cpp ([SFZ] loadSfzFile/noteOn/render peaks); cleanup: scratch_test target khỏi CMakeLists.txt + scratch_test.cpp + fix_.py + dbg_ probes + seq_*.txt logs đã xóa.
  • Installer mới: NSIS SonicForgeDAW_1.0.0_x64-setup.exe (11:44:12, 363307885 B) + MSI (11:47:02, 598618948 B). md5 3 binary giống hệt bb1380357c30ec931058c65c29beeb46 (build/Release == src-tauri/binaries/ == target/release). packaged runtime.js có isBridgeConnected check (PACKAGED-OK).
  • CMakeLists sau khi bỏ scratch_test vẫn build OK (daw_vst_bridge.vcxproj relink, md5 giữ nguyên).

Ghi chú batch 2026-08-12 (FIX LOGIN "Not Found" + reset pass admin + rebuild installer)

  • TRIỆU CHỨNG user: login không được — "Not Found", "không tìm thấy database cũ standalone", pass mặc định không vào.
  • NG.NHÂN "Not Found" (2 lớp):
    1. app.jsx:10 const API_BASE_URL = window.location.origin; — trong Tauri origin=tauri://localhost → mọi fetch API resolve sai → "Not Found". Fix: (window.API_BASE_URL || window.location.origin).replace(/\/+$/, ''); rebuild bundle (app.precompiled.js), bump tag ?v=202608102202 → ?v=202608121215 trong 4 index.html (app/templates, installed _internal, dist/_internal, resources/_internal).
    2. double-slash: shell Tauri inject API_BASE_URL có trailing slash ("http://127.0.0.1:8000/") + api.js nối /api/v1 → //api/v1 → FastAPI 404 "Not Found". Fix: base.replace(//$/,'') trong build/scripts/frontend_host_index.html (đã sync src-tauri/ui/index.html, diff IDENTICAL) + api.js:2 replace(//+$/,''). Probe xác nhận: double-slash=404, single-slash=400.
  • DB thật: %APPDATA%\SonicForgeDAW\storage\sonicforge.db (WAL, 96KB) — KHÔNG có DB ở LocalAppData; user tìm nhầm chỗ. Chứa sẵn admin + 2 projects (dữ liệu cũ còn nguyên).
  • Pass admin đã bị đổi (verify admin123/admin/password/... đều FALSE). seed_admin chỉ seed khi chưa có admin, KHÔNG reset. Không có endpoint reset. → Reset trực tiếp DB (engine tắt): hashed_password = hash_password("admin123") (PBKDF2-HMAC-SHA256 600000 iter, salt token_hex(32), format salt:hash — dùng đúng thuật toán app/core/auth.py). Verify: admin/admin123 login HTTP 200 (token + user), admin/wrong 400.
  • REBUILD SẠCH (không hot-patch): python -m PyInstaller engine.spec --clean --noconfirm → dist/daw_engine mới (12:29, md5 3367007aaced6e3c32a7a940914850e0) → copy sang src-tauri/resources/daw_engine/ → cmd //c ..\node_modules\.bin\tauri.cmd build từ src-tauri → installer mới: NSIS setup.exe 363333650 B (12:44) + MSI 598651716 B (12:47). Bridge md5 giữ bb1380357c30ec931058c65c29beeb46 (release + binaries).
  • Verify packaged (target/release/daw_engine/_internal): api.js fix=1, precompiled fix=1, index.html tag ?v=202608121215, runtime.js có isBridgeConnected, engine md5 == dist.
  • PASS MẶC ĐỊNH SAU CÀI MỚI: admin / admin123 (user nên đổi lại sau khi vào).

Ghi chú batch 2026-08-12 (FIX: GUI VST native window + audio path bridge — E2E ĐẠT)

  • TRIỆU CHỨNG user: (1) chọn VSTi → mở Carla (KHÔNG đúng TASKS.md — bridge host mọi instrument); (2) instrument SF2 câm; (3) GUI plugin mở ra nhưng là HTML che, không phải cửa sổ plugin thật.
  • FIX Issue 2 (GUI native): src-tauri/src/lib.rs open_vst_gui bỏ WebviewWindowBuilder/thread → chỉ shm.push_control(4,0,0,0,&plugin_id); native_bridge/src/main.cpp thêm create_native_vst_window(title) (class SonicForge_Native_VST3_Class, WS_OVERLAPPEDWINDOW|WS_VISIBLE 800x600, không TOPMOST), OPEN_GUI arg1==0 tạo window trong ChannelWorker job, giữ guiWindows map, capture arg2 by value (fix dangling). Verify: hwnd 0x4BE0EC4 class SonicForge_Native_VST3_Class title Nexus, child JUCE_19ff6684f11 visible.
  • FIX Issue 1 (âm câm): root cause SF2 = HAS_PYFLUIDSYNTH=FALSE trong bundled engine → /api/v1/plugins/soundfont-render 501; VST3 play path cũ nativeSf/scheduleCarlaNote không chạy vì Carla đã gỡ. Fix app.jsx: guard isBridgeActive() vào 8 chỗ (kbNative 9306, keybed mouseenter 9335, pvCtx wheel 8180, clCtx piano-roll 8550, dwTrk draw 8814, pvCtxInst draw 8915, nativeSf 21779+22075, subNativeSf 21942) → bridge active thì mọi note đi router → pushEvent → bridge.
  • E2E CHÍNH ĐẠT (CDP + SHM): sf2_focus2 — bridge active, loadInstrument SF2 orchestral ch0 ok=true, dispatchMidiEvent NOTE_ON 60 → SHM peak 0.029745 (âm phát qua bridge), NOTE_OFF → pk 0.
  • E2E UI còn lại: chèn SF2 024 từ PM → track 01 có instrument 024; PR track 01 vẫn mở track 02 (track 01 chưa có MIDI item — dblclick lane không mở PR; không phải bug); preset list modal Select Instrument trống (bank list OK) — instrument data chưa expand, không chặn E2E chính.
  • VERIFY thêm: gui_test_nexus.py native window OK; bridge.log 1 lần "Starting", 43 "instrument loaded", load thread ch=1 path 024_BigSymphny.sf2 → assigned ok=1; transport STOP.