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
4 changes: 3 additions & 1 deletion .github/workflows/ui-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ jobs:
needs: quick
# Both 8D-SonKu and SOF native-owner PRs share ONE actual Chromium runner.
# Preserve fast-only checks for unrelated GUI and engine branches.
if: ${{ (github.event_name == 'pull_request' && (startsWith(github.head_ref, 'feat/8d-sonku-') || startsWith(github.head_ref, 'test/sof-native-') || startsWith(github.head_ref, 'integration/sof-sonku-main-'))) || (github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/heads/feat/8d-sonku-') && inputs.expected_sha != '') }}
if: ${{ (github.event_name == 'pull_request' && (startsWith(github.head_ref, 'feat/8d-sonku-') || startsWith(github.head_ref, 'test/sof-native-') || startsWith(github.head_ref, 'integration/sof-sonku-main-') || startsWith(github.head_ref, 'fix/native-wire-inspector-'))) || (github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/heads/feat/8d-sonku-') && inputs.expected_sha != '') }}
runs-on: ubuntu-latest
timeout-minutes: 12
steps:
Expand All @@ -216,6 +216,8 @@ jobs:
# job (zero additional browser runners and zero Windows recompiles).
- name: Native SOF PRE/POST, SEND ON, EdgeId gain and ACK/readback Chromium
run: python tests/approved_native_sof_chromium_smoke.py
- name: Native WIRE Inspector rejected gain and exact EdgeId ACK rollback (real Chromium)
run: python tests/approved_native_wire_gain_smoke.py
- name: Integrated V65 WIRE motion, SOF and actual native WIRE regression
if: ${{ github.event_name == 'pull_request' && startsWith(github.head_ref, 'integration/sof-sonku-main-') }}
run: |
Expand Down
15 changes: 15 additions & 0 deletions scripts/build_approved_native_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,21 @@ def accepted_pages_html() -> str:
" }\n"
" }\n"
" },\n"
" rollbackNativeWireInspector(rows){\n"
" const gain=document.getElementById('wireWsGain');\n"
" const text=document.getElementById('wireWsGainText');\n"
" // Rejection/expiry has no new PCM snapshot. Restore the last admitted\n"
" // readback in-place rather than leaving a forever-PENDING inspector.\n"
" if(!gain||!text?.textContent?.startsWith('PENDING · '))return false;\n"
" const id=Number(gain.dataset.wsGain);\n"
" const edge=wireEdges.find(e=>e.id===id&&e.kind!=='primary'&&e.enabled);\n"
" const row=Array.isArray(rows)?rows.find(r=>r.id===id&&Number.isFinite(r.levelDb)):null;\n"
" if(!edge||!row){gain.disabled=true;text.textContent='SEND UNAVAILABLE';return true;}\n"
" edge.levelDb=row.levelDb;\n"
" gain.value=String(row.levelDb); // same focused input, no DOM replacement\n"
" text.textContent='UNCHANGED · '+row.levelDb+' dB';\n"
" return true;\n"
" },\n"
" syncVerifiedM4Wires(rows,ids){\n"
" if(!Array.isArray(rows)||rows.length!==10||!Array.isArray(ids)||ids.length!==10)\n"
" return false;\n"
Expand Down
23 changes: 23 additions & 0 deletions tests/approved_native_m2_contract.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ test("WIRE inspector controls PRIMARY BUS and PARALLEL MAIN by actual EdgeId, wi
const parallel={id:42,sourceId:1,destId:3,kind:"send",mode:"send",
nativeTap:"POST_FADER",levelDb:-6,enabled:true};
const panel={hidden:false,innerHTML:""},readout={textContent:"-6 dB"};
const inspectorGain={value:"-12",dataset:{wsGain:"42"},disabled:false};
const observed=[];
const gain=input=>input?.dataset?.wsGain!==undefined?input:null;
const tap=input=>input?.dataset?.wsTap!==undefined?input:null;
Expand All @@ -66,6 +67,7 @@ test("WIRE inspector controls PRIMARY BUS and PARALLEL MAIN by actual EdgeId, wi
get hidden(){return panel.hidden},set hidden(v){panel.hidden=v},
get innerHTML(){return panel.innerHTML},set innerHTML(v){panel.innerHTML=v}};
if(id==="wireWsGainText")return readout;
if(id==="wireWsGain")return inspectorGain;
return null;
}},
window:{__JUCE__:{backend:{}},__ARMIX_NATIVE_M2__:{
Expand Down Expand Up @@ -119,6 +121,27 @@ test("WIRE inspector controls PRIMARY BUS and PARALLEL MAIN by actual EdgeId, wi
assert.match(observed[2],/awaiting accepted native PCM readback/);
assert.equal(primary.levelDb,0);
assert.equal(parallel.levelDb,-6,"reference WIRE graph never becomes native routing owner");
// Execute the native compiled rollback method rather than a mock. It must
// repair the same focused DOM control from the latest accepted PCM readback.
// Rejection has no new snapshot: the original level remains -6, not -12.
const rollbackStart=html.indexOf(" rollbackNativeWireInspector(rows){");
const rollbackEnd=html.indexOf(" syncVerifiedM4Wires(rows,ids){",rollbackStart);
assert.ok(rollbackStart>0&&rollbackEnd>rollbackStart,"native rollback method installed exactly once");
const method=html.slice(rollbackStart,rollbackEnd).trim().replace(/,\s*$/,"");
const rollback=vm.runInNewContext("({"+method+"})",scope);
assert.equal(rollback.rollbackNativeWireInspector([{id:42,levelDb:-6}]),true);
assert.equal(inspectorGain.value,"-6","failed native intent restores accepted gain without replacing the focused input");
assert.equal(readout.textContent,"UNCHANGED · -6 dB","LCD cannot remain PENDING after a rejected gain");
assert.equal(parallel.levelDb,-6,"no browser graph edit or optimistic audio state");
assert.equal(rollback.rollbackNativeWireInspector([{id:42,levelDb:-6}]),false,
"idempotent failure reconciliation must not repaint a settled LCD");
// A stale EdgeId cannot silently roll back or write a different route.
inspectorGain.dataset.wsGain="41";readout.textContent="PENDING · -8 dB";
assert.equal(rollback.rollbackNativeWireInspector([{id:42,levelDb:-6}]),true);
assert.equal(inspectorGain.disabled,true);
assert.equal(readout.textContent,"SEND UNAVAILABLE");
assert.match(bridge,/rollbackNativeWireInspector\?\.\(nativeWireGainReadback\(state.current\)\)/,
"native control failure must invoke the same compiled inspector rollback");
});

test("native PRE_FADER WIRE inspector uses one exact SET_TAP PCM intent and accepted readback",()=>{
Expand Down
83 changes: 83 additions & 0 deletions tests/approved_native_wire_gain_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,86 @@ def drag():




def verify_inspector_rejected_gain(page, out):
"""Real compiled native GUI: rejected ACK with NO new snapshot must not
strand PENDING or detach the inspector slider held in keyboard focus."""
page.add_init_script("""window.__nativeListeners=new Map();window.__nativeIntents=[];
window.__JUCE__={backend:{
emitEvent(name,payload){
if(name==='arMixConsoleIntent')window.__nativeIntents.push(payload);
},
addEventListener(name,callback){window.__nativeListeners.set(name,callback);}
}};""")
errors=[]
page.on("pageerror",lambda exc:errors.append(str(exc)))
page.goto((out/"index.html").as_uri())
page.wait_for_function("()=>window.__ARMIX_NATIVE_M2__?.enabled")
state=snapshot()
# Use an exactly representable accepted -6 dB gain to prove the
# native coalescer's equality/no-op path emits no redundant intent.
state["graph"]["edges"][1]["gainLinear"]=10**(-6/20)
emit(page,"arMixConsoleSnapshot",state)
page.locator("#wireMatrixToggle").click()
route=page.locator('[data-ws-inspect="1:2"]')
route.wait_for(state="visible")
route.click()
slider=page.locator("#wireWsGain")
slider.wait_for(state="visible")
assert slider.is_enabled(),"Selected parallel SEND must allow native gain"
assert "PRIMARY" not in page.locator("#wireWsGainText").inner_text()
assert abs(float(slider.input_value())-(-6.0))<.11
page.evaluate("()=>window.__heldInspectorGain=document.getElementById('wireWsGain')")
slider.focus()
slider.evaluate("""el=>{
el.value='-12';
el.dispatchEvent(new Event('input',{bubbles:true}));
}""")
assert page.locator("#wireWsGainText").inner_text()=="PENDING · -12 dB"
page.wait_for_function(
"()=>window.__nativeIntents.filter(x=>x.operation==='SET_WIRE_GAIN').length===1")
request=page.evaluate(
"()=>window.__nativeIntents.find(x=>x.operation==='SET_WIRE_GAIN')")
assert request["targetChannelId"]==SOURCE,request
assert request["payload"]["edgeId"]==SEND,request
assert abs(request["payload"]["gainLinear"]-10**(-12/20))<1e-8,request
emit(page,"arMixConsoleAck",{
"requestId":request["requestId"],"status":"REJECTED",
"errorCode":"TEST_REJECTION","deviceEpoch":state["device"]["epoch"],
"graphRevision":state["graph"]["revision"],
"rosterRevision":state["graph"]["rosterRevision"]})
# NO independent later snapshot is intentionally emitted.
# A rejected request cannot wait for one to repaint its LCD.
assert page.locator("#wireWsGainText").inner_text()=="UNCHANGED · -6 dB"
assert abs(float(slider.input_value())-(-6))<.11
assert page.evaluate(
"()=>document.getElementById('wireWsGain')===window.__heldInspectorGain")
assert slider.evaluate("el=>document.activeElement===el"), (
"Rejection must not drop keyboard focus on the original range input")
assert len(page.evaluate(
"()=>window.__nativeIntents.filter(x=>x.operation==='SET_WIRE_GAIN')"))==1
assert abs(float(page.evaluate("""()=>{
// EdgeId is allocated by the native graph projector; never assume 2.
const id=Number(document.getElementById('wireWsGain').dataset.wsGain);
return window.__ARMIX_NATIVE_SCOPE__.wireEdges.find(e=>e.id===id)?.levelDb;
}"""))-(-6))<.11
# Requesting the exact same accepted -6 dB is a no-op: native must
# suppress redundant PCM writes AND settle the pending LCD by itself.
# No ACK, new snapshot or hidden user recovery action is available.
slider.evaluate("""el=>{
el.value='-6';
el.dispatchEvent(new Event('input',{bubbles:true}));
}""")
assert page.locator("#wireWsGainText").inner_text()=="PENDING · -6 dB"
page.wait_for_function("""()=>{
return document.getElementById('wireWsGainText')?.textContent==='-6 dB';
}""",timeout=5000)
assert len(page.evaluate(
"()=>window.__nativeIntents.filter(x=>x.operation==='SET_WIRE_GAIN')"))==1, (
"Exact accepted gain no-op must not resend a native PCM command")
assert slider.evaluate("el=>document.activeElement===el")
assert not errors,errors

def verify_external_output(page, out):
"""Actual /preview/ native WebView: select -> native ACK -> callback readback.

Expand Down Expand Up @@ -250,6 +330,9 @@ def main():
impact = browser.new_page(viewport={"width": 1366, "height": 768})
verify_socket_impact(impact, out)
impact.close()
inspector_page = browser.new_page(viewport={"width":1366,"height":900})
verify_inspector_rejected_gain(inspector_page,out)
inspector_page.close()
output_page = browser.new_page(viewport={"width":1366,"height":900})
verify_external_output(output_page,out)
output_page.close()
Expand Down
38 changes: 31 additions & 7 deletions web/approved-native-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,23 @@
if(state?.pending||!current?.admitted)return;
for(const [edgeId,edit] of pendingWireGains){
pendingWireGains.delete(edgeId);
if(current.identity!==edit.identity)continue; // never replay into a new graph/device
if(current.identity!==edit.identity){
// A changed device/graph invalidates a deferred edit, but must not
// strand its LCD while waiting for a nonexistent ACK.
scope?.rollbackNativeWireInspector?.(nativeWireGainReadback(current));
continue; // never replay into a new graph/device
}
const edge=current.graph.edges.find(e=>e.enabled&&e.edgeId===edgeId&&e.from===edit.source);
if(!edge||edge.primaryOutput!==false)continue;
if(Math.abs(edge.gainLinear-edit.gain)<.00001)continue;
if(!edge||edge.primaryOutput!==false){
scope?.rollbackNativeWireInspector?.(nativeWireGainReadback(current));
continue;
}
if(Math.abs(edge.gainLinear-edit.gain)<.00001){
// The accepted PCM gain already equals the requested scalar. Do not
// emit a redundant native intent, but DO settle the pending display.
scope?.syncNativeWireGains?.(nativeWireGainReadback(current));
continue;
}
const result=controller.intent("SET_WIRE_GAIN",edit.source,{edgeId,gainLinear:edit.gain});
if(result.ok)window.setTimeout(()=>controller?.expire(result.requestId),8000);
else status("WIRE gain rejected · "+result.error);
Expand Down Expand Up @@ -643,6 +656,14 @@
}
return true;
}
// One authoritative EdgeId gain projection for normal readback AND failure
// rollback. No duplicate DSP math or synthetic accepted control state.
function nativeWireGainReadback(next){
return (next?.graph?.edges||[]).filter(e=>e.enabled&&e.primaryOutput===false)
.map(e=>({id:uiByWireId.get(e.edgeId),pending:pendingWireGains.has(e.edgeId),
levelDb:Math.round(Math.max(-60,Math.min(6,
e.gainLinear>0?20*Math.log10(e.gainLinear):-60))*10)/10}));
}
function projectNativeGraphWithoutFocusLoss(next) {
// Only identity, order, processing width, source and edges are structural.
// Rack/slot bypass is applied in-place from independent readback below.
Expand All @@ -658,9 +679,7 @@
lastNativeTopologySignature=structure;
return true;
}
scope?.syncNativeWireGains?.(next.graph.edges.filter(e=>e.enabled&&e.primaryOutput===false)
.map(e=>({id:uiByWireId.get(e.edgeId),pending:pendingWireGains.has(e.edgeId),levelDb:Math.round(Math.max(-60,Math.min(6,
e.gainLinear>0?20*Math.log10(e.gainLinear):-60))*10)/10})));
scope?.syncNativeWireGains?.(nativeWireGainReadback(next));
// A SEND OFF is a scalar, NOT a disconnected WIRE. Update just the
// affected selected SOF strip; preserve fader focus and all plugin state.
for(const edge of next.graph.edges.filter(e=>e.enabled&&e.primaryOutput===false)){
Expand Down Expand Up @@ -2954,6 +2973,11 @@
state.current?.device?.epoch===wire.epoch&&deferStartupWire(wire.ops,1))return;
startupWire=null;
pendingWireGains.clear();
// The controller deliberately freezes current on a rejected ACK.
// Repaint only an inspector that still says PENDING from that
// admitted PCM readback, without a new intent, timer or graph edit.
if(state.current)
scope?.rollbackNativeWireInspector?.(nativeWireGainReadback(state.current));
if(pendingFxInsert?.authority==="CHANNEL_ID"){
pendingFxInsert=null;
nativeToast("VST3 insert rejected · "+state.lastError);
Expand All @@ -2966,7 +2990,7 @@
// Never destroy an active pointer capture. Once the user releases,
// restore only the last independently accepted native controls.
if(flags.acceptedGraphConnected && (scope.activeFaderId??-1)<0){
if(!scope.wireGainDragging && !document.activeElement?.matches?.(".strip select,.wire-gain"))
if(!scope.wireGainDragging && !document.activeElement?.matches?.(".strip select,.wire-gain,#wireWsGain"))
scope.render?.();
controller.subscribe();
if(state.current)paintNativeMeters(state.current);
Expand Down
Loading