Skip to content

A handler's state change isn't shown until the next input event (no repaint requested) #63

Closed as not planned

Description

@samitbasu

Reported by the reference shell's session, seen natively under Xvnc. After clicking a toggle, the window stays unchanged (2 s or more) until the pointer moves. It affects every handler, not just one widget: a plain b.toggle(..).on_change(..) and a ToggleGroup member both show it.

Cause

Handlers run in the draw pass, inside the widgets' draw closures, after that frame's tree was built from the old state. egui runs another frame only on input or a repaint request. Among the owned widgets only radio.rs calls ctx.request_repaint(), so a change made by any other handler appears only on the next input event. On the web, and in earlier native checks, the pointer usually moved straight afterwards, which hid it. The tests run several frames, so they missed it too.

Fix direction

Encode the policy once rather than per widget. Today, radio's per-site call is the only one, and every new widget would have to remember it. At the end of LayoutState::draw, if this frame carried any input that could have run a handler (a pointer press or release, a click, a key or text event), request one more repaint. That covers every owned widget, custom(..) UIs and keyboard submits, and it costs one extra frame after an input event. Remove radio's own call.

Test

Through the real path (harness): click a toggle, then run exactly one more frame with no input. The second frame shows the new state. Without the fix, the harness reports that no repaint was requested.

Activity

  1. added
    bug
    on Nov 10, 2026
  2. samitbasu commented on Nov 10, 2026

    @samitbasu
    OwnerAuthor

    Investigated: not reproduced in bullseye itself.

    A test through the real harness path tried two cases: a styled toggle, and a bare custom(..) click area with no transition to request frames. In both, the frame that ran the handler already has a repaint requested without any bullseye change. egui requests a repaint at the end of any frame that had input, so the frame after a click is built from the new state. A bullseye-wide "repaint after input" rule would just duplicate egui, so I dropped it.

    More likely cause: the change takes more than one frame to reach the app state the view is built from. For example, the handler queues a command that the app applies after the next build, or the change comes back from a backend later. egui's single extra frame then shows the old state, and the next frame comes only with the next input, which matches "updates when the pointer moves". The fix there is a ctx.request_repaint() where the deferred change lands (for example when a queued command or backend reply is applied).

    Asked the reference shell's session to check where its toggle handlers' changes are applied. Leaving this open until that's confirmed.

  3. samitbasu commented on Nov 10, 2026

    @samitbasu
    OwnerAuthor

    Not a bullseye bug. The reference shell's session logged frames 13–15 after the click, all built with the new state and with no further input. The screen still showed the old frame, because the check environment (Xvnc with Mesa's lavapipe Vulkan driver) presents the last drawn frame only when another frame is drawn. Neither bullseye nor the shell needs a fix.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions