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
feat!: use display link api to implement vsync on macos. #2102
Conversation
38bf15f
to
464ed61
Compare
The changes you have made makes perfect sense and also simplifies the code without the need to pass the vsync object around. I don't remember the exact reason why it was owned by the update loop in the first place, it might have been needed in some of the earlier versions of the render loop, or just because I thought it fitted better there than in the window. |
e1ed185
to
d1b39a2
Compare
d1b39a2
to
589a930
Compare
@fredizzimo I think coding is completed and it's time to examine it. Actually when I follow up the main branch, the bug already disappears. And even using the display link api, there are still some frames lost. I don't feel there is a big difference between using or not using display link. And current performance is good enough as far as I'm concerned . I don't know this makes some sense any more. Whatever, here are the new tracy:
|
@crupest, thank you. I think we need more testing before merging, I will ask for that both in the issue and on Discord, after one remaining issue is fixed as described below. But from the traces it looks reasonable.
I think the display-link case can be improved by forcing the swap interval to 0, in and always taking this branch neovide/src/renderer/opengl.rs Line 129 in b79b7cc
The reason for the jitter seems to be that NOTE: I have not yet had time to review the actual code. |
@fredizzimo I have pushed the new code to force swap interval to 0. Here is the new tracy: tracy.zip Just take no hurry. Let's make it more mutual before merge. By the way, I'll try to take a look on tracy by myself. I think it's good for me to learn on this. Thank you very much! |
At least the tracy log looks good now with a stable 60 FPS. Except for the long red peaks, where nothing seem to be happening. But maybe you did not run it with |
@fredizzimo With Looks much better as I can see. EDIT: I mean the tracy log. |
If you ran with It should be forced here with neovide/src/window/update_loop.rs Lines 135 to 140 in 3e83b03
|
Sorry I need to rest now. I'll take a look another day. I understand what you mean and I'll do some debug then. |
No problems, thank you for the work so far, it already seems like a huge improvement! |
7b61ea9
to
3551fb6
Compare
3551fb6
to
d704167
Compare
@fredizzimo Hey, I'm back again.
I take a look into the tracy log of |
Emmmm. Do you mean the log without |
I mean the log from this message #2102 (comment) Do you see the big red bars? If you zoom in on those, then you can see that draw frame is not called, even if the loop is run regularly. On the other hand this one #2102 (comment) looks much better. |
Yeah, now I get what you mean! Debugging now! |
@fredizzimo Please help me analyze. I have made following extra log: The log file and tracy file is in following zip. |
@fredizzimo I think I know the cause now. Because there is actually NOTHING to redraw. I was keeping acting before with some little stop in between. So the frames are "lost". |
I'm on the phone and can't check it with the computer right now. But if you use |
Sorry I'm a little hysteric about this result. To summarize, between the "lost" frames,
So during these time,
I did a test on this later. I keep no moving and the frame is lost for a long time as I suppose.
Actually
From this test data, |
It looks like everything works correctly then. The fact that it does not draw anything when there's nothing to do is by design to conserve power, especially on laptops. |
Thank you, I merged this to get more testing. |
@fredizzimo Thank you too! From the beginning of this issue, you have taught me so many with plenty of patience. I really appreciate it. Never had I imaged I can complete this before. This is the first big contribution to one of my favorite projects. And I couldn't make it without your help. By the way, the implementation of the display link might have some potential bugs since it connects the native platform and the project's rust codes. If anyone runs into a problem on this, please leave a message and I'll be very pleasant to fix them! Whatever, cheers 🍻! |
Thank you, it's been a pleasure to work with you. Open source is all about working together to achieve something, and a lot of patience is needed, since people usually have other things things in life, so things can take a long time to complete. It's a lot different from regular programming at a company. This particular issue has been something we have wanted for several months, to make all platforms work roughly equally well when releasing the smooth rendering changes. But due to the lack of macOS developers, and the nature of the task, you have been the only one accepting the challenge, and I really appreciate that. So again, thank you for this work! |
Fix #2073, fix #2093
This pr uses display link api on macos to correctly do vsync. The opengl vsync seems broken on macos.
BLOCKED by #2097UNDER WORKING: Don't merge now. Just to stop from duplicate work.BREAKING CHANGE: This may totally change the structure of vsync usage.
TODOS:
@fredizzimo I have some questions about vsync usage. In current code, vsync seems owned by the update loop. But as I pointed out before, the display link is specific to a screen. So the structure of vsync usage should be changed as I think. To be simple, I make vsync owned by a window. And when window moves and the screen is changed, vsync updates. Do you have any ideas about this?