From 569be7211037d250a3a8ce9d740f66de1a9014d4 Mon Sep 17 00:00:00 2001 From: locphamtran Date: Tue, 18 Aug 2026 08:27:35 +0700 Subject: [PATCH] fix(native_bridge): strip query string in fx-gui HTTP path + walkthrough notes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - readRequest now trims '?t=' cache-buster so /frame?t=... matches /frame route (frontend VstGuiEmbed polls with timestamp → was 404, no image) - document: jpeg62.dll manual copy, add auto-opens GUI (already_running expected), reopen needs bridge exit wait --- WALKTHROUGH_WINDOWS.md | 10 ++++++++-- native_bridge/src/FxGuiServer.cpp | 13 +++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/WALKTHROUGH_WINDOWS.md b/WALKTHROUGH_WINDOWS.md index 4a1ec0a..75ac7ea 100644 --- a/WALKTHROUGH_WINDOWS.md +++ b/WALKTHROUGH_WINDOWS.md @@ -30,6 +30,8 @@ Lưu ý thay đổi mới trong phần này (so với lần build cũ): - Script phải copy `daw_vst_bridge.exe` + DLL (fluidsynth, jpeg) sang `src-tauri\binaries\` (chỉ các DLL cần thiết; libjpeg-turbo thường static theo manifest, nếu build động thì copy luôn `jpeg62.dll`). +- Trên máy thật: script hiện KHÔNG copy `jpeg62.dll` (build động) — copy tay: + `copy native_bridge\build\Release\jpeg62.dll src-tauri\binaries\`. **PASS khi**: `native_bridge\build\Release\daw_vst_bridge.exe` tồn tại và `daw_vst_bridge.exe --help` không crash. @@ -103,11 +105,15 @@ chết (`Get-Process daw_vst_bridge` không còn). ## 2W1 — E2E MasteringModal 1. Mở app → **Mastering Panel**. -2. Thêm VST (Ozone) vào master chain → **bấm nút GUI** trên slot. +2. Thêm VST (Ozone) vào master chain → GUI TỰ MỞ (addMasterVst gọi openMasterVstGui). + Bấm thêm nút GUI trên slot lúc này → backend trả `already_running:true` + toast + "GUI của plugin này đang mở sẵn" — đúng thiết kế, không spawn 2 GUI. 3. Kỳ vọng: GUI plugin hiện **TRONG panel** (thay vùng graph EQ/imager), header hiện "VST GUI — nhúng (frame-capture · ~10fps)". 4. Click/scroll/kéo trong vùng GUI → plugin phản hồi (thay preset, xoay nút). -5. Bấm "✕ Đóng GUI" → về graph; bấm nút GUI lại → mở lại. +5. Bấm "✕ Đóng GUI" → về graph; chờ ~2-3s (bridge thoát hẳn) rồi bấm nút GUI lại + → mở lại. Bấm ngay trong ~1s đầu có thể vẫn nhận `already_running` (process + chưa thoát) — không phải lỗi. 6. Xóa slot khi GUI đang mở → GUI đóng + slot xóa, không crash. 7. Tắt bridge thủ công (Task Manager kill `daw_vst_bridge`) → sau ~2s panel toast "Bridge VST GUI đã mất kết nối" và tự trả về graph. diff --git a/native_bridge/src/FxGuiServer.cpp b/native_bridge/src/FxGuiServer.cpp index 8b79a2f..9366556 100644 --- a/native_bridge/src/FxGuiServer.cpp +++ b/native_bridge/src/FxGuiServer.cpp @@ -22,10 +22,10 @@ #include #pragma comment(lib, "ws2_32.lib") +#include #include #include -#include #include #include #include @@ -39,6 +39,12 @@ namespace { // --- tiny JSON helpers (same API as RenderFxJob.cpp) ------------------------ +const json_object_element_s* member(const json_object_s* o, const char* key) { + for (const json_object_element_s* e = o ? o->start : nullptr; e; e = e->next) + if (e->name && e->name->string && std::strcmp(e->name->string, key) == 0) + return e; + return nullptr; +} const json_value_s* memberValue(const json_object_s* o, const char* key) { const json_object_element_s* m = member(o, key); return m ? m->value : nullptr; @@ -83,6 +89,9 @@ bool readRequest(SOCKET c, HttpReq& out) { if (sp1 == std::string::npos || sp2 == std::string::npos) return false; out.method = head.substr(0, sp1); out.path = head.substr(sp1 + 1, sp2 - sp1 - 1); + // strip query string: frontend cache-busts /frame?t= + const size_t q = out.path.find('?'); + if (q != std::string::npos) out.path.resize(q); long contentLength = 0; size_t pos = 0; @@ -285,7 +294,7 @@ void runHttpServer(HWND hwnd, std::atomic& stop) { } else if (req.path == "/close") { sendResponse(c, 200, "application/json", "{\"ok\":true}", 11); stop.store(true); - PostMessageA(hwnd, WM_CLOSE); // pump exits -> process returns + PostMessageA(hwnd, WM_CLOSE, 0, 0); // pump exits -> process returns } else { sendResponse(c, 404, "application/json", "{\"error\":\"not found\"}", 22); }