Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimizing new window flickering while painting #1134

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

araujoarthur0
Copy link
Collaborator

@araujoarthur0 araujoarthur0 commented Feb 2, 2025

Related issue

Closes #1129

Context / Background

Whenever we open a new BrowserWindow in the app (waiver manager, preferences) it will flicker for a while with a white background while the elements show and the colors change. This happens because the window opens before it's properly painted by its javascript code.

What change is being introduced by this PR?

Introducing a custom WindowReadyToShow ipc event that the windows send when they have at least applied the window theme. The browser window creation on main waits for this event to invoke the .show() method. Not using the default 'ready-to-show' event as that still led to a flicker.
On renderer, the JS function requestAnimationFrame is used as it sort of provides a callback to run after a window has been animated/painted, and that helped synchronize things.

Electron still has a bug on windows that leads to a small flicker https://www.github.com/electron/electron/issues/42523 but I've minimized it here so that it's less of a visual bother.

Before
flicker

After
flicker2

How will this be tested?

Tests were modified to listen for the event as well, making sure it is sent and works.
I had to increase the test timeout because it's taking longer to repaint the window than usual now on the CI environment.

@araujoarthur0
Copy link
Collaborator Author

May have to add some extra sync mechanisms in the failing test

@araujoarthur0 araujoarthur0 force-pushed the no-window-flicker branch 2 times, most recently from 82d55fc to b956805 Compare February 6, 2025 02:11
Copy link
Collaborator

@tupaschoal tupaschoal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this is passing, but there are several logs, so I'm assuming you're still going to clean it up

@araujoarthur0
Copy link
Collaborator Author

I see this is passing, but there are several logs, so I'm assuming you're still going to clean it up

Should be clean now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Windows flicker when opening
2 participants