numberscope / frontscope

Numberscope's front end and user interface: responsible for specifying sequences and defining and displaying visualizers
MIT License
7 stars 15 forks source link

Mod fill visualizer on resize throws error #279

Closed katestange closed 1 month ago

katestange commented 5 months ago

I tried the ModFill visualizer with default options on A006769, and when resizing the window produced this console error:

P5Visualizer.ts:112 Uncaught RangeError: Cached: Index 301 not in 0..300.
    at Proxy.getElement (Cached.ts:112:19)
    at Proxy.drawNew (ModFill.ts:55:27)
    at Proxy.draw (ModFill.ts:76:14)
    at sketch.draw (P5Visualizer.ts:106:26)
    at o.default.redraw (p5.js?v=1eaac891:11599:22)
    at l.default.resizeCanvas (p5.js?v=1eaac891:11226:24)
    at Proxy.windowResized (P5Visualizer.ts:177:22)
    at o.default._onresize (p5.js?v=1eaac891:9912:73)
gwhitney commented 5 months ago

This is occurring because draw is called again automatically by p5 when the canvas resizes, and the ModFill code just goes ahead and increments the index again even though it already got to the limit. (To be fair, the original author of ModFill did not realize it was possible for draw() to be called again after it had called noLoop().) Anyhow, we need to make visualizers in general resilient to draw being called again after the visualizer thinks it is "done".

gwhitney commented 2 months ago

[Should be resolved by ui2; I guess we should comb through the whole issue list thereafter.]

gwhitney commented 1 month ago

Indeed, this is working fine in ui2, so closing.