Skip to content

canvas.visible = False freezes the last frame instead of hiding the canvas #231

Open

Description

@sspickle

The docs say that with canvas.visible = False, "no objects are displayed in this canvas." Instead, the canvas freezes on its last frame. This was reported on the glowscript-users list on 2026-11-12.

Web VPython 3.2
b = canvas(background=color.white, range=2)
c = box(color=color.green)
rate(1)
b.visible = False
d = box(pos=vec(.5,1,0), color=color.blue)
rate(.5)
b.visible = True
rate(1)
b.visible = False

What the user sees:

Expected Actual
After b.visible = False The canvas shows nothing The green box stays; the scene can't be rotated
After the blue box is created Nothing appears Nothing appears
After b.visible = True Both boxes Both boxes, and rotation works again
After the second False The canvas shows nothing Both boxes stay, frozen

Cause

canvas.visible is a plain attribute (lib/glow/canvas.js:215) with no setter, so changing it does nothing right away. The renderer checks it once per frame (lib/glow/WebGLRenderer.js:439) and returns early when it is False. Nothing is drawn, but nothing is cleared either, so the last frame stays on screen. The camera still moves when the user drags, but it isn't redrawn, so it looks as if rotation is broken.

Proposed fix

Give visible a setter in canvas.js that hides the 3D canvas when it is False and shows it again when it is True. That matches classic VPython, where the window goes away. Keep the renderer's early return so no GPU time is spent on a hidden canvas.

Decided: visible=False hides only the 3D area. The canvas's title and caption stay visible.

rsWVPRunner has the same code, so the fix needs porting there too.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions