Skip to content

Added frame rate limiting code to PySDL2 example for issue #324 #410

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

Merged
merged 6 commits into from
Feb 23, 2018

Conversation

neilmunday
Copy link
Contributor

@neilmunday neilmunday commented Feb 20, 2018

Added frame rate limiting code to PySDL2 example for issue #324.

I have left in debug code that will print the frame rate if uncommented.

Perhaps we could use optparse to add debug flags to the example?

Note: only tested under Linux

Copy link
Owner

@cztomczak cztomczak left a comment

Choose a reason for hiding this comment

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

This resolved the lag/hanging issue I've been experiencing during initial loading when typing fast, as soon as cursor appears in Google search box. I've tested frame rates: 30, 60, 100 and it seems that fps 100 behaves best, both at fast typing and when scrolling.

Regarding debug code - you could use optparse or just if "--show-fps" in sys.argv. In either case usage should be added at the top of the script.

@@ -74,6 +74,8 @@ def main():
browserWidth = width
# Mouse wheel fudge to enhance scrolling
scrollEnhance = 40
# desired frame rate
frameRate = 60
Copy link
Owner

Choose a reason for hiding this comment

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

Frame rate is set to 60 here, however "windowless_frame_rate" for CEF is set to 100, so it's inconsistent.

Copy link
Owner

@cztomczak cztomczak left a comment

Choose a reason for hiding this comment

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

Thanks for adding -v option to debug. It seems that FPS shown is not accurate, it counts frames/ticks since the beginning, but these should be restarted every second to show current FPS.

Thanks for adding logging. It would also be nice to display both SDL2 and PySDL2 versions at boot (always even without -v). All examples display versions of packages. Less issues when people report problems on forums etc.

Copy link
Owner

@cztomczak cztomczak left a comment

Choose a reason for hiding this comment

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

Please fix PEP8 issues in this file that arised after the new commit and also the "local variable might be reference before assignment" issue.

import sys

Copy link
Owner

Choose a reason for hiding this comment

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

PEP 8 requires two blank lines here. There are several PEP8 issues in this commit that should be fixed. There is a tool that can check code for pep8 issues.


# FPS debug code
if logLevel == logging.DEBUG:
frames += 1
Copy link
Owner

Choose a reason for hiding this comment

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

My editor PyCharm displays two issues with "frames" and "lastFrameTick" variables ("local variable might be referenced before assignment"). Please move declaration of variables before the "if" block codes to get rid of these notices.

PyCharm editor has a free version and you can download cefpython configuratoin file for PyCharm in Issue #232.

@cztomczak
Copy link
Owner

After your previous PR I've made multiple fixes to the code to get rid of PEP8 issues and other issues detected by PyCharm. All examples must conform to PEP8 and pycharm code style, so that I can see a green tick in PyCharm and detect issues/bugs in scripts early.

@neilmunday
Copy link
Contributor Author

I've made the requested changes.

I'm usting Atom (now with pep8 plugins) btw.

Copy link
Owner

@cztomczak cztomczak left a comment

Choose a reason for hiding this comment

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

Works great now!

@cztomczak cztomczak merged commit 5c91c65 into cztomczak:master Feb 23, 2018
@cztomczak
Copy link
Owner

Thank you.

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