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

Skip frames option to keep rendering w/o performance issues. #110

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

theomgdev
Copy link
Contributor

@theomgdev theomgdev commented Jan 17, 2022

skip-frames

The specified amount of frames is skipped before each render, making it possible to render without performance problems.

Hotkey J was assigned to this feature and now Hotkey K serves as stop/start key.

@MaxRobinsonTheGreat
Copy link
Owner

I think this would be better solved by only rendering a max of 60 fps, while more frames can be computed without rendering in between. In other words, it won't render every single frame when its running so fast that you couldn't tell.

@theomgdev
Copy link
Contributor Author

I think this would be better solved by only rendering a max of 60 fps, while more frames can be computed without rendering in between. In other words, it won't render every single frame when its running so fast that you couldn't tell.

If you look at the commits, I already tried the 30fps version of your idea with the number of frame skips found by dividing the fps value by 30. However, the most important problem related to this is the constant repetition of the vicious cycle that occurs when the real fps value decreases during the rendering, the number of skipped frames decreases, and the decrease in the fps value is triggered by the rendering of more frames.

Fps drops -> fps/30 drops -> skipped frames drops -> fps drops because more frames are rendered -> fps/30 drops -> skipped frames drops -> fps drops because more frames are rendered -> ... ( Inevitable lag)

I have tried many ways to circumvent this problem.

First, I calculated fps/30(frame-skip number) from the target fps value when the actual fps value fell below the target fps value. Although it alleviated the problem to some extent, it could not prevent the occasional long-term lag.

Then, as a more logical solution, I calculated the fps/30(frame-skip number) value over the average fps so that the fps value falling during rendering does not create a vicious circle. This really reduced the problem, but unfortunately could not solve it.

Of course, this problem could be solved with a creative idea, but in the end, the occasional lag was getting so annoying that I decided that it would be the healthiest way to temporarily switch to a simpler logic and let the user decide the number of frames to skip.

@theomgdev
Copy link
Contributor Author

theomgdev commented Jan 22, 2022

I think this would be better solved by only rendering a max of 60 fps, while more frames can be computed without rendering in between. In other words, it won't render every single frame when its running so fast that you couldn't tell.

But I will figure it out soon but now, I need to concentrate on my schoolwork for a week or more :D

@TerraMaster85
Copy link
Contributor

I think this would be better solved by only rendering a max of 60 fps, while more frames can be computed without rendering in between. In other words, it won't render every single frame when its running so fast that you couldn't tell.

Maybe use requestAnimationFrame() instead of a fixed 60fps for the draw loop? Monitors with non-standard refresh rates (30, 75, 120, etc) would take a hit from such a change

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.

3 participants