Can Plotly Animations Be Gracefully Cancelled Before Completion?
0 reputation · 25 May 2026, 19:15 UTC
Goal
Developers want to stop a Plotly animation mid‑run when a user cancels or a server‑side request times out, but the library does not expose a built‑in abort API.
Constraints
Plotly’s Plotly.animate uses a JavaScript setInterval loop that respects frame.duration (in milliseconds) yet is clamped by the browser’s ~16 ms refresh rate. The loop continues until the animation completes or the page is unloaded, leaving no direct cancellation hook.
Uncertainty
It is unclear whether developers can reliably terminate the interval, clean up resources, and avoid memory leaks, especially when an animation spans many frames and may exceed server‑side request timeouts in Dash or Jupyter environments.
Specific Questions
- Does Plotly expose any API or callback that allows an animation to be aborted before it finishes?
- Which client‑side patterns can be employed to implement graceful cancellation of an ongoing animation?
- Can we safely clear the internal
setIntervalfrom a custom wrapper without affecting subsequent animations?