/palladius-public-goodies:raspberry-pi-game-optimizationfrom palladius-public-goodies
Optimizes Web, Flutter/CanvasKit, HTML5 Canvas2D, and Three.js/WebGL games for Raspberry Pi 400 and low-end ARM64 SBCs. Covers hardware constraints, WebKit2GTK fixes, texture downscaling, and zero-idle-CPU design.
Ships in palladius-public-goodies. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Use this skill whenever building, auditing, or optimizing web games (Flutter Web / CanvasKit, HTML5 Canvas 2D, Three.js / WebGL, or WebAssembly TUIs) so they are Raspberry-Compliant and run at 30–60 FPS with 0% idle CPU on a Raspberry Pi 400 (or Raspberry Pi 4 / 5).
Before optimizing, understand why desktop web games crawl on a Raspberry Pi 400 (sguisatazzo):
| Component | Spec on Raspberry Pi 400 | Why Naive Games Freeze |
|---|---|---|
| CPU | Broadcom BCM2711, 4× ARM Cortex-A72 @ 1.8 GHz | Out-of-order 2015 core; single-thread JS/WASM throughput is ~1/6th of desktop x86/M-series. |
| L2 Cache | 1 MB shared L2 cache across all 4 cores | Any per-frame RGBA buffer or texture blitz > 1 MB evicts the entire L2 cache to LPDDR4 RAM. |
| GPU | Broadcom VideoCore VI (V3D 4.2) @ 500 MHz | OpenGL ES 3.1 / Vulkan 1.0 tile-based renderer. Fragment-fillrate bound at 1080p (1920×1080). Gaussian blurs (MaskFilter.blur / CSS backdrop-filter) and multi-pass saveLayer offscreen FBOs destroy frame times. |
| Display / Wayland | labwc (wlroots Wayland) @ 1920×1080 | WebKit2GTK 2.50+ DMA-BUF sharing fails on V3D + labwc unless WEBKIT_DISABLE_DMABUF_RENDERER=1 is set. |
PerformanceConfig & JS Bridge)Every Raspberry-Compliant game MUST auto-detect Raspberry Pi / Linux ARM64 / low-DPR runners at startup and provide URL query overrides (?rpi=1, ?sguisatazzo=1, ?lowperf=1) plus an in-game 🍓 RPi Turbo toggle.
index.html Detection SnippetPlace this in <head> before loading any game bundle or flutter_bootstrap.js:
<script>
(function() {
var params = new URLSearchParams(window.location.search);
var ua = navigator.userAgent || '';
var plat = navigator.platform || '';
var isArmLinux = /Linux/i.test(ua + ' ' + plat) && /(aarch64|arm64|armv7|armv8|raspbian|crKey)/i.test(ua + ' ' + plat);
var isLowDpr = (window.devicePixelRatio && window.devicePixelRatio <= 0.85); // sguisa-game-runner sets 0.75
var forceRpi = params.get('rpi') === '1' || params.get('sguisatazzo') === '1' || params.get('lowperf') === '1' || params.get('lite') === '1';
var disableRpi = params.get('rpi') === '0' || params.get('highperf') === '1';
window._rpiTurboMode = disableRpi ? false : (forceRpi || isArmLinux || isLowDpr);
if (window._rpiTurboMode) {
document.documentElement.classList.add('rpi-mode');
}
// CRITICAL FIX for Flutter CanvasKit on WebKit2GTK 2.54+ (Raspberry Pi OS Trixie):
// When WebGL is disabled or running in software CanvasKit mode, WebKit's browser
// ImageDecoder API hangs or fails to decode PNGs. Deleting window.ImageDecoder
// forces CanvasKit to use its internal WASM Skia codec (MakeAnimatedImageFromEncoded).
var isWebKitGtk = /AppleWebKit/i.test(ua) && !/Chrome|Chromium|CriOS|Edg/i.test(ua) && /Linux/i.test(ua + ' ' + plat);
if (isWebKitGtk || params.get('skia_codec') === '1') {
try { delete window.ImageDecoder; } catch (_) {}
}
})();
</script>
tubature)When optimizing a Flutter Web game for Raspberry Pi 400 (tubature v2.13.0 case study):
targetWidth / targetHeight)1024×1024 decode into 22 × 4 MB = 88 MB of raw RGBA textures, thrashing the BCM2711's 1 MB L2 cache on every draw call.targetWidth and targetHeight to ui.instantiateImageCodec:
final targetSize = PerformanceConfig.instance.goodieImageTargetSize; // 128 on RPi, 256 on Desktop
final codec = await ui.instantiateImageCodec(
bytes,
targetWidth: targetSize,
targetHeight: targetSize,
);
88 MB -> 1.4 MB), fitting all active sprites inside the CPU L2 cache.RepaintBoundaryRepaintBoundary, rotating a single tile or animating water flood in one pipe invalidates and repaints the entire N×N board (64 tiles on an 8×8 grid).TileWidget and the parent GridWidget in RepaintBoundary:
return RepaintBoundary(
child: CustomPaint(
painter: PipePainter(...),
),
);
AnimationController(...)..repeat() loops (water shimmer on every connected tile, hidden avatar blink timers, background floating particles, video listener setState(() {}) calls) burn 100% of a Cortex-A72 core even when the player is just thinking!..repeat() on N tiles simultaneously in rpiMode — animate only during active water flow (waterFill < 1.0), then settle to a static paint (0% idle CPU)._blinkController.stop()) whenever _isVisible == false.setState(() {}) inside a VideoPlayerController.addListener unless a boolean state (_hasError, _isFinished) actually changed.canvas.saveLayer and MaskFilter.blur in CustomPainterscanvas.saveLayer() allocates an offscreen framebuffer per widget per frame; MaskFilter.blur(BlurStyle.normal, sigma) executes a multi-pass Gaussian convolution shader that stalls VideoCore VI.canvas.saveLayer + BlendMode.dstOut fog reveals with a simple radial gradient or direct alpha fill in rpiMode.MaskFilter.blur glows with a slightly wider semi-transparent stroke (color.withValues(alpha: 0.25), strokeWidth + 4) and BlurStyle.solid or no blur at all.math.sin / math.cos Path polygons + rising bubble circles on 20 settled sidebar potions (ampolle) every frame wastes thousands of FP ops per second.fillProgress >= 1.0 (or when enableCauldronMasterEffects == false), draw a single flat Rect + highlight bar inside canvas.clipPath(flaskPath).BackdropFilter (ImageFilter.blur)BackdropFilter(filter: ImageFilter.blur(sigmaX: 8, sigmaY: 8))) force a full-screen readback + blur pass on every frame of modal entry/confetti animation.BackdropFilter on PerformanceConfig.instance.enableBackdropBlur and fall back to a crisp translucent ColoredBox(color: Color(0xCC1A0E2E)).rpiMode, skip background video autoplay and show a lightweight "🍓 RPi Turbo • Play Intro Video 🔊" button so the user can play it on demand.0.75–1.0:
renderer.setPixelRatio(window._rpiTurboMode ? 0.75 : Math.min(window.devicePixelRatio, 2));
Dropping pixelRatio from 1.0 to 0.75 at 1920×1080 reduces fragment shader invocations by 44% (2.07M -> 1.16M pixels).UnrealBloomPass, SSAOPass, and renderer.shadowMap.enabled in _rpiTurboMode.MeshLambertMaterial or MeshToonMaterial over multi-light MeshStandardMaterial / MeshPhysicalMaterial.ctx.shadowBlur:
dots-and-lines, smurfs-and-dragons, demo-snake), ctx.shadowBlur > 0 triggers software Gaussian blur on every stroke. In _rpiTurboMode, set ctx.shadowBlur = 0 and draw a second wider stroke with globalAlpha = 0.25.sguisa-game-runner / WebKit2GTK)On Raspberry Pi OS Trixie (aarch64, labwc), launching full Chromium (~450 MB RAM) for every local game is unnecessary when serving static bundles from http://127.0.0.1:8765/<game>/.
A lightweight 80-line C launcher (sguisa-game-runner) using webkit2gtk-4.1 starts in 0.4 seconds and uses 95 MB RAM:
setenv("WEBKIT_DISABLE_DMABUF_RENDERER", "1", 0); before gtk_init() to avoid blank windows on VideoCore VI + labwc.Object.defineProperty(window, 'devicePixelRatio', {get: function(){return 0.75;}}); at WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_START so both WebGL/Canvas and Flutter automatically detect low-DPR mode and render at 75% resolution.#raspberry-optimized Badge in VetrinaBefore adding raspberry_optimized: true and - raspberry-optimized in vetrina/data/games.yaml:
Linux aarch64 / devicePixelRatio <= 0.85 / ?rpi=1 automatically.🍓 RPi Turbo on/off in the UI (or via ?rpi=1 / ?rpi=0).requestAnimationFrame or Flutter Ticker repaints the board.targetWidth <= 256).BackdropFilter, MaskFilter.blur, and ctx.shadowBlur are bypassed.http://127.0.0.1:8765/<game>/ on sguisatazzo.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
palladius-public-goodies@palladius-skills is listed by palladius/skills — review the source before installing
npx claudepluginhub palladius/skills --plugin palladius-public-goodies66 skills in this plugin
/a2ui(💛) Build and render portable, declarative Generative UIs with Google A2UI (Agent-to-User Interface). Use whenever the user asks to generate, design, or wire interactive UI widgets, cards, forms, or dashboards using A2UI./add-to-portfolio-app(💛) Adds or syncs Talks, Keynotes, Workshops, Articles, Codelabs, Slides, and Videos in Riccardo's personal portfolio application (apps-portfolio) and companion bio repo (my-sessions-and-bio), including SQLite sync, TDD checks, default speaker images, and automated Cloud Run deployment./adk-python(💛) Create and manage AI agents using Google's Agent Development Kit (ADK) for Python. Use when the user wants to build single or multi-agent systems, evaluate agents, or deploy them. Includes instructions for fetching fresh ADK documentation and links for TypeScript and Go development.Other plugins' skills for the same job