diff --git a/docs/GUI-PERFORMANCE.md b/docs/GUI-PERFORMANCE.md new file mode 100644 index 0000000..f7c5a43 --- /dev/null +++ b/docs/GUI-PERFORMANCE.md @@ -0,0 +1,18 @@ +# ArSonComp GUI Performance — isolated LCD (2026-10-31) + +## User observation +Task Manager screenshot: 0.4% CPU, 46.4 MB process memory and 2.7% GPU at one instant. These are not host callback duration, continuous memory growth, nor proof of a memory leak. Audio stutter cannot be diagnosed from one Task Manager sample. + +## Change +- Split live graph/IN/GR/OUT into an **opaque child canvas**. Parent GUI paints the cached brushed chassis, toolbar and fixed hardware controls. Only the graph canvas receives continuous timer invalidation, preventing re-execution of the parent's text, material and header drawing every meter tick. +- Full canvas draws pre-rendered black LCD/grid plus actual signals/meters. MINI repaints only the 47px meter well. All image decoding and path generation remain on JUCE message thread. +- Preserve native threshold drag by forwarding graph canvas mouse coordinates to parent editor. APVTS automation and host callbacks remain untouched. +- Coalesce idle repaint requests when no new SPSC telemetry, no stopped-transport history ageing, and no perceptible meter decay. Keep the 30 Hz live visualization while active. +- Restore the intended 740×585 minimum / 780×640 default resize limits. No new audio worker, mutex, audio allocation, latency, DSP modification, or file I/O from processBlock. + +## Test gate +- Actual Windows VST3 + Standalone, JUCE GUI render screenshots at minimum/default/SIDECHAIN/MINI; engine-safety test on Linux. +- Editor smoke asserts the opaque child bounds at 740×585, 780×640 and MINI, plus restored FULL layout. +- Physical Windows interface/DAW comparison is still required for GUI on/off, same driver/buffer and 30–60-minute run; measure actual xrun counters and sustained CPU/GPU and memory, not Task Manager snapshot alone. + +Technical reference: JUCE developer ADC 2025 session on component hierarchy, opaque components, cached painting and avoiding repeated work in paint: https://conference.audio.dev/session/2025/understanding-juce-drawing/ diff --git a/plugin/Editor.cpp b/plugin/Editor.cpp index fbd6f9a..e92015c 100644 --- a/plugin/Editor.cpp +++ b/plugin/Editor.cpp @@ -321,6 +321,9 @@ Editor::Editor(Processor& p):AudioProcessorEditor(p),processor(p),alternate(p.sn k.setComponentID("param."+juce::String(spec.id)); k.onValueChange=[this,i] { if(hoveredParameter==i)updateHoverReadout(i); + if(i==arson::Threshold || i==arson::Ratio || + i==arson::Knee || i==arson::Range) + graphCanvas.repaint(); }; juce::String shortLabel=juce::String(spec.name).toUpperCase(); if(i==arson::Highpass) shortLabel="HP"; @@ -461,6 +464,7 @@ Editor::Editor(Processor& p):AudioProcessorEditor(p),processor(p),alternate(p.sn } }; addAndMakeVisible(compact); + addAndMakeVisible(graphCanvas); hoverReadout.setComponentID("view.value.readout"); hoverReadout.setFont(juce::FontOptions(11.0f)); hoverReadout.setColour(juce::Label::textColourId,accentBright); @@ -473,7 +477,7 @@ Editor::Editor(Processor& p):AudioProcessorEditor(p),processor(p),alternate(p.sn presets.setSelectedId(0,juce::dontSendNotification); presets.setText("Custom / restored",juce::dontSendNotification); setResizable(true,true); - setResizeLimits(860,700,1200,965); + setResizeLimits(740,585,1200,965); setSize(780,640); syncPanelVisibility(); startTimerHz(30); @@ -486,6 +490,33 @@ Editor::~Editor() { parameter->endChangeGesture(); setLookAndFeel(nullptr); } +void Editor::GraphCanvas::paint(juce::Graphics& g) { + if(owner.compactMode) { + if(owner.metalSurface.isValid()) + g.drawImageAt(owner.metalSurface,-getX(),-getY()); + else g.fillAll(juce::Colour{0xff0b1014}); + juce::Graphics::ScopedSaveState saved(g); + g.setOrigin(-getX(),-getY()); + owner.paintCompactMeters(g); + } else { + if(owner.grid.isValid())g.drawImageAt(owner.grid,0,0); + else g.fillAll(juce::Colour{0xff070b0d}); + owner.drawDisplay(g); + } +} +void Editor::GraphCanvas::mouseDown(const juce::MouseEvent& e) { + owner.mouseDown(e.getEventRelativeTo(&owner)); +} +void Editor::GraphCanvas::mouseDrag(const juce::MouseEvent& e) { + owner.mouseDrag(e.getEventRelativeTo(&owner)); +} +void Editor::GraphCanvas::mouseUp(const juce::MouseEvent& e) { + owner.mouseUp(e.getEventRelativeTo(&owner)); +} +void Editor::GraphCanvas::mouseMove(const juce::MouseEvent& e) { + owner.mouseMove(e.getEventRelativeTo(&owner)); + setMouseCursor(owner.getMouseCursor()); +} void Editor::setValue(std::size_t i,float value) { if(auto* parameter=processor.state.getParameter(arson::specs[i].id)) { parameter->beginChangeGesture(); @@ -601,6 +632,8 @@ void Editor::resized() { external.setBounds(detX+detW+8,bottomY+42,extW,30); listen.setBounds(detX+detW+extW+16,bottomY+42,listenW,30); const int readoutW=juce::jmin(254,w-40); + graphCanvas.setBounds(compactMode + ? juce::Rectangle{13,258,w-26,47} : display); hoverReadout.setBounds(compactMode?w-readoutW-14: display.getCentreX()-readoutW/2, compactMode?h-21:display.getBottom()-27,readoutW,18); @@ -703,6 +736,8 @@ void Editor::timerCallback() { outPeaks[i]=std::max(outPeaks[i],frame.outputChannel[i]); } } + const auto previousInput=inputDb,previousOutput=outputDb,previousGr=gr; + const auto previousInChannels=inChannelDb,previousOutChannels=outChannelDb; // Time-based visual smoothing: attack remains responsive (~18 ms) while // falloff is calm (~210 ms). No change to real detector or DSP latency. const double now=juce::Time::getMillisecondCounterHiRes(); @@ -730,8 +765,14 @@ void Editor::timerCallback() { std::max(1,static_cast(std::round(elapsed*100.0)))); } if(!compactMode && (received>0 || aged>0))rebuildHistoryPaths(); - if(compactMode)repaint(14,298,getWidth()-28,57); - else repaint(display); + bool meterChanged=std::abs(inputDb-previousInput)>0.03f || + std::abs(outputDb-previousOutput)>0.03f || + std::abs(gr-previousGr)>0.015f; + for(std::size_t i=0;i<2;++i) + meterChanged=meterChanged || + std::abs(inChannelDb[i]-previousInChannels[i])>0.03f || + std::abs(outChannelDb[i]-previousOutChannels[i])>0.03f; + if(received>0 || aged>0 || meterChanged)graphCanvas.repaint(); } void Editor::rebuildHistoryPaths() { @@ -831,10 +872,7 @@ void Editor::paint(juce::Graphics& g) { g.setColour(accent.withAlpha(0.68f)); g.fillRoundedRectangle(sidechainPanel?115.0f:17.0f, static_cast(bottomY+22),sidechainPanel?91.0f:88.0f,1.8f,1.0f); - if(!compactMode) { - if(grid.isValid())g.drawImageAt(grid,display.getX(),display.getY()); - drawDisplay(g); - } else paintCompactMeters(g); + // Cached chassis/header are static; the live LCD is an opaque child. g.setColour(text.withAlpha(0.66f)); g.setFont(juce::FontOptions(9.0f)); g.drawText("0 SAMPLES ADDED / REALTIME DSP", @@ -901,8 +939,8 @@ void Editor::drawMeter(juce::Graphics& g,juce::Rectangle bounds, } void Editor::drawDisplay(juce::Graphics& g) { juce::Graphics::ScopedSaveState save(g); - g.reduceClipRegion(display); - g.setOrigin(display.getPosition()); + g.reduceClipRegion(juce::Rectangle{0,0, + display.getWidth(),display.getHeight()}); const auto plot=plotBounds().translated(-static_cast(display.getX()), -static_cast(display.getY())); if(plot.isEmpty())return; @@ -1044,7 +1082,7 @@ void Editor::mouseDrag(const juce::MouseEvent& event) { parameter->setValueNotifyingHost(parameter->convertTo0to1(threshold)); hoveredParameter=arson::Threshold; updateHoverReadout(hoveredParameter); - repaint(display); + graphCanvas.repaint(); } void Editor::mouseUp(const juce::MouseEvent&) { if(!thresholdDragging)return; diff --git a/plugin/Editor.h b/plugin/Editor.h index fbb92fb..973fc0f 100644 --- a/plugin/Editor.h +++ b/plugin/Editor.h @@ -35,6 +35,20 @@ class Editor final : public juce::AudioProcessorEditor, private juce::Timer { void mouseMove(const juce::MouseEvent&) override; void mouseEnter(const juce::MouseEvent&) override; private: + class GraphCanvas final : public juce::Component { + public: + explicit GraphCanvas(Editor& p) : owner(p) { + setComponentID("view.graph.canvas"); + setOpaque(true); + } + void paint(juce::Graphics&) override; + void mouseDown(const juce::MouseEvent&) override; + void mouseDrag(const juce::MouseEvent&) override; + void mouseUp(const juce::MouseEvent&) override; + void mouseMove(const juce::MouseEvent&) override; + private: + Editor& owner; + }; void timerCallback() override; void applyPreset(int); void setValue(std::size_t,float); @@ -52,6 +66,7 @@ class Editor final : public juce::AudioProcessorEditor, private juce::Timer { CompLook look; std::array knobs; std::array labels; + GraphCanvas graphCanvas{*this}; juce::Label hoverReadout; std::size_t hoveredParameter=arson::Threshold; using SliderAttachment=juce::AudioProcessorValueTreeState::SliderAttachment; diff --git a/tests/PluginSmoke.cpp b/tests/PluginSmoke.cpp index 757f723..8bf8ed8 100644 --- a/tests/PluginSmoke.cpp +++ b/tests/PluginSmoke.cpp @@ -423,6 +423,12 @@ int main(int argc,char** argv) { // No floating tooltip obscures the hardware control strip. if(!slider->getTooltip().isEmpty())return 49; } + // Opaque live meter canvas isolates timer repaints from chassis. + auto* canvas=editor->findChildWithID("view.graph.canvas"); + const auto expectedCanvas=juce::Rectangle{ + 8,70,editor->getWidth()-16,editor->getHeight()-268}; + if(!canvas || !canvas->isVisible() || !canvas->isOpaque() || + canvas->getBounds()!=expectedCanvas)return 70; auto* readout=dynamic_cast( editor->findChildWithID("view.value.readout")); if(!readout || !readout->isVisible() || @@ -562,6 +568,8 @@ int main(int argc,char** argv) { if(!mini || !mini->onClick)return 10; mini->onClick(); if(editor->getHeight()!=330)return 11; + if(canvas->getBounds()!=juce::Rectangle{ + 13,258,editor->getWidth()-26,47})return 71; auto compactImage=editor->createComponentSnapshot(editor->getLocalBounds()); if(compactImage.isNull() || compactImage.getHeight()!=330)return 12; if(argc>1) { @@ -572,6 +580,9 @@ int main(int argc,char** argv) { } mini->onClick(); if(editor->getHeight()!=640)return 14; + if(canvas->getBounds()!=juce::Rectangle{ + 8,70,editor->getWidth()-16,editor->getHeight()-268}) + return 72; } auto image=editor->createComponentSnapshot(editor->getLocalBounds()); if(image.isNull())return 3;