Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 75 additions & 24 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
#endif
orbit_.stop();
catalog_.onChanged = nullptr;
closePluginEditor();
closeAllPluginEditors();
// Tear down the modal transaction first. A closing window must not
// re-enter device rebind while ConsoleWindow is being destroyed.
audioSetupLease_.reset();
Expand Down Expand Up @@ -563,6 +563,14 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
// retained vendor processor lease. No vendor destructor runs on RT.
armix::mixer::LiveChannelFxGraph::InstanceLease routedEditorOwner_;
std::uint64_t routedEditorEpoch_=0;
#if defined(ARMIX_IMMERSIB_RELEASE_CANDIDATE) && ARMIX_IMMERSIB_RELEASE_CANDIDATE
// A separate native concert HWND: third-party VST3 editors must not
// close or silently replace the active ImmerSIB processor UI.
armix::mixer::LiveChannelFxGraph::InstanceLease immersibEditorOwner_;
std::uint64_t immersibEditorEpoch_=0;
juce::AudioProcessor* immersibEditorProcessor_=nullptr; // non-owning identity
std::unique_ptr<PluginEditorWindow> immersibEditorWindow_;
#endif
struct PendingNativeEq {
armix::mixer::LiveChannelFxGraph::InstanceLease owner;
juce::String request,channelId,deviceEpoch,revision,instanceId;
Expand Down Expand Up @@ -1050,9 +1058,9 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
// The editor must reflect accepted global/rack/slot PCM state even
// when the gesture originated in the WebView header or FX Rack.
// All these dispatches run on JUCE's UI/message thread.
if(editorWindow_)
if(immersibEditorWindow_)
if(auto* ui=dynamic_cast<armix::builtin_fx::ImerSipP92Editor*>(
editorWindow_->getContentComponent()))
immersibEditorWindow_->getContentComponent()))
ui->synchronizeHostPower();
#endif
}
Expand All @@ -1064,6 +1072,19 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
routedEditorEpoch_=0;
}

void closeImmerSIBEditor() noexcept {
#if defined(ARMIX_IMMERSIB_RELEASE_CANDIDATE) && ARMIX_IMMERSIB_RELEASE_CANDIDATE
immersibEditorWindow_.reset(); // JUCE editor disposed before PCM owner
immersibEditorProcessor_=nullptr;
immersibEditorOwner_.reset();
immersibEditorEpoch_=0;
#endif
}
void closeAllPluginEditors() noexcept {
closePluginEditor();
closeImmerSIBEditor();
}

void emitChain()
{
if (browser_.loaded)
Expand Down Expand Up @@ -3891,7 +3912,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
chosenEpoch==engine.dryRoutingLabEpoch()&&engine.liveOutputArmFault(false).isEmpty())
engine.setMonitorEnabled(true);
if(error.isEmpty()) {
safe->closePluginEditor();
safe->closeAllPluginEditors();
safe->stopOrbit();
safe->mixerSessionId_=id;
const auto keyError=safe->hotkeys_.activateSession(id,&importedHotkeys);
Expand Down Expand Up @@ -5865,7 +5886,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
if(error.isEmpty()) {
// Structural replacement can remove the vendor object.
// Close its editor before attempting graph publication.
closePluginEditor();
closeAllPluginEditors();
try {
error=engine_.applyDryRoutingLab(value,selected);
} catch(const std::exception& ex) {
Expand Down Expand Up @@ -6572,17 +6593,34 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
}
} else owner=engine_.leaseRoutedFxForEditor(lane,slot,epoch,revision,token);
if(owner && owner->processor) {
#if defined(ARMIX_IMMERSIB_RELEASE_CANDIDATE) && ARMIX_IMMERSIB_RELEASE_CANDIDATE
const bool dedicatedImmerSIB=dynamic_cast<
armix::builtin_fx::ImerSipP92Processor*>(owner->processor.get())!=nullptr;
auto& shownWindow=dedicatedImmerSIB?immersibEditorWindow_:editorWindow_;
auto& shownOwner=dedicatedImmerSIB?immersibEditorOwner_:routedEditorOwner_;
auto& shownEpoch=dedicatedImmerSIB?immersibEditorEpoch_:routedEditorEpoch_;
auto& shownProcessor=dedicatedImmerSIB?immersibEditorProcessor_:editorProcessor_;
#else
auto& shownWindow=editorWindow_;
auto& shownOwner=routedEditorOwner_;
auto& shownEpoch=routedEditorEpoch_;
auto& shownProcessor=editorProcessor_;
#endif
// A second click must raise an already open OR hidden
// editor for exactly this accepted instance. Do not
// destroy/recreate JUCE's active editor on every click.
if(editorWindow_ && routedEditorOwner_==owner &&
routedEditorEpoch_==retainedEpoch &&
editorProcessor_==owner->processor.get()) {
editorWindow_->present();
if(shownWindow && shownOwner==owner &&
shownEpoch==retainedEpoch &&
shownProcessor==owner->processor.get()) {
shownWindow->present();
Comment on lines +6612 to +6615

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update existing lifecycle assertions for the aliased editor state

The refactor to shownOwner/shownEpoch leaves existing source-contract tests asserting the removed expressions. Running python3 tests/native_fx_window_lifecycle_contract_test.py fails on routedEditorOwner_==owner, and node --test tests/approved_native_m2_contract.test.cjs fails on routedEditorEpoch_=retainedEpoch; the parent lifecycle suite passes. These tests are executed by .github/workflows/native-fx-owned-editor.yml, ui-smoke.yml, and p1-windows.yml, so the change breaks qualification despite adding passing new assertions. Update the existing retention/refocus assertions to validate the aliased state while preserving their identity and disposal-order checks.

Useful? React with 👍 / 👎.

opened=true;
error.clear();
} else try {
closePluginEditor();
#if defined(ARMIX_IMMERSIB_RELEASE_CANDIDATE) && ARMIX_IMMERSIB_RELEASE_CANDIDATE
if(dedicatedImmerSIB)closeImmerSIBEditor();
else
#endif
closePluginEditor();
if(auto* editor=owner->processor->createEditorIfNeeded()) {
#if defined(ARMIX_IMMERSIB_RELEASE_CANDIDATE) && ARMIX_IMMERSIB_RELEASE_CANDIDATE
if(auto* imer=dynamic_cast<
Expand Down Expand Up @@ -6626,19 +6664,27 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
},readPower);
}
#endif
routedEditorOwner_=owner;
routedEditorEpoch_=retainedEpoch;
editorWindow_=std::make_unique<PluginEditorWindow>(
shownOwner=owner;
shownEpoch=retainedEpoch;
shownWindow=std::make_unique<PluginEditorWindow>(
owner->processor->getName(),editor,*this);
editorProcessor_=owner->processor.get();
shownProcessor=owner->processor.get();
opened=true;
error.clear();
} else error="This VST3 has no native editor";
} catch(const std::exception& ex) {
closePluginEditor();
#if defined(ARMIX_IMMERSIB_RELEASE_CANDIDATE) && ARMIX_IMMERSIB_RELEASE_CANDIDATE
if(dedicatedImmerSIB)closeImmerSIBEditor();
else
#endif
closePluginEditor();
error="Vendor editor failed: "+juce::String(ex.what());
} catch(...) {
closePluginEditor();
#if defined(ARMIX_IMMERSIB_RELEASE_CANDIDATE) && ARMIX_IMMERSIB_RELEASE_CANDIDATE
if(dedicatedImmerSIB)closeImmerSIBEditor();
else
#endif
closePluginEditor();
error="Vendor editor failed (plugin exception)";
}
}
Expand Down Expand Up @@ -6694,7 +6740,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
if(error.isEmpty()) {
// Do not read vendor parameters while an editor is open.
// Output MUST already be muted by captureDry and the engine.
closePluginEditor();
closeAllPluginEditors();
std::vector<LiveDryRoutingLab::CapturedFxState> vendorStates;
error=engine_.captureRoutedFxStates(epoch,revision,vendorStates);
if(error.isEmpty()) {
Expand Down Expand Up @@ -6952,7 +6998,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
lane-LiveDryRoutingLab::count)].fx);
}
if(error.isEmpty()) {
safe->closePluginEditor();
safe->closeAllPluginEditors();
error=safe->engine_.applyDryRoutingLab(
command,selections,&restores);
}
Expand Down Expand Up @@ -7034,7 +7080,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
// Backward-compatible command name: CLEAR PATCH keeps the one
// native 10CH+4AUX topology, with ALL physical inputs disconnected.
// Never enable the legacy CH1 signal path on STOP or hotplug.
closePluginEditor();
closeAllPluginEditors();
const auto error=engine_.clearProductionRouting();
diagnostics_.record(error.isEmpty()?"NATIVE_INPUT_PATCH_CLEARED":
"NATIVE_INPUT_PATCH_CLEAR_FAILED",
Expand All @@ -7058,7 +7104,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
if (!value.isBool()) return emitNotice ("Invalid smart clock command", true);
// Close third-party editors before device/processor preparation.
stopOrbit();
closePluginEditor();
closeAllPluginEditors();
const auto error = engine_.setIndependentClockEnabled (bool (value));
if (error.isNotEmpty())
{
Expand Down Expand Up @@ -7202,7 +7248,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
if (!engine_.allOutputsDisarmed())
return emitNotice ("Mute output in SIGNAL CHECK before saving a native sound preset. This avoids interrupting your live performance.", true);
stopOrbit();
closePluginEditor();
closeAllPluginEditors();
armix::storage::Snapshot snapshot;
snapshot.name = name;
auto error = engine_.captureSnapshot (snapshot);
Expand All @@ -7227,7 +7273,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
if (engine_.isGraphSwitchPending())
return emitNotice ("FX recall is already transitioning; retry shortly.", true);
stopOrbit();
closePluginEditor();
closeAllPluginEditors();
armix::storage::Snapshot snapshot;
auto error = presets_.load (name, snapshot);
if (error.isEmpty()) error = engine_.restoreSnapshot (snapshot);
Expand Down Expand Up @@ -7320,7 +7366,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
// Orbit retains the same vendor instance across the prepared graph handoff.
const bool keepOrbit=orbit_.active();
if(keepOrbit)orbit_.pauseForGraphEdit();
closePluginEditor();
closeAllPluginEditors();
try
{
error = engine_.addVst3 (plugin->path, plugin->uid, plugin->key(),plugin->name);
Expand Down Expand Up @@ -7360,7 +7406,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
const auto* previous=orbit_.processor();
const bool removedOrbit=previous && engine_.pluginAt(slot)==previous;
if(orbit_.active())orbit_.pauseForGraphEdit();
closePluginEditor();
closeAllPluginEditors();
const bool changed=engine_.removeAt(slot);
if(changed) {
// Orbit stays paused until the callback and control thread
Expand Down Expand Up @@ -8386,6 +8432,11 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
if(routedEditorOwner_ &&
!engine_.retainsRoutedFxEditor(routedEditorEpoch_,routedEditorOwner_))
closePluginEditor();
#if defined(ARMIX_IMMERSIB_RELEASE_CANDIDATE) && ARMIX_IMMERSIB_RELEASE_CANDIDATE
if(immersibEditorOwner_ &&
!engine_.retainsRoutedFxEditor(immersibEditorEpoch_,immersibEditorOwner_))
closeImmerSIBEditor();
#endif
annotateRecovery (state);
state.getDynamicObject()->setProperty("mixerSessionStatus",mixerSessionStatus_);
if(mixerSessionError_.isNotEmpty())
Expand Down
28 changes: 28 additions & 0 deletions tests/approved_native_fx_edit_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,34 @@ def accept(request):
assert row(2,0).get_attribute('data-insert-id')=='actual-a'
assert page.locator('.wire-main-fragment').count()==0
assert any(e['to']==state['graph']['mainChannelId'] for e in state['graph']['edges'])
# ImmerSIB native editor must dispatch the *accepted* ChannelId
# token, even when a dearVR/VST3 editor is opened in the same
# live rack. This is a browser transport test; the JUCE HWND's
# separate lifetime is compiled and checked by Windows FAT.
state['graph']['channels'][1]['inserts']=[
{'id':'concert-accepted','catalogId':'armix.builtin.imersip.v1',
'name':'ImmerSIB','bypassed':False},
{'id':'dearvr-accepted','catalogId':'vst3.dearvr.pro2',
'name':'dearVR PRO 2','bypassed':False}]
state['mixerSession']['channels']=copy.deepcopy(state['graph']['channels'])
emit(page,'arMixConsoleSnapshot',state)
row(2,0).locator('[data-action="openPlugin"]').click()
opened=page.evaluate('()=>window.__actions.at(-1)')
assert opened['action']=='routingFxEditor' and opened['channelId']==RECEIVER,opened
assert opened['instanceId']=='concert-accepted',opened
assert str(opened['deviceEpoch'])==str(state['device']['epoch']),opened
assert str(opened['revision'])==str(state['graph']['revision']),opened
emit(page,'arMixRoutingFxEditorAck',{'ok':True,'instanceId':'concert-accepted'})
row(2,1).locator('[data-action="openPlugin"]').click()
vst=page.evaluate('()=>window.__actions.at(-1)')
assert vst['action']=='routingFxEditor' and vst['instanceId']=='dearvr-accepted',vst
emit(page,'arMixRoutingFxEditorAck',{'ok':True,'instanceId':'dearvr-accepted'})
row(2,0).locator('[data-action="openPlugin"]').click()
reopened=page.evaluate('()=>window.__actions.at(-1)')
assert reopened['action']=='routingFxEditor' and reopened['instanceId']=='concert-accepted',reopened
assert reopened['channelId']==RECEIVER,reopened
assert page.locator('#armixNativeToast:visible').count()==0,(
'Successful native editor open must not raise an FX settings toast')
assert not errors,errors
page.screenshot(path=f'native-fx-edit-{width}.png');page.close()
browser.close()
Expand Down
18 changes: 15 additions & 3 deletions tests/approved_native_m2_contract.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1907,18 +1907,30 @@ test("native FX remove/reorder/transfer requires exact token, ACK and ordered re
assert.equal(c.state().pending,null);
});

test("ImmerSIB opens the exact native ChannelId HWND, survives VST3 editor, no success-only toast",()=>{
const bridge=read("web/approved-native-bridge.js"),host=read("src/Main.cpp");
assert.match(bridge,/insert\.catalogId==='armix\.builtin\.imersip\.v1' && current\.admitted/);
assert.match(bridge,/backend\.emitEvent\("arMixAction",\{action:"routingFxEditor",channelId:id,slot,/);
assert.doesNotMatch(bridge,/else status\("Native VST3 editor opened"\)/);
assert.match(host,/shownWindow=dedicatedImmerSIB\?immersibEditorWindow_:editorWindow_/);
assert.match(host,/shownOwner=dedicatedImmerSIB\?immersibEditorOwner_:routedEditorOwner_/);
assert.match(host,/shownWindow->present\(\)/);
assert.match(host,/immersibEditorWindow_\.reset\(\)/);
assert.match(host,/!engine_\.retainsRoutedFxEditor\(immersibEditorEpoch_,immersibEditorOwner_\)/);
});

test("native vendor editor retention follows current PCM ownership, not inactive M4 slots",()=>{
const main=read('src/Main.cpp'),lab=read('src/LiveDryRoutingLab.h');
assert.match(main,/engine_\.retainsRoutedFxEditor\(routedEditorEpoch_,routedEditorOwner_\)/);
assert.match(main,/routedEditorEpoch_=retainedEpoch/);
assert.match(main,/shownEpoch=retainedEpoch/);
assert.match(main,/retainedEpoch=ep/);
assert.match(lab,/nativeAccepted_\.fxOwners->retainsEditor\(owner\)/);
const start=main.indexOf('if(owner && owner->processor)');
assert.ok(start>=0,'routed FX editor source must exist');
const editor=main.slice(start,main.indexOf('catch(const std::exception& ex)',start));
assert.ok(editor.includes('routedEditorOwner_==owner'),
assert.ok(editor.includes('shownOwner==owner'),
'reopen only exact current accepted PCM owner');
assert.ok(editor.includes('editorWindow_->present()'),
assert.ok(editor.includes('shownWindow->present()'),
'same FX instance must be focused instead of recreated');
const fresh=editor.slice(editor.indexOf('} else try {'));
assert.ok(fresh.includes('closePluginEditor();') &&
Expand Down
10 changes: 10 additions & 0 deletions tests/imersip_p92_catalog_contract_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
def source(path): return (ROOT/path).read_text(encoding="utf-8")

class ImerSipP92Contract(unittest.TestCase):
def test_immersib_rack_opens_real_native_editor_without_fake_toast(self):
bridge=source("web/approved-native-bridge.js")
host=source("src/Main.cpp")
self.assertIn("insert.catalogId==='armix.builtin.imersip.v1' && current.admitted",bridge)
self.assertIn('backend.emitEvent("arMixAction",{action:"routingFxEditor",channelId:id,slot,',bridge)
self.assertIn('instanceId:insert.id,deviceEpoch:current.device.epoch',bridge)
self.assertNotIn('else status("Native VST3 editor opened")',bridge)
self.assertIn("ImerSipP92Editor*>(editor)",host)
self.assertIn("std::make_unique<PluginEditorWindow>",host)

def test_single_pcm_authority_and_stable_catalog(self):
p=source("engine/builtin_fx/ImerSipP92Processor.h")
scene=source("engine/builtin_fx/ImerSipP92Scene.h")
Expand Down
Loading
Loading