Minimizing new window flickering while painting #1134
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
After
How will this be tested?
Tests were modified to listen for the event as well, making sure it is sent and works.