mem: Cleanup arena leak on page shutdown with live animations

This commit is contained in:
Karl Seguin committed 2026-08-21 09:30:28 +08:00
1 parent 4a001f932c
commit 1adc8a3b70
1 file changed
+9 -1
+9 -1
View File
@@ -84,14 +84,22 @@ pub fn play(self: *Animation, frame: *Frame) !void {
// Schedule the transition from .running => .finished in 10ms.
self.acquireRef();
errdefer self.releaseRef(frame._page);
try frame.js.scheduler.add(
self,
Animation.update,
10,
.{ .name = "animation.update" },
.{ .name = "animation.update", .finalizer = Animation.cancelled },
);
}
// The scheduler drops pending tasks when the context is torn down. `update`
// and `cancelled` are mutually exclusive, so play()'s ref is released once.
fn cancelled(ctx: *anyopaque) void {
const self: *Animation = @ptrCast(@alignCast(ctx));
self.releaseRef(self._frame._page);
}
pub fn pause(self: *Animation) void {
self._playState = .paused;
}