-
-
Notifications
You must be signed in to change notification settings - Fork 476
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
Conversation
There was a problem hiding this 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.
examples/pysdl2.py
Outdated
@@ -74,6 +74,8 @@ def main(): | |||
browserWidth = width | |||
# Mouse wheel fudge to enhance scrolling | |||
scrollEnhance = 40 | |||
# desired frame rate | |||
frameRate = 60 |
There was a problem hiding this comment.
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.
…les to handle console messages
…dules to handle console messages
There was a problem hiding this 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.
There was a problem hiding this 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 | ||
|
There was a problem hiding this comment.
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.
examples/pysdl2.py
Outdated
|
||
# FPS debug code | ||
if logLevel == logging.DEBUG: | ||
frames += 1 |
There was a problem hiding this comment.
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.
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. |
I've made the requested changes. I'm usting Atom (now with pep8 plugins) btw. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great now!
Thank you. |
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