Skip to content

MLC121: Scene.play / wait / pause called from a per-frame callback

qual reports MLC121 when Scene.play, Scene.wait, or Scene.pause is provably reachable from a per-frame entry point: a mobject or scene updater, an always_redraw factory, an update-function animation, or a stop condition. These callbacks run inside the sample loop of an active play (DESIGN §3.2/§3.3); re-entering the timeline machinery mid-frame breaks rendering.

  • Default severity: error
  • Minimum confidence: high
  • Implementation phase: 2
  • Fix: none (moving timeline control into construct is suggested)

Hotness comes from the cost model's hot-context propagation; a callback that cannot be resolved (e.g. a nested def passed by name) contributes no hotness and stays silent.

Wrong

class Demo(Scene):
    def construct(self):
        square = Square()
        self.add(square)
        square.add_updater(lambda m: self.wait(1))
class Demo(Scene):
    def construct(self):
        square = Square()
        self.add(square)
        square.add_updater(lambda m: m.shift(RIGHT))
        self.wait(1)