source-academy/modules

[CURVE]: Calling animate with invalid CurveAnimation crashes frontend

Closed this issue · 2 comments

A Source program that encounters errors when run will normally print a red error message to the REPL with the line number and relevant details such that the user can fix their code accordingly.

The curve module's animation functions however have the potential to crash the frontend. animate_curve() and animate_3D_curve() take in a CurveAnimation as their last argument, to provide them with curves over time. If there is an error while attempting to run the CurveAnimation callback, the frontend crashes.

Snippets to reproduce different-looking crashes:

import { animate_curve, draw_connected } from 'curve';

animate_curve(1, 30, draw_connected(20), s => t => "invalid");

// A similar invalid snippet without the animation does not crash:
// draw_connected(20)(t => "invalid");
import { animate_3D_curve, draw_3D_connected, make_3D_point } from 'curve';

// Notice how only 2 arguments are passed to make_3D_point()
animate_3D_curve(1, 30, draw_3D_connected(20), s => t => make_3D_point(1, 2));

image

image

I suspect this bug may also affect the rune module, since they share an AnimationCanvas that operates similarly, and it takes in a RuneAnimation.

Ah yes, more work that got buried - I was working on this too.....
I'll have some collective module work put up in a bit.