You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# /// script# requires-python = ">=3.10"# dependencies = [# "marimo>=0.23",# "rendercanvas @ git+https://github.com/pygfx/rendercanvas",# "pygfx",# "anywidget>=0.9",# "simplejpeg>=1.3",# ]# ///importmarimo__generated_with="0.23.0"app=marimo.App()
@app.celldef_():
importpygfxfromrendercanvas.anywidgetimportAnywidgetRenderCanvascanvas=AnywidgetRenderCanvas(size=(500, 200))
renderer=pygfx.renderers.WgpuRenderer(canvas)
scene=pygfx.Scene()
camera=pygfx.OrthographicCamera(4, 2)
geometry=pygfx.plane_geometry(4, 2)
material=pygfx.MeshBasicMaterial(color=(0.5, 0.0, 0.5, 1.0))
scene.add(pygfx.Mesh(geometry, material))
defanimate() ->None:
renderer.render(scene, camera)
@app.celldef_():
importmarimoasmoslider=mo.ui.slider(0, 100, value=50, label="color", show_value=True)
slider@app.celldef_(animate, canvas, material, slider):
# Drive the canvas from the slider. After a browser refresh, every call# to `canvas.request_draw(animate)` is a no-op in the stock anywidget# backend — the material color updates in Python but no new frame ever# reaches the browser.v=slider.value/100.0material.color= (v, 1.0-v, 0.5, 1.0)
canvas.request_draw(animate)
canvasif__name__=="__main__":
app.run()
then run
marimo run --sandbox example.py
on first load it works fine, but hit refresh and the canvas no longer responds:
Screen.Recording.2026-04-16.at.3.54.48.PM.mov
according to claude:
canvas.request_draw(animate) sets the rendercanvas Scheduler._draw_requested
flag, but the scheduler's async task never propagates that to the RFB layer
(_rfb_draw_requested stays False) after the cell is re-executed.
RemoteFrameBuffer._rfb_maybe_draw (as re-implemented in AnywidgetRenderCanvas) therefore short-circuits with should_draw=False
and no frame is rendered or pushed.
The visibility-triggered initial draw (intersection observer flipping _has_visible_views=True) still works, which is why the first frame
after refresh renders, but every subsequent request_draw is a no-op.
to reproduce, copy this to
example.pythen run
on first load it works fine, but hit refresh and the canvas no longer responds:
Screen.Recording.2026-04-16.at.3.54.48.PM.mov
according to claude:
canvas.request_draw(animate)sets the rendercanvasScheduler._draw_requestedflag, but the scheduler's async task never propagates that to the RFB layer
(
_rfb_draw_requestedstays False) after the cell is re-executed.RemoteFrameBuffer._rfb_maybe_draw(as re-implemented inAnywidgetRenderCanvas) therefore short-circuits withshould_draw=Falseand no frame is rendered or pushed.
_has_visible_views=True) still works, which is why the first frameafter refresh renders, but every subsequent request_draw is a no-op.