`;
- syncClipLeds();
+ syncClipLeds();invalidateMeterCanvas();
}
function setView(next){
if(next!=='MIX'&&next!=='FX RACK'&&next!=='SIGNAL FLOW')return;
@@ -1201,6 +1210,8 @@
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();
}
@@ -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)){
@@ -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;
@@ -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);
diff --git a/docs/MIXER_POINTER_PERF_PHASE2_20261026.md b/docs/MIXER_POINTER_PERF_PHASE2_20261026.md
new file mode 100644
index 000000000..a584a13c8
--- /dev/null
+++ b/docs/MIXER_POINTER_PERF_PHASE2_20261026.md
@@ -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.
diff --git a/site/preview/perf.html b/site/preview/perf.html
index be42c9530..47abe3848 100644
--- a/site/preview/perf.html
+++ b/site/preview/perf.html
@@ -2,10 +2,10 @@
ArSonMix Mixer Performance LabArSonMix · Mixer Perf Lab
-
+
Open direct mixerLoading…
-
+
No measurements. rAF frame intervals are diagnostic proxies; browser graphics profiling is still required.