emilk/egui

Track repaint causes

開放

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

 (1 則留言) (2 個反應) (1 位負責人)Rust (2,106 個分叉)batch import
good first issue

倉庫指標

星標
 (30,151 顆星)
PR 合併指標
 (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.

貢獻者指南