Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a37b9ba
perf(gui): optional single-canvas preview meter renderer for A/B
masarray Oct 26, 2026
795e976
style(gui): isolate canvas meter mode without changing faders
masarray Oct 26, 2026
5dea3cb
perf(lab): add DOM-vs-canvas comparison variant
masarray Oct 26, 2026
c9db974
test(gui): canvas compositor geometry/render/clip and mode regression
masarray Oct 26, 2026
3637b30
build(gui): compile isolated canvas meter diagnostic CSS
masarray Oct 26, 2026
dfa36da
build(gui): sync experimental canvas meters with standalone and WebVi…
masarray Oct 26, 2026
72c1a19
docs(gui): phase 2 DOM vs canvas hypothesis, guardrails and FAT plan
masarray Oct 26, 2026
6aecf64
test(gui): exercise experimental meter canvas in actual Firefox
masarray Oct 26, 2026
1a752f2
ci(gui): validate experimental Canvas2D mixer meters in Firefox
masarray Oct 26, 2026
c30863d
fix(gui): synchronize canvas visibility immediately with selected mix…
masarray Oct 26, 2026
0f31578
build(gui): keep offline HTML in parity with instantaneous canvas vie…
masarray Oct 26, 2026
72a7909
fix(gui): restore DOM meters on Canvas2D failure
masarray Oct 26, 2026
7999ab2
style(gui): activate canvas-only visibility after context success
masarray Oct 26, 2026
9c01b53
test(gui): verify failure fallback with mocked unavailable Canvas2D
masarray Oct 26, 2026
c125b51
test(firefox): verify actual canvas activation
masarray Oct 26, 2026
885b763
test(gui): verify canvas stops DOM style writes after activation
masarray Oct 26, 2026
c86200b
build(gui): synchronize fail-closed canvas activation CSS
masarray Oct 26, 2026
79eea05
build(gui): synchronize fail-safe Canvas2D fallback and A/B runtime
masarray Oct 26, 2026
9365e62
test(gui): expose Canvas2D init-mock diagnostics instead of opaque ti…
masarray Oct 26, 2026
c142288
test(gui): deterministically exercise context-null failure after file…
masarray Oct 26, 2026
bbb578d
fix(gui): release compositor overlay and observers on canvas loss or …
masarray Oct 26, 2026
889dbb4
build(gui): keep standalone synchronized with canvas fallback lifecycle
masarray Oct 26, 2026
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: 4 additions & 0 deletions .github/workflows/ui-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ jobs:
run: python tests/pan_button_asset_test.py
- name: Run mixer UI smoke tests
run: python tests/ui_smoke.py
- name: Install Firefox for compositor functional regression
run: python -m playwright install --with-deps firefox
- name: Verify Firefox Canvas2D meter A/B mode
run: python tests/ui_firefox_perf_smoke.py
- name: Attach visual regression screenshots
if: always()
uses: actions/upload-artifact@v4
Expand Down
127 changes: 122 additions & 5 deletions AR-MIX-Live-FX-Host-Standalone-v0.3.html
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,15 @@
html:is([data-mixperf="baseline"],[data-mixperf="hover-off"],[data-mixperf="meters-off"]) #app .meter .meter-fill{will-change:transform}
html:is([data-mixperf="hover-off"],[data-mixperf="all-off"]) #mixer :is(.fader:hover .cap,.pan-track:hover .pan-thumb,.rack .insert:hover,.rack .fx-power:hover,.strip-name:hover,.master-insert:hover,.master-tools button:hover){filter:none!important;transition:none!important}
html:is([data-mixperf="hover-off"],[data-mixperf="all-off"]) #mixer .strip-name:hover{outline:none!important}

/* Issue #56 phase 2: optional canvas-vs-DOM meter compositor experiment.
Native never enables this mode. Keep the full 13-strip/control geometry. */
html[data-mixcanvas="active"] #app .workbench{position:relative}
html[data-mixcanvas="active"] #app .meter :is(.meter-fill,.meter-peak){visibility:hidden}
#app .workbench > .mix-meter-canvas{
position:absolute;inset:0;width:100%;height:100%;
z-index:3;pointer-events:none;user-select:none;
}
</style></head>
<body>
<div id="app" class="app">
Expand Down Expand Up @@ -1054,15 +1063,15 @@
const levelStep=Math.round(value*10);
if(meter.level!==levelStep){
meter.level=levelStep;
meter.fill.style.setProperty('--meter-scale',String(levelStep/1000));
if(!meterCanvasState.ctx)meter.fill.style.setProperty('--meter-scale',String(levelStep/1000));
}
const previous=peakHold[key];
if(!previous||value>=previous.value||now>=previous.until){
peakHold[key]={value,until:now+1600};
const step=Math.round(value*10);
if(meter.peak&&meter.peakValue!==step){
meter.peakValue=step;
meter.peak.style.bottom=(step/10)+'%';
if(!meterCanvasState.ctx)meter.peak.style.bottom=(step/10)+'%';
}
}
if(value>=97&&!clipLatch[key]){
Expand Down Expand Up @@ -1145,7 +1154,7 @@
function renderMixer(){
const x=$('mixer'),scroll=x.scrollLeft;
x.innerHTML=channels.map(makeStrip).join('')+'<article id="masterLeft" class="strip master-strip '+(masterSelected?'selected':'')+'" aria-label="Stereo master channel"></article>';
renderMaster();x.scrollLeft=scroll;createSide();
renderMaster();x.scrollLeft=scroll;createSide();invalidateMeterCanvas();
}
let masterGain=-.1,masterPan=0,masterMute=false,phones=-12,masterInserts=['Studio EQ','Brickwall Limiter'],masterBypassed={},pendingMasterSlot=null;
function masterFxRows(){
Expand Down Expand Up @@ -1193,14 +1202,16 @@
</div>
<div class="fader-tools master-tools"><span class="master-route-label">MAIN L/R</span><button type="button" class="btn-180" data-clear-all-clips="1" title="Reset latched clips">CLEAR CLIP</button></div>
<div class="strip-name master-strip-name" role="group" aria-label="Master output"><span class="strip-caption">MASTER</span><span class="track-icon" aria-hidden="true"><svg viewBox="0 0 24 24" width="19" height="19" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="m11 5-5 4H3v6h3l5 4V5Z"/><path d="M15 9a5 5 0 0 1 0 6M18 6a9 9 0 0 1 0 12"/></svg></span></div>`;
syncClipLeds();
syncClipLeds();invalidateMeterCanvas();
}
function setView(next){
if(next!=='MIX'&&next!=='FX RACK'&&next!=='SIGNAL FLOW')return;
view=next;
document.querySelectorAll('[data-view]').forEach(btn=>btn.classList.toggle('selected',btn.dataset.view===next));
$('mixer').classList.toggle('hidden',next!=='MIX');
$('rackWorkspace').classList.toggle('hidden',!['FX RACK','SIGNAL FLOW'].includes(next));
// Canvas is an overlay sibling of #mixer: hide it immediately on view switch.
if(meterCanvasState.canvas)meterCanvasState.canvas.classList.toggle('hidden',next!=='MIX');
if(next==='FX RACK')renderRackWorkspace();
if(next==='SIGNAL FLOW')renderSignalFlow();
}
Expand Down Expand Up @@ -1343,7 +1354,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','canvas'];
const mixperfMode=mixperfModes.includes(mixperfParam)?mixperfParam:'optimized';
document.documentElement.dataset.mixperf=mixperfMode;
if(mixperfParam&&mixperfModes.includes(mixperfParam)){
Expand Down Expand Up @@ -1378,6 +1389,111 @@
},ms));
}};
}
/* Experimental, browser-preview-only single-surface meter renderer (Issue #56).
It draws the 12 channel + 2 master meters into ONE transparent canvas.
DOM clip buttons and native JUCE metering remain the owners of interaction
and true audio telemetry. No pointer handler or canvas exists in normal GUI. */
const meterCanvasState={canvas:null,ctx:null,failed:false,entries:[],tiles:new Map(),invalid:true,
dpr:1,width:0,height:0,draws:0,resizeObserver:null};
function invalidateMeterCanvas(){meterCanvasState.invalid=true}
function restoreDomMeterFallback(){
const state=meterCanvasState;
state.failed=true;state.ctx=null;
delete document.documentElement.dataset.mixcanvas;
state.canvas?.remove();state.canvas=null;
state.resizeObserver?.disconnect();state.resizeObserver=null;
$('mixer')?.removeEventListener('scroll',invalidateMeterCanvas);
window.removeEventListener('resize',invalidateMeterCanvas);
// Restore last measured levels and held peaks immediately after context loss.
for(const [key,node] of meterNodes){
if(!node.fill.isConnected)continue;
if(node.level>=0)node.fill.style.setProperty('--meter-scale',String(node.level/1000));
const held=peakHold[key];
if(held&&node.peak)node.peak.style.bottom=(Math.round(held.value*10)/10)+'%';
}
}
function meterCanvasTile(w,h){
const state=meterCanvasState,key=w+'x'+h,existing=state.tiles.get(key);
if(existing)return existing;
const tile=document.createElement('canvas');tile.width=w;tile.height=h;
const context=tile.getContext('2d',{alpha:true});
if(!context){restoreDomMeterFallback();return null;}
const gradient=context.createLinearGradient(0,h,0,0);
for(const [at,color] of [[0,'#33f17d'],[.43,'#78f65f'],[.69,'#d6ec36'],
[.85,'#ffe133'],[1,'#ff6540']])gradient.addColorStop(at,color);
context.fillStyle=gradient;context.fillRect(0,0,w,h);
context.fillStyle='rgba(0,0,0,.60)';
for(let y=h-7;y>=-2;y-=7)context.fillRect(0,y,w,2);
state.tiles.set(key,tile);return tile;
}
function prepareMeterCanvas(){
if(mixperfMode!=='canvas'||window.__JUCE__?.backend?.emitEvent||meterCanvasState.failed)return false;
const state=meterCanvasState,host=$('mixer')?.parentElement;
if(!host)return false;
if(!state.canvas){
const canvas=document.createElement('canvas');
canvas.className='mix-meter-canvas';
canvas.setAttribute('aria-hidden','true');
host.append(canvas);
state.canvas=canvas;
state.ctx=canvas.getContext('2d',{alpha:true});
if(!state.ctx){canvas.remove();state.canvas=null;restoreDomMeterFallback();return false}
document.documentElement.dataset.mixcanvas='active';
canvas.addEventListener('contextlost',e=>{e.preventDefault();restoreDomMeterFallback()});
if('ResizeObserver' in window){
state.resizeObserver=new ResizeObserver(invalidateMeterCanvas);
state.resizeObserver.observe(host);
}
$('mixer').addEventListener('scroll',invalidateMeterCanvas,{passive:true});
window.addEventListener('resize',invalidateMeterCanvas,{passive:true});
}
state.canvas.classList.toggle('hidden',view!=='MIX');
if(view!=='MIX')return false;
const dpr=Math.min(window.devicePixelRatio||1,2);
const width=host.clientWidth,height=host.clientHeight;
if(width<=0||height<=0)return false;
if(width!==state.width||height!==state.height||dpr!==state.dpr){
state.width=width;state.height=height;state.dpr=dpr;
state.canvas.width=Math.ceil(width*dpr);
state.canvas.height=Math.ceil(height*dpr);
state.ctx.setTransform(dpr,0,0,dpr,0,0);
state.invalid=true;
}
if(state.invalid||state.entries.some(e=>!e.fill.isConnected)){
const hostRect=host.getBoundingClientRect();
state.entries=[...$('mixer').querySelectorAll('.meter-fill')].map(fill=>{
const slot=fill.closest('.meter'),box=slot.getBoundingClientRect();
// offsetTop/Left read the *untransformed* meter geometry once per rebuild.
return {key:fill.dataset.meter,fill,x:box.left-hostRect.left-host.clientLeft+fill.offsetLeft,
y:box.top-hostRect.top-host.clientTop+fill.offsetTop,
w:fill.offsetWidth,h:fill.offsetHeight,
peakBottom:box.bottom-hostRect.top-host.clientTop,peakH:box.height};
});
state.invalid=false;
}
return true;
}
function paintPreviewMeterCanvas(){
if(!prepareMeterCanvas())return;
const state=meterCanvasState,ctx=state.ctx;
ctx.clearRect(0,0,state.width,state.height);
for(const e of state.entries){
if(e.x+e.w<0||e.x>state.width||e.y+e.h<0||e.y>state.height)continue;
const node=meterNodes.get(e.key);
if(!node||!node.fill.isConnected)continue;
const value=Math.max(0,Math.min(1,node.level/1000));
if(value>0){
const tile=meterCanvasTile(Math.max(1,e.w),Math.max(1,e.h));
if(tile)ctx.drawImage(tile,e.x,e.y+e.h*(1-value),e.w,e.h*value);
}
const held=peakHold[e.key];
if(held){
const peakY=e.peakBottom-e.peakH*(held.value/100)-2;
ctx.fillStyle='#fb5b50';ctx.fillRect(e.x,peakY,e.w,2);
}
}
state.draws++;
}
let lastMeterFrame=0;function meters(t){
// JUCE desktop reads actual audio meters; browser demo only animates a preview.
if(window.__JUCE__?.backend?.emitEvent)return;
Expand All @@ -1387,6 +1503,7 @@
const base=clamp(67+Math.sin(t*.002)*15,8,95);
const l=clamp(base+Math.sin(t*.003)*6,3,99),r=clamp(base-5+Math.sin(t*.003+1)*7,3,99);
updateMeterVisual('masterL',masterMute?2:l,t);updateMeterVisual('masterR',masterMute?2:r,t);
if(mixperfMode==='canvas')paintPreviewMeterCanvas();
// UI demonstration only. These values are never from a true-peak or loudness meter.
const lufs=$('masterLufs'),tp=$('masterDbtp');
if(lufs)lufs.textContent=(-31+(l+r)/11).toFixed(1);
Expand Down
21 changes: 21 additions & 0 deletions docs/MIXER_POINTER_PERF_PHASE2_20261026.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Issue #56 — Phase 2: single-canvas preview meter A/B and Firefox coverage

**Status:** experimental rendering candidate; default `optimized` remains DOM-based until the affected Firefox/Windows machine proves an improvement. This does not touch native ASIO/WASAPI/DSP, JUCE metering or the real-time audio callback.

## Engineering hypothesis
The browser GUI still mutates 14 individual meter DOM bars around 25 Hz. On some Firefox GPU/driver paths the combination of multiple CSS filter layers and continuous repaint/compositing may contend with pointer feedback. The earlier lighter-hover + selective layer work (#58) did not yet establish causality. Replacing these 14 animated DOM bars with one transparent preview-only Canvas2D drawing surface is a bounded experiment, **not** a performance claim.

## Implementation
- `?mixperf=canvas` explicitly enables `paintPreviewMeterCanvas()`: one transparent canvas overlay within the workbench, `pointer-events:none`. The 12 channel and stereo master bars use cached meter rectangles measured once per redraw/scroll/resize. Bar gradients/stripes are rendered once per unique geometry and reused with `drawImage`. Peak-hold tick positions are drawn into the same canvas. The original 14 `[data-meter]` and peak elements stay in the DOM (only hidden visually in canvas mode), preserving geometry and clip-latch buttons.
- JS meter values and 1600ms peak-hold logic are shared with the DOM path. Canvas mode skips per-meter `style.setProperty('--meter-scale')` and per-peak `style.bottom` writes, but retains `clipLatch` semantics and the master simulated LUFS-I/dBTP labels.
- Cache invalidation happens on `renderMixer`, `renderMaster`, workbench resize and mixer horizontal scroll, not on every frame. Canvas is hidden outside MIX and is created **only** when the explicit URL flag is set and there is no native JUCE backend.
- No change to approved silver/red metallic fader art, Button 19, Button 180, rack power, PAN center detent, layouts, channel/master DSP or native meter bridge. The original DOM meter is still the default and fallback if canvas initialization fails.
- `site/preview/perf.html` gains **Canvas** as a seventh comparison mode. Use the existing recorder to compare `optimized` (DOM) vs `canvas` on **identical Firefox hardware**.

## Verification
- `python scripts/build_ui_css.py --check` and existing Chromium screenshot/geometry/drag/preset tests.
- Chromium Canvas functional smoke verifies 14 meter mappings, a painted canvas, unchanged CLIP targets, suppressed DOM meter style writes, and correct view switching.
- Dedicated Playwright Firefox smoke verifies actual Firefox Canvas2D rendering and switching, without hard-coded FPS gains. CI is Linux/headless: it **cannot** certify the Windows Firefox/GPU improvement.

## Next decision
Collect at least 3 paired 10-second recordings for `optimized` and `canvas` (same device, similar pointer movement, record full JSON with p95 and over33Ms). Check for perceptual smoothness alongside Firefox Profiler paint / compositor trace. If Canvas consistently lowers p95/dropped frames without visual mismatch, promote to browser-preview default in a separate reviewed PR. If Canvas performs worse, keep DOM as default and investigate WebRender software fallback or image/filter cache behavior. Issue #56 remains open until evidence arrives.
4 changes: 2 additions & 2 deletions site/preview/perf.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<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="canvas">Canvas · one meter surface (experimental)</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>
<aside>Move mouse over FX inserts, fader caps and PAN during 10s; also move over toolbar as control. Repeat each mode 2–3 times. Canvas mode replaces 14 animated DOM bars with one preview-only canvas. The meter demo is not real audio.</aside>
<iframe id="mixer" title="ArSonMix full-size performance comparison"></iframe>
<pre id="report">No measurements. rAF frame intervals are diagnostic proxies; browser graphics profiling is still required.</pre>
<script>
Expand Down
52 changes: 52 additions & 0 deletions tests/ui_firefox_perf_smoke.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""Firefox functional coverage for Issue #56 Canvas vs DOM mixer meter mode.

Headless Linux verifies correctness, NOT FPS improvement on Windows hardware.
"""
from pathlib import Path
import asyncio
from playwright.async_api import async_playwright

ROOT=Path(__file__).resolve().parents[1]
PAGE=(ROOT/"AR-MIX-Live-FX-Host-Standalone-v0.3.html").as_uri()

async def main():
async with async_playwright() as pw:
browser=await pw.firefox.launch(headless=True)
try:
page=await browser.new_page(viewport={"width":1440,"height":820})
errors=[]
page.on("pageerror",lambda e:errors.append(str(e)))
await page.goto(PAGE+"?mixperf=canvas")
await page.wait_for_function("""()=>meterCanvasState.draws>=2 &&
meterCanvasState.entries.length===14""",timeout=15000)
data=await page.evaluate("""()=>{
const c=meterCanvasState.canvas;
let alpha=0,ctx=c.getContext('2d');
const d=ctx.getImageData(0,0,c.width,c.height).data;
for(let n=3;n<d.length;n+=4)if(d[n]){alpha++;if(alpha>8)break}
return {mode:mixperfMode,meters:meterCanvasState.entries.length,
drawn:meterCanvasState.draws,alpha,clips:document.querySelectorAll('#mixer [data-clip]').length,
visible:getComputedStyle(document.querySelector('[data-meter="0"]')).visibility}
}""")
assert data["mode"]=="canvas" and data["meters"]==14 and data["alpha"]>0,data
assert data["clips"]==14 and data["visible"]=="hidden",data
assert await page.evaluate("document.documentElement.dataset.mixcanvas")=='active'
await page.locator('[data-view="FX RACK"]').click()
assert await page.locator(".mix-meter-canvas").is_hidden()
await page.locator('[data-view="MIX"]').click()
await page.wait_for_function("""()=>meterCanvasState.canvas &&
!meterCanvasState.canvas.classList.contains('hidden')""")
await page.close()
ordinary=await browser.new_page(viewport={"width":1440,"height":820})
await ordinary.goto(PAGE)
await ordinary.wait_for_function("""()=>document.querySelectorAll('#mixer [data-meter]').length===14""")
assert await ordinary.locator(".mix-meter-canvas").count()==0
assert await ordinary.evaluate("mixperfMode")=="optimized"
assert not errors,errors
await ordinary.close()
finally:
await browser.close()
print("PASS: Firefox Canvas2D renders 14 demo meters, preserves 14 clip targets and default DOM fallback")

if __name__=="__main__":
asyncio.run(main())
Loading
Loading