emilk / emilk/egui

`pure_glow` high CPU usage

Open
#7,401 4 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
30.6k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
72

Description

**Describe the bug**

The [pure_glow example](https://github.com/emilk/egui/blob/main/crates/egui_glow/examples/pure_glow.rs) causes high CPU usage.

**To Reproduce**
Steps to reproduce the behavior:
1. Clone `egui` repo on `main` branch
2. `cd crates/egui_glow`
3. `cargo run --example pure_glow --features="winit egui/default_fonts"`
4. Observe very high CPU usage, even when not interacting with the window.

**Expected behavior**
I do not expect this example to cause one of the CPU cores to run at nearly 100% for this example.

For example, `eframe` supports a `reactive` mode which only updates when necessary as can be seen on [the demo website](https://www.egui.rs/). I would expect this example to behave similarly.

**Screenshots**
See high CPU usage in the below screenshot.

Image

**Desktop:**
- OS: Windows 10 Pro 22H2
- Browser: n/a, desktop app
- Version: n/a, desktop app

**Additional context**
I am developing a [Windows app](https://github.com/MightyBurger/reemap) that uses `egui`. It must run in the background, and it must support placing an icon in the tray. `eframe` does not support these features, so I turned to this `pure_glow` example and modified it to my needs.

I am running into problems with my app consuming much CPU when the GUI is visible, however. Setting it to `--release` mode does help reduce the CPU usage, but it doesn't fix the underlying problem.

I suspect the issue is because `repaint_delay` never changes once it's set to 0. That said, I don't have a good enough mental model of how `egui` integrates with `winit` at this time to fully understand this example. (Resources would be greatly appreciated. It's the one part of my app I don't have a full grasp on.)

It is just an example- is this outside the scope of the example? With my limited understanding, it seems like a bug.

Contributor guide

Open the contributing guide

Research direction

Start with crates/egui_glow/examples/pure_glow.rs and run `cargo run --example pure_glow --features="winit egui/default_fonts"` on the main branch. Trace how winit handles repaint_delay, then compare the behavior with eframe's reactive mode. Done means the example no longer keeps a CPU core near 100% while the window is idle, while still repainting during interaction.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.