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
19 changes: 16 additions & 3 deletions AR-MIX-Live-FX-Host-Standalone-v0.3.html
Original file line number Diff line number Diff line change
Expand Up @@ -1228,14 +1228,27 @@
const meterNodes=new Map();
// Shared preview/native painter: preserve fixed colors; light only whole 7px LEDs.
const LED_PITCH_PX=7,ledMeterCache=new WeakMap();
// Opt-in performance A/B: reproduce pre-P1 raw-level DOM writes, with the
// exact same meter visuals. Production only writes CSS on visible LED changes.
const meterRawStyleWrites=new URLSearchParams(location.search).get('mixperf')==='meter-raw';
function setLedMeterLevel(el,rawLevel){
if(!el)return;
const level=clamp(Number(rawLevel)||0,0,100);
let state=ledMeterCache.get(el);
if(!state){state={height:el.getBoundingClientRect().height,level:-1,lit:-1};ledMeterCache.set(el,state)}
if(state.level!==level){state.level=level;el.style.setProperty('--level',level+'%')}
const levelChanged=state.level!==level;
state.level=level; // Full precision remains cached for ResizeObserver / telemetry.
const lit=level>=100?state.height:Math.floor((level*state.height/100+1e-7)/LED_PITCH_PX)*LED_PITCH_PX;
if(state.lit!==lit){state.lit=lit;el.style.setProperty('--led-lit',lit+'px')}
if(state.lit!==lit){
state.lit=lit;
// --led-lit drives the clip; --level remains the compatible fallback,
// updated only when the visible whole-row LED state actually changes.
el.style.setProperty('--level',level+'%');
el.style.setProperty('--led-lit',lit+'px');
}else if(meterRawStyleWrites&&levelChanged){
// Diagnostics only: old unconditional raw-level style invalidation.
el.style.setProperty('--level',level+'%');
}
}
window.__arMixSetLedMeterLevel=setLedMeterLevel;
// Observe only the stable mixer root, never disposable strips; no hot-path reflow.
Expand Down Expand Up @@ -1589,7 +1602,7 @@
document.addEventListener('keydown',e=>{if(e.ctrlKey&&e.key.toLowerCase()==='s'){e.preventDefault();if(persistSession())flash('UI state saved locally');else flash('Browser storage unavailable')}});
// Issue #56: no pointer profiler/event listener runs in normal preview or native.
const mixperfParam=new URLSearchParams(location.search).get('mixperf');
const mixperfModes=['optimized','baseline','hover-off','meters-off','layers-off','all-off'];
const mixperfModes=['optimized','baseline','hover-off','meters-off','layers-off','all-off','meter-raw'];
const mixperfMode=mixperfModes.includes(mixperfParam)?mixperfParam:'optimized';
document.documentElement.dataset.mixperf=mixperfMode;
if(mixperfParam&&mixperfModes.includes(mixperfParam)){
Expand Down
32 changes: 32 additions & 0 deletions docs/ARD_056_GUI_RENDER_P1_DIRTY_DOM_2026-10-27.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# ARD-056 P1: dirty LED-paint and idle telemetry DOM writes

**Base:** `main@0dc201c556623a55348abbb93d8dbd0d1cf08cb4` (Orbit PR #94 merged). **Issue:** [#56](https://github.com/masarray/arsonmix/issues/56). User confirmed **slight** pointer improvement after PR #93; not a hardware acceptance or measured p95 result.

## Audit: actual source paths (cost remains unmeasured on user's PC)

| Trigger | Current source | Identified avoidable work | Remediation |
| --- | --- | --- | --- |
| Preview meter 40/60ms demo tick and native 12Hz status | `web/app.js::setLedMeterLevel` | Writes CSS `--level` on every changed raw level even if the quantized 7px `--led-lit` clip remains **identical** | Preserve float telemetry in JS cache; only write `--level` and `--led-lit` when the displayed whole-row clip changes; opt-in `meter-raw` reproduces old behavior |
| Native 12Hz status | `web/bridge.js` | Reassigns the same footer/audio labels each status event | Update those text nodes/data attribute only when changed |
| Native 12Hz status | `web/monitor.js::repaint` | Rewrites invariant header/status labels regardless of equality | Idempotent `setTextIfChanged` for static or slow-changing labels |
| FX Orbit (PR #94) | `web/bridge.js` | Animated path uses rAF **only when popover visible**, and normal live Orbit runs in native motion engine | Leave untouched; no competing animation scheduler introduced |
| Meter `clip-path` / static painted shadows | `40-rail-pan.css`, `20-button-180.css` | May cost compositing but no verified profiler trace or proof of dominant cost | Preserve artwork and physical pad; no blind Canvas merge or removal of seven resting/pressed shadows |

## Engineering decision

`--led-lit` is the primary authored meter clip variable. The `--level` fallback is retained, but normal-mode writes it only when the visible 7px LED count changes. Full-precision measured level remains in the `WeakMap` cache for accurate resize reconstruction; DSP peaks, CLIP latch, 1600ms peak-hold, native meter update frequency and all L/R semantics are untouched. `?mixperf=meter-raw` restores **just** the legacy per-raw-level write, so same-machine A/B separates this change from BTN-180/hover experiments. No new timer, Canvas renderer, layer hint, hot-path DOM lookup or CPU/DSP callback changes.

Native status idempotency is a separate non-visual reduction: compare existing text before assigning; do not suppress state transitions, diagnostic panel measurements or audio device indicators.

## Evidence and acceptance

Deterministic functional smoke tests call `setLedMeterLevel(e,1)` then `setLedMeterLevel(e,1.1)`; displayed 7px LED row is identical. In production style attribute must remain unchanged while cache retains raw 1.1; in explicit `meter-raw` mode the style attribute must change. Chromium/Firefox and Windows-native CI plus source/offline HTML JavaScript byte-parity required. A deterministic DOM mutation count proves redundant writes eliminated **only for identical quantized levels**, not GPU performance gain.

Physical benchmark still needed on affected Windows PC: repeat matched 10-second pointer sweeps in Perf Lab **optimized** vs **meter-raw** and optionally **meters-off**, record p95/p99 and >33ms frames, actual compositor paint/gpu/driver, matched DPI/resolution/monitor/RDP. No claim that pointer stutter is resolved or that meter-raw mode is an accurate reproduction of every earlier build. Issue #56 stays OPEN until physical gate.

## Rejected shortcuts

- Directly replace DOM clip bars with Canvas PR #60 absent same-device evidence.
- Degrade native meter update rate or L/R precision.
- Force GPU `will-change` on all LED elements.
- Rewrite Orbit PR #94, entire FX rack or audio callback for this unrelated GUI optimization.
2 changes: 1 addition & 1 deletion site/preview/perf.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<title>ArSonMix Mixer Performance Lab</title>
<style>*{box-sizing:border-box}body{margin:0;height:100dvh;display:flex;flex-direction:column;background:#101a22;color:#d5e8f1;font:12px Segoe UI,Arial,sans-serif}header{display:flex;gap:9px;align-items:center;flex-wrap:wrap;padding:9px 13px;background:#192b38;border-bottom:1px solid #395261}b{font-size:14px;color:#80e7c0}select,button{padding:7px 9px;border:1px solid #527789;border-radius:4px;color:#e3f4fa;background:#243946;font:inherit}button{cursor:pointer}button:disabled{opacity:.5}iframe{flex:1;min-height:220px;width:100%;border:0}aside{padding:7px 13px;color:#a0becc;background:#142630;font-size:11px}pre{margin:0;padding:9px 13px;max-height:110px;overflow:auto;background:#09131a;white-space:pre-wrap;font:11px Consolas,monospace}a{color:#8edaf4}</style></head><body>
<header><b>ArSonMix · Mixer Perf Lab</b><label for="mode">A/B</label>
<select id="mode"><option value="optimized">Optimized (default)</option><option value="baseline">Baseline (old hover + GPU hints)</option><option value="hover-off">Hover off (old GPU hints)</option><option value="meters-off">Meters paused (old hover + GPU hints)</option><option value="layers-off">Layer hint off (old hover)</option><option value="all-off">All off (hover, meters, hint)</option></select>
<select id="mode"><option value="optimized">Optimized (default)</option><option value="baseline">Baseline (old hover + GPU hints)</option><option value="hover-off">Hover off (old GPU hints)</option><option value="meters-off">Meters paused (old hover + GPU hints)</option><option value="layers-off">Layer hint off (old hover)</option><option value="all-off">All off (hover, meters, hint)</option><option value="meter-raw">Meter raw DOM writes (P0 comparison)</option></select>
<button id="record">Record 10s</button><button id="copy" disabled>Copy JSON</button>
<a id="direct" target="_blank" rel="noopener">Open direct mixer</a><span id="status">Loading…</span></header>
<aside>Move mouse over FX inserts, fader caps and PAN during 10s; also move over toolbar as control. Repeat each mode 2–3 times. The meter demo is not real audio.</aside>
Expand Down
9 changes: 9 additions & 0 deletions tests/gui_workflow_contract_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,12 @@ test('native bridge does not inspect idle pointer movement',()=>{
assert.ok(!guard.includes('"pointermove"'), 'idle pointer listener forbidden');
assert.ok(guard.includes('typeof drag') && guard.includes('"pointerup"') && guard.includes('"pointercancel"'));
});

test('quantised LED meter avoids redundant raw CSS writes while preserving diagnostics',()=>{
assert.ok(app.includes('meterRawStyleWrites=new URLSearchParams(location.search)'));
assert.ok(app.includes('if(state.lit!==lit)'));
assert.ok(app.includes('else if(meterRawStyleWrites&&levelChanged)'));
assert.ok(app.includes("'meter-raw'"));
assert.ok(monitor.includes('const setTextIfChanged='));
assert.ok(bridge.includes('footer.textContent!==text'));
});
11 changes: 10 additions & 1 deletion tests/ui_firefox_perf_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,23 @@ async def main():
assert await page.evaluate('window.__arMixPerfProbe === undefined'), "No profiler in normal mode"
await page.close()

for mode in ("optimized", "meters-off", "all-off"):
for mode in ("optimized", "meters-off", "all-off", "meter-raw"):
page = await browser.new_page(viewport={"width": 1440, "height": 820})
page.on("pageerror", lambda error: errors.append(str(error)))
await page.goto(PAGE + "?mixperf=" + mode)
await page.wait_for_selector('[data-fader="master"] .cap')
assert await page.locator('#mixer [data-fader]').count() == 11
assert await page.locator('#mixer [data-meter]').count() == 16
assert await page.locator('#mixer [data-clip]').count() == 16
dirty = await page.evaluate("""() => {
const el=document.querySelector('[data-meter="0"]');
setLedMeterLevel(el,1);
const first=el.getAttribute('style');
setLedMeterLevel(el,1.1);
return {changed:first!==el.getAttribute('style'),
raw:ledMeterCache.get(el).level};
}""")
assert dirty == {"changed":mode=="meter-raw","raw":1.1}, (mode,dirty)

heads = await page.evaluate("""() => {
const c = document.querySelector('[data-fader="0"] .cap');
Expand Down
10 changes: 10 additions & 0 deletions tests/ui_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ def shared_shadow_shape(shadow):
assert all(x['palette']==meter['first']['palette'] for x in levels),levels
assert all(x['lit']<=.9*x['height'] for x in levels[:4]),levels
assert levels[-1]['lit']>.9*levels[-1]['height'],levels
# The visible LED row must be the only normal-mode CSS mutation gate.
# Two nearby raw levels with the same lit 7px row must not repaint.
dirty=await page.evaluate("""()=>{
const e=document.querySelector('[data-meter="0"]');
setLedMeterLevel(e,1);
const before=e.getAttribute('style'),lit=e.style.getPropertyValue('--led-lit');
setLedMeterLevel(e,1.1);
return {before,after:e.getAttribute('style'),lit,level:ledMeterCache.get(e).level};
}""")
assert dirty['before']==dirty['after'] and dirty['level']==1.1,dirty
# Full mixer rebuild must restore held peaks and clip state on fresh DOM nodes.
restored=await page.evaluate("""()=>{
clipLatch['0']=true;
Expand Down
19 changes: 16 additions & 3 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,27 @@ function syncClipLeds(){document.querySelectorAll('[data-clip]').forEach(e=>e.cl
const meterNodes=new Map();
// Shared preview/native painter: preserve fixed colors; light only whole 7px LEDs.
const LED_PITCH_PX=7,ledMeterCache=new WeakMap();
// Opt-in performance A/B: reproduce pre-P1 raw-level DOM writes, with the
// exact same meter visuals. Production only writes CSS on visible LED changes.
const meterRawStyleWrites=new URLSearchParams(location.search).get('mixperf')==='meter-raw';
function setLedMeterLevel(el,rawLevel){
if(!el)return;
const level=clamp(Number(rawLevel)||0,0,100);
let state=ledMeterCache.get(el);
if(!state){state={height:el.getBoundingClientRect().height,level:-1,lit:-1};ledMeterCache.set(el,state)}
if(state.level!==level){state.level=level;el.style.setProperty('--level',level+'%')}
const levelChanged=state.level!==level;
state.level=level; // Full precision remains cached for ResizeObserver / telemetry.
const lit=level>=100?state.height:Math.floor((level*state.height/100+1e-7)/LED_PITCH_PX)*LED_PITCH_PX;
if(state.lit!==lit){state.lit=lit;el.style.setProperty('--led-lit',lit+'px')}
if(state.lit!==lit){
state.lit=lit;
// --led-lit drives the clip; --level remains the compatible fallback,
// updated only when the visible whole-row LED state actually changes.
el.style.setProperty('--level',level+'%');
el.style.setProperty('--led-lit',lit+'px');
}else if(meterRawStyleWrites&&levelChanged){
// Diagnostics only: old unconditional raw-level style invalidation.
el.style.setProperty('--level',level+'%');
}
}
window.__arMixSetLedMeterLevel=setLedMeterLevel;
// Observe only the stable mixer root, never disposable strips; no hot-path reflow.
Expand Down Expand Up @@ -396,7 +409,7 @@ document.addEventListener('keydown',e=>{const pan=e.target.closest('[data-pan]')
document.addEventListener('keydown',e=>{if(e.ctrlKey&&e.key.toLowerCase()==='s'){e.preventDefault();if(persistSession())flash('UI state saved locally');else flash('Browser storage unavailable')}});
// Issue #56: no pointer profiler/event listener runs in normal preview or native.
const mixperfParam=new URLSearchParams(location.search).get('mixperf');
const mixperfModes=['optimized','baseline','hover-off','meters-off','layers-off','all-off'];
const mixperfModes=['optimized','baseline','hover-off','meters-off','layers-off','all-off','meter-raw'];
const mixperfMode=mixperfModes.includes(mixperfParam)?mixperfParam:'optimized';
document.documentElement.dataset.mixperf=mixperfMode;
if(mixperfParam&&mixperfModes.includes(mixperfParam)){
Expand Down
30 changes: 22 additions & 8 deletions web/bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
const percent = peak => Math.max(1,Math.min(100,(20*Math.log10(Math.max(1e-6,Number(peak)||0))+60)*100/60));
const toStatus = text => {
const footer = document.querySelector("#audioStatus");
if(footer) footer.textContent = text;
if(footer && footer.textContent!==text) footer.textContent = text;
};

// The v0.3 cosmetic demo catalog and FX editor are replaced with the REAL
Expand Down Expand Up @@ -972,7 +972,11 @@
state.monitor=!!d.monitor;
syncNativeMixerControls(d);
const b=document.querySelector('[data-native-action="monitor"]');
if(b){b.textContent=state.monitor?"MUTE OUTPUT":"UNMUTE OUTPUT";b.classList.toggle("on",!state.monitor);}
if(b){
const label=state.monitor?"MUTE OUTPUT":"UNMUTE OUTPUT";
if(b.textContent!==label)b.textContent=label;
b.classList.toggle("on",!state.monitor);
}
const text=d.error?"AUDIO ERROR: "+d.error:
d.connected?`${d.driver} · ${Math.round(d.rate)} Hz / ${d.buffer} · ${state.chain.length} LIVE VST3 · ${d.latencySamples||0} samples FX latency`
:"NO AUDIO DEVICE · SELECT AUDIO SETUP";
Expand All @@ -995,26 +999,36 @@
paintMeter(aux,liveOutputLevel);
// Design-only LUFS/true-peak fields have no native measurement yet.
const lufs=document.getElementById("masterLufs"),tp=document.getElementById("masterDbtp");
if(lufs)lufs.textContent="—";
if(tp)tp.textContent="—";
if(lufs&&lufs.textContent!=="—")lufs.textContent="—";
if(tp&&tp.textContent!=="—")tp.textContent="—";
// v0.8 Master stream LUFS-I/dBTP remains unimplemented; values stay
// em dashes rather than falsely claiming measured loudness.
const pk=document.getElementById("masterPeakDb");
if(pk)pk.textContent=Number(d.peak)>0
?(20*Math.log10(Math.max(1e-8,Number(d.peak)))).toFixed(1)+" dBFS":"−∞";
const driver=document.getElementById("headerDriver");
if(driver)driver.textContent=d.driver||"No device";
if(driver){
const label=d.driver||"No device";
if(driver.textContent!==label)driver.textContent=label;
}
// Preserve the latest main native device lamp.
const deviceButton=document.querySelector(".toolbar .spec-device");
if(deviceButton){
const ready=!!d.connected && !d.error;
deviceButton.classList.toggle("on",ready);
deviceButton.dataset.audioConnected=String(ready);
if(deviceButton.dataset.audioConnected!==String(ready))
deviceButton.dataset.audioConnected=String(ready);
}
const rate=document.getElementById("headerRate");
if(rate)rate.textContent=d.rate?(Number(d.rate)/1000).toLocaleString("en-US",{maximumFractionDigits:1}):"--";
if(rate){
const label=d.rate?(Number(d.rate)/1000).toLocaleString("en-US",{maximumFractionDigits:1}):"--";
if(rate.textContent!==label)rate.textContent=label;
}
const buffer=document.getElementById("headerBuffer");
if(buffer)buffer.textContent=d.buffer||"--";
if(buffer){
const label=String(d.buffer||"--");
if(buffer.textContent!==label)buffer.textContent=label;
}
});
backend.addEventListener("arMixScanProgress",p=>{
state.progress=p;
Expand Down
Loading
Loading