fix: bridge crash/stall when opening native VST GUI while playing

- Fix A (USER32 crash): WM_CLOSE no longer destroys the native VST
  window from the main thread (plugin editor children live on the
  channel worker thread). WM_CLOSE -> hide + closeGUI on worker;
  WM_DESTROY erases registry. LOAD_INSTRUMENT close uses closeGUI +
  SW_HIDE, waits on hasAttachedView() instead of registry erase.
- Fix B: per-process SHM name SonicForge_DAW_IPC_{pid} so stale
  bridges from old builds can never attach to a new app's ring buffer.
- Fix C (stall): opening editor for a plugin whose other channel still
  has a live instance of the same DLL (Nexus) deadlocked the audio
  loop (reload+createView on worker while audio thread processed the
  other instance). Silence same-path channels via setReloading during
  reload/attach, restore afterwards; audio resumes.
- Rebuild bridge + update install/ portable package.
This commit is contained in:
2026-08-14 14:36:34 +07:00
parent a1bbf549b7
commit 0696545ae9
6 changed files with 127 additions and 31 deletions
+5 -5
View File
@@ -169,7 +169,7 @@ fn spawn_bridge(
match app
.shell()
.command(&bridge_exe)
.env("SF_SHM_NAME", shm::SHM_NAME)
.env("SF_SHM_NAME", shm::shm_name())
.env("SF_PARENT_PID", std::process::id().to_string())
.env("SF_SAMPLE_RATE", sample_rate.to_string())
.env("SF_BLOCK_SIZE", "256")
@@ -342,7 +342,7 @@ pub fn run() {
let shm_created = Shm::create();
println!(
"SharedMemory {}: {}",
shm::SHM_NAME,
shm::shm_name(),
if shm_created.is_some() { "created" } else { "unavailable (non-windows or error)" }
);
app.manage(ShmState(Mutex::new(shm_created)));
@@ -588,7 +588,7 @@ fn open_vst_gui(app: AppHandle, plugin_id: String, channel: u8) -> Result<(), St
#[derive(serde::Serialize)]
struct BridgeStatus {
connected: bool,
shm_name: &'static str,
shm_name: String,
write_index: u32,
block_timestamp: u64,
shm_size_bytes: usize,
@@ -610,7 +610,7 @@ fn bridge_status(app: AppHandle) -> Result<BridgeStatus, String> {
let status = match guard.as_ref() {
Some(shm) => BridgeStatus {
connected: true,
shm_name: shm::SHM_NAME,
shm_name: shm::shm_name(),
write_index: shm.write_index(),
block_timestamp: shm.block_timestamp(),
shm_size_bytes: std::mem::size_of::<shm::SharedAudioBufferIPC>(),
@@ -623,7 +623,7 @@ fn bridge_status(app: AppHandle) -> Result<BridgeStatus, String> {
},
None => BridgeStatus {
connected: false,
shm_name: shm::SHM_NAME,
shm_name: shm::shm_name(),
write_index: 0,
block_timestamp: 0,
shm_size_bytes: 0,