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.

贡献者指南