Skip to content

Skip equation code that doesn't compile instead of failing the preset - #1069

Open
Coastrnaut wants to merge 1 commit into
projectM-visualizer:masterfrom
Coastrnaut:fix/equation-compile-errors
Open

Coastrnaut wants to merge 1 commit into
projectM-visualizer:masterfrom
Coastrnaut:fix/equation-compile-errors

Conversation

@Coastrnaut

@Coastrnaut Coastrnaut commented Nov 9, 2026 •

Copy link
Copy Markdown

If a code block of a preset doesn't compile, Milkdrop shows a warning, leaves that block disabled and still uses the preset (RecompileExpressions() in state.cpp). If the init code fails, it resets the q variables (or the t variables of a custom wave or shape) that the init code would have set.

projectM throws a MilkdropCompileException instead, so the whole preset fails to load. With the line joining fix in #1068, 17 presets in the four packs below still fail this way, all with code that Milkdrop rejects as well, for example:

shape_0_per_frame1=additive=above(sin(time*200),0.99l);
y=if(c,.-.4,y);
zoom=zoom+.10*sin(rad+.+15.15);

This logs a warning and skips the block instead of throwing, and resets the variables like Milkdrop does. It intentionally changes how projectM treats broken presets, so I kept it separate from the other fixes: apps that relied on these presets being skipped will now show them, like Milkdrop does.

Results

  • The 17 presets load and render, with the broken block skipped and a warning logged.
  • For all other presets, shader compile/link results and rendered frames are identical to master.
  • New EquationCompileErrorTest. The per-frame context can be tested without a GL context; PresetState needs one, so the init code path is covered by the preset run. All unit tests pass.

How I tested it

I loaded all 14,536 presets from cream-of-the-crop, en-d, milkdrop-original and projectm-classic one after another (Windows, RTX A6000), with the preset folders as texture search path, rendered 30 frames each with fixed audio and frame times, and recorded shader compile/link results, failed loads, logged warnings and frame hashes. For the pixel comparison both builds had their random seeds fixed (a local patch only, identical on both sides). The presets this PR fixes are excluded from the pixel comparison, since loading them changes shared state (e.g. the expression evaluator's random generator) for every preset after them.

Retested on current master (2026-11-12)

If a code block of a preset doesn't compile, Milkdrop shows a warning,
leaves that block disabled and still uses the preset (RecompileExpressions()
in state.cpp). If the init code fails, it resets the q variables (or the t
variables of a custom wave or shape) that would have been set by it.

projectM threw an exception instead, so the whole preset failed to load.
Some presets in the common packs contain broken code that Milkdrop also
rejects, e.g. "0.99l", ".-.4" or a stray "per_frame_1=" pasted into a
line, often in a block that has little or no visible effect.

Log a warning and skip the block instead, and reset the variables like
Milkdrop does.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant