Skip to content

Activate hosted plugins before restoring their saved state - #472

Open
ItsAlphaNeon wants to merge 2 commits into
mainfrom
plugin-state-order
Open

ItsAlphaNeon wants to merge 2 commits into
mainfrom
plugin-state-order

Conversation

@ItsAlphaNeon

Copy link
Copy Markdown
Owner

Summary

  • When a new instance started from a saved state (project open, FLP import, undo, container members, native hosting), it got the state before the host had set its sample rate and block size or activated it. Plugins that compute from the rate while restoring (the issue's VASTvaporizer2) divided by zero and crashed.
  • Plugins::instantiate and instantiate_effect now share one start step: activate at the device rate, then load the state. Activation covers VST2 effSetSampleRate / effSetBlockSize / effMainsChanged, VST3 setupProcessing / setActive and CLAP activate, and all three formats take a state while active.
  • VST2 and VST3: after a state lands on an active instance, the host reads the latency again (and, for VST2, the channel counts). If they changed without the plugin saying so, the instance is set up again on the next idle.
  • Process isolation (the issue's second half) is not in this PR. The contributor's attached patch was not used: this is written from the issue's description.

Fixes #458 (the load-order part; process isolation is still open)

Test plan

  • New os_session::order_probe test plugin: it logs the order of host calls and refuses a state that arrives before a rate.
  • saved_states_reach_plugins_after_activation (os-session): every creation path in CLAP, VST3 and VST2. It fails before the fix.
  • reopened_projects_activate_plugins_before_their_state (os-app): FLP save → open → sync_wrapped, plus native hosting. It fails before the fix.
  • VST2 and VST3 mock tests: the state comes after the rate, block size and activation, and a latency that changed quietly is taken on idle.
  • cargo test --workspace --locked on Windows: 2711 passed, 0 failed.
  • Manual, on Linux: reopen the issue's project with VASTvaporizer2 + LSP Compressor (the plugin isn't on the Windows test machine).

🤖 Generated with Claude Code

ItsAlphaNeon and others added 2 commits December 3, 2026 02:20
Plugins::instantiate / instantiate_effect, which every path that starts an
instance from a saved state goes through (project open, FLP import, undo,
container members, sampler/recreation sync, native hosting), gave the plugin
its state before activating it. A plugin that works its state out at the
sample rate (VASTvaporizer2 divided by it) failed. They now share one start
step: activate at the device rate (VST2 effSetSampleRate / effSetBlockSize /
effMainsChanged, VST3 setupProcessing / setActive, CLAP activate), then load
the state.

Tests: a call-order probe plugin (os_session::order_probe, test builds only)
that refuses a state before a rate; os-session checks every creation path in
CLAP, VST3 and VST2 format, os-app checks a saved project reopened through
FLP open + sync_wrapped and native hosting. Both failed before the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A state now reaches an already active instance, so the latency (and VST2
channel counts) read at activation can be stale. After a state loads on an
active instance the host re-reads them; if they moved without the plugin
signalling it (audioMasterIOChanged / restartComponent), the next idle sets
the instance up again, as for a signalled change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Crash from plugin state load order AND signal handler isolation

1 participant