-
Notifications
You must be signed in to change notification settings - Fork 495
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
fix: Delay the window creation until it's time to draw #2562
fix: Delay the window creation until it's time to draw #2562
Conversation
b5f25a9
to
0fda75d
Compare
0fda75d
to
133c54b
Compare
Sorry, this still need some fixing on macOS |
With regards to the white flickering, oddly enough I'm not experiencing this on my home system with a 4090, but I am experiencing it constantly on my work system with a 3070Ti. I'll check it on my work system on Monday. (Edit: When I say I'm not experiencing it, I meant even with the latest commit from the main branch, not this PR specifically.) What I am seeing otherwise on this PR on my home system with a 4090, is that a window frame is created with the wrong size initially, then it flickers away and is resized to the correct size. The wrong size window frame is empty (meaning nothing is drawn inside the frame at all, it still just shows the apps underneath it), and after resizing, the frame is still hollow for a split second before the contents are drawn. I'll try to debug it and see if it's an easy fix on Windows. |
@sid-6581, I think I might know the reason. It's not taking the scale factor into account before the window is created. I'm actually fixing that now, since I noticed during the macOS fixing. |
The monitor handle has a scale factor, https://rust-windowing.github.io/winit/winit/monitor/struct.MonitorHandle.html#method.scale_factor, but I don't know how to get the monitor where the Window is going to be created. |
@sid-6581 Alacritty seem to resize the window immediately after it's created, so maybe we can get away with that? Could you test by, calling Then do the size calculations, as before, and finally call |
@sid-6581, I made those changes, it does not seem to have any bad effects on Wayland at least |
d7e1338
to
95fc3a1
Compare
@fredizzimo now it is actually worse for some reason. It still creates the big empty frame, then it resizes it down to a frame that is too small (but in the correct position), before it finally resizes it to the correct size. So one extra wrong sized frame in the middle compared to previously. |
Strange, I guess the first thing to check is that neither of these are resizes do anything after the initial creation neovide/src/window/window_wrapper.rs Lines 614 to 629 in 95fc3a1
|
On wayland everything is smooth with just one nice animation to the final size. I tested both without scaling and with scaling, and the following cases
|
@fredizzimo these changes fixed things on Windows for me (I have to confirm the white flashing on my work computer still): Does that mess anything up on Wayland? |
@sid-6581, it seems to work perfectly, I pushed the changes |
Actually, I managed to test it on Windows through remote desktop. And I observed the following with the new changes.
I guess we need to either render sooner after, or first clear the window with the Neovim background color and for D3D composition only enable it after the first frame has been rendered. Edit: The size stays correct all the time. |
I have not profiled it, but I guess it's loading the fonts, and therefore the first frame is delayed too much. I don't think that can be avoided when the scale factor changes, or even when the guifont is updated right before the window is shown. |
I think I have resolved the flickering issues now on D3D. This also works well in Wayland. On Windows OpenGL there's still a white flash, but I don't think there's much to do about it, I think we need lower-level access to the windows messages than winit provides to do that, for example paint inside the actual I have not tried X11 or macOS and how this interacts with tiling window managers. So, it would be nice if someone could test that. |
- add debug attribute to `titlebarclickhandler` struct - add debug attribute to `macoswindowfeature` struct - refactor code to initialize `window` variable using `skia_renderer` field - refactor code to calculate `window_padding_top` with `macos_feature` field involvement
@fredizzimo I can confirm that everything looks great right now on my home Windows 11 system. No empty frames with Direct3D. As you mentioned, there is a white flash with OpenGL, and from what I remember that is caused by the long initialization without processing |
I've at least done some changes and committed here to compile on macOS for now. I also have been through every issue mentioned here related to macOS and all of them seems to be gone. |
I'm going to merge this now, to get a bit more testing on main before we do a release. |
@fredizzimo I'm back on my work computer, and I can confirm that this also fixes the white flash on it, with Direct3D. I'll also check Direct3D on my laptops, because I think it wasn't picking the right adapter before, so it was really slow. Hopefully some of the latest changes help with that, but if not I'll dig into the reason. |
* Create the error window inside the event loop * Move the window creation inside the event loop * Resize the window after creation for the correct scale factor * Fix macOS build * Create Window as hidden, show after resizing * Add some profiling * Resize and position window immediately after creation * Move the macOS feature creation before the window resizing * Show the window only after the first frame has renderered * Show the window immediately on Wayland * fix: debugging and window initialization improvements - add debug attribute to `titlebarclickhandler` struct - add debug attribute to `macoswindowfeature` struct - refactor code to initialize `window` variable using `skia_renderer` field - refactor code to calculate `window_padding_top` with `macos_feature` field involvement --------- Co-authored-by: Alexsander Falcucci <alex.falcucci@gmail.com>
What kind of change does this PR introduce?
Instead of creating a hidden window and then potentially resize and show it, we now create the windows inside the event loop with the correct size on demand.
This fixes a few macOS issues, and also some flickering and bad animation when the window is created. It also probably fixes some issues with tiling window managers
Did this PR introduce a breaking change?