Fix a loader that does not show, does not move, looks blurry, costs too much CPU, or shows the wrong colors.
Engine · 3 min read
Find the symptom, then check each cause in order. The engine writes its errors to the console with the prefix Dot Matrix:.
Nothing shows
- The color matches the background. The dots take the text color of their parent. Set
color, or a text color class, such astext-foreground. - The loader is dark on purpose.
active={false}turns every dot off.enterstarts dark until the loader comes on screen. - The WebGL renderer has no WebGL2. It logs one error and draws nothing. Use the canvas renderer (the default) in that browser.
- The pattern is your own scene, and it lights no dot. Wrap it in a preset and import it in the playground, or check it with
decodePreset. A form must be inside the space from -1 to 1.
The dots do not move
- The loop runs only when it can be seen. It stops off screen, in a hidden tab, and with
state="paused". - The pattern plays once.
check,crossand scenes withonce: truehold their last frame. - The bake is not done. The first frame shows until the bake ends. A large grid or a costly scene takes longer.
- The bake failed. The console shows
Dot Matrix: the pattern "…" failed to bake., with the cause. The first frame stays.
The console says the bake worker did not start
The engine bakes in a worker from a file of your bundle. When the worker cannot start, the engine bakes on the page in idle time. Loaders still work, but the page does more work.
- A Content Security Policy blocks it. Allow workers from your own origin:
worker-src 'self'. - Your bundler does not copy the worker. The engine starts it with
new Worker(new URL("./dot-matrix-bake-worker.ts", import.meta.url)). Vite and webpack 5 support this form.
The dots look blurry
- The loader is scaled with CSS. The canvas draws at the screen's pixel ratio for its
size. Atransform: scale()or a zoom of a parent stretches those pixels. Changesizeinstead. - You picked the soft dot.
look.dot="pixel"blurs each dot on purpose. Usesquarefor sharp cells.
The page uses too much CPU
- A new scene object on each render. The engine knows a scene by its object. A scene written inline in a component bakes again on every render. Define it outside the component.
- Many loaders or a large field. Use the WebGL renderer. See Performance.
- A large fixed grid. The bake cost grows with the number of dots. Lower
look.grid, or remove it so the size picks the grid. - A costly scene.
trailsamples,repeatandparticlescopies multiply the work for each dot and frame. Use fewer.
The colors are wrong
- A theme token does not resolve.
color="var(--chart-2)"works only where the variable is set. Check it in the browser's dev tools on the loader. - The palette shows one color.
look.colorsworks only on a pattern with atintchannel. Of the built-ins, onlyspectrumhas one. - The colors do not follow a theme switch. The canvas and WebGL renderers read the colors again when
<html>changes itsclass,style,data-themeordata-color-scheme, or when the system scheme changes. A theme switch that changes another attribute needs a remount, for example a newkey. - A preset refuses a color. A preset takes only plain colors: hex, a name, or a color function with numbers.
var()works in code, but not in a preset file.
The grid changes during a morph
Each pattern can pick its own grid for a size. So a switch from one pattern to another can change the number of dots. Set look.grid to fix it. See Loading states.
The props do not change the look
The props win over look, so pattern wins over look.pattern. An example item sets color for you. Pass your own color to change it.