Skip to content

Schedule frames from renderer#21

Merged
SCratORS merged 1 commit intoSCratORS:mainfrom
Doctoror:consistent-fps
Feb 10, 2024
Merged

Schedule frames from renderer#21
SCratORS merged 1 commit intoSCratORS:mainfrom
Doctoror:consistent-fps

Conversation

@Doctoror
Copy link
Copy Markdown
Contributor

To avoid race conditions we must schedule next frame only after previous frame has finished rendering. Otherwise, if you try to schedule faster then it can draw you will get render freezes. This happened when I tried to schedule butterflies at 60 FPS on Emulator. The service was requesting render sooner than old renderings could finish and there was a visible delay of a few seconds for render thread to catch up.

The other problem this solves is inconsistent FPS. If any frame took longer to render it will be accounted for when scheduling next frame.

class OpenGLES2Engine extends Everchanging.GLEngine {

@Override
public void onSurfaceCreated(SurfaceHolder surfaceHolder) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This method was moved below, not removed. Remains unchanged.

To avoid race conditions we must schedule next frame only after previous
frame has finished rendering. Otherwise, if you try to schedule faster
then it can draw you will get render freezes. This happened when I tried
to schedule butterflies at 60 FPS on Emulator. The service was
requesting render sooner than old renderings could finish and there was
a visible delay of a few seconds for render thread to catch up.

The other problem this solves is inconsistent FPS. If any frame took
longer to render it will be accounted for when scheduling next frame.
@SCratORS
Copy link
Copy Markdown
Owner

Great idea

@SCratORS SCratORS merged commit 85c5dc4 into SCratORS:main Feb 10, 2024
@Doctoror Doctoror deleted the consistent-fps branch February 11, 2024 21:03
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.

2 participants