RE
render-performance
Rules for implementing GPU-accelerated rendering (WebGL/WebGPU), optimizing canvas operations, and ensuring a stable 60fps UI for real-time music performance.
Install
mkdir -p .claude/skills/render-performance && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15791" && unzip -o skill.zip -d .claude/skills/render-performance && rm skill.zipInstalls to .claude/skills/render-performance
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Rules for implementing GPU-accelerated rendering (WebGL/WebGPU), optimizing canvas operations, and ensuring a stable 60fps UI for real-time music performance.158 charsno explicit “when” trigger
About this skill
Instructions
You are a Graphics Performance Engineer. Use this skill whenever you are modifying the rendering pipeline, adding new visualizations, or implementing high-frequency UI updates in the MixKit.
1. Frame Rate & Timing
- Strict 60fps Pursuit: All visual updates (waveforms, meters, spectrums) MUST use
requestAnimationFrame. Never usesetIntervalfor rendering. - Jank Prevention: Minimize "Long Tasks" (tasks > 50ms). If a calculation (like waveform generation) takes too long, offload it to a Web Worker.
- Delta Timing: If implementing time-based animations, use the
timestampprovided byrequestAnimationFrameto ensure consistent speed regardless of frame rate.
2. GPU Acceleration (WebGL/WebGPU)
- Batching: Minimize draw calls. In WebGL, batch vertex data into large buffers instead of making multiple
drawArrayscalls. - Shader Efficiency: Keep fragment shaders simple. Avoid complex branching logic inside the shader loops.
- Texture Management: When using album art or static waveforms as textures, resize them to "Power of Two" dimensions (e.g., 256x256) for better compatibility and performance.
3. Canvas 2D Optimizations (Legacy/Fallback)
- Offscreen Buffering: Large static elements (like the background waveform) should be rendered once to an offscreen canvas and copied using
drawImagein the main loop. - State Management: Minimize
context.save()andcontext.restore(). Manually reset properties if possible, as state saves are expensive. - Integer Coordinates: Use
Math.floor()orMath.round()on coordinates to prevent sub-pixel rendering, which triggers expensive anti-aliasing.
4. Memory & Garbage Collection
- Object Pooling: Reuse arrays and objects inside the
render()loop to avoid frequent garbage collection spikes. - Typed Arrays: Use
Float32ArrayorUint8Arrayfor audio and vertex data to ensure maximum memory efficiency. - Resource Cleanup: Explicitly delete WebGL buffers, textures, and programs when they are no longer needed to prevent GPU memory leaks.