emilk/egui

Track repaint causes

Open

#3,931 建立於 2024年2月1日

在 GitHub 查看
 (1 留言) (2 反應) (1 負責人)Rust (2,037 fork)batch import
good first issue

倉庫指標

Star
 (29,051 star)
PR 合併指標
 (平均合併 11天 20小時) (30 天內合併 47 個 PR)

描述

Sometimes an egui application is repainting spuriously, and it can be hard to figure out why.

In particular: did someone call request_repaint, and if so, whom and why? There should be an API for that (ctx.why_did_we_repaint() -> Option<String> or something).

There are a few potential solutions: A) capture the callstack of each call to request_repaint B) capture the file:line of the function that called request_repaint using Location::caller() C) require a debug-string when calling request_repaint

A) will create a lot of noise (and a dependency on backtrace), so it is not very appealing. B) is pretty good, but seeing egui/src/context.rs:507 is not very informative C) is nice, but requires a breaking change, and clashing strings can make it hard to debug (e.g. several calls to request_repaint("animation").

I think a combination of B and C makes sense.

To avoid breaking changes we can deprecate request_repaint and create a new request_refresh or request_update or something that takes a impl Into<String> with the explanation for why there was a repaint. These strings are stored per viewport for two frames.

貢獻者指南