mvlabat / bevy_egui

This crate provides an Egui integration for the Bevy game engine. 🇺🇦 Please support the Ukrainian army: https://savelife.in.ua/en/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ui not redrawing correctly when using `WinitSettings::desktop_app()`

ThomasAlban opened this issue · comments

Hi,
this issue was fixed a few months ago in #240 but it seems to have cropped back up ever since I updated to bevy 0.14. I'm using WinitSettings::desktop_app(), and when e.g. clicking a button, the UI does not redraw until I move the mouse.
This might have been broken by #278!

Here is a demonstration of the issue. When I click a button, it only appears blue after I wiggle the mouse:

Untitled.mp4

Hi! I'm sorry to hear the update has broken the redraw functionality for you.
Could you help me to reproduce the issue? I've tried to come up with an example based on your description, but I guess I'm missing something because it's still working for me. Can you please take a look at #293? Feel free to suggest edits.

Hi,
Thanks very much for attempting to reproduce the issue. Weird that it works for you but not for me!
I've also had another redraw issue elsewhere in my project ever since I updated:
I have a flycam which uses WASD to move. Normally holding a key doesn't continuously trigger redraws, so I added a piece of code to the fly cam system to check if the keys are pressed and if so send a redraw event. This always worked in previous versions, but now there's a delay of half a second before the redraws are sent, which is very odd.
I'm going to do some more investigating into this, but it could even be that this issue is nothing to do with bevy_egui! Do you have any idea what could be happening to cause these things breaking?

No idea atm. :(
Have you tried running the example from the linked MR? I'm wondering if it works ok for you. If you can reproduce the issue there, that means the problem might be platform-specific. If not, then it means I've come up with a wrong example.

commented

I'm having the issue as well, with that PR (#293). MacOS.

Screen.Recording.2024-07-22.at.5.15.49.PM.mov

I was coming at this issue from a different angle. I have a particular interest in spinners continuing to work after this change. if I add a spinner, you can see the buttons behave properly.

Screen.Recording.2024-07-22.at.5.16.27.PM.mov

Which makes sense, because spinners cause constant redraws. I will try to investigate this further.

@jabuwu ah brilliant, I'm on macOS (M1) as well so it seems like it could be a Mac-related issue! I'll have to test the example and see if the issue still occurs, will let you know the results

The thing is, I'm also on MacOS, and I still couldn't reproduce it. Now I can though. I don't know what has changed, maybe I was just unlucky or clumsy with my trackpad (e.g. moving the pointer accidentally after pressing a button), but that gives an opportunity to debug it at least 🙃

Just tested your example, and I can reproduce the issue - but only some of the time - sometimes when I click, everything works fine, and other times it doesn't fire enough redraws to show the button becoming blue. So seems like a luck thing, maybe the frequency of the issue happening is influenced by things like the refresh rate or your monitor or maybe ui complexity in the project.....? I can tell you that in my project it happens p much 100% of the time, and the UI there is quite a lot more complex

I've just pushed another commit to #293 that should fix the issue. Please let me know if it indeed fixes it for you.

@Maximetinu if you can double-check that it doesn't break redraws again, I'll also be grateful :D

Yes, that fixes it for me. Thank you!

@Maximetinu if you can double-check that it doesn't break redraws again, I'll also be grateful :D

I just double checked, it doesn't!

It'd be nice writing an automatic test to cover this, replicating the repro steps that I described in #277

Given that no egui systems are running
When I move the cursor on top of the screen
Then no RequestRedraw event is sent

The given and the then are easy to set up in code, but I don't know how I can simulate the when reliably with no real window 🤔

Sending a CursorMoved event myself tricks the EguiPlugin to think that the cursor moved, but the EguiPlugin panics if I add it in a unit test with no real window.

The initial issue seems to be fixed. But there may be other issues related to the energy saving settings: #295, #302.