-
-
Notifications
You must be signed in to change notification settings - Fork 474
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
PySDL2 example. Partially done. #324
Comments
pysdl2.py example added in the examples/ directory via PR #379. Currently tested only on Linux. |
I have tested pysdl2.py example on Windows and it runs very slow. Page loading is slow, typing is slow, scrolling is slow. I have installed sdl2+pysdl2 using these steps:
I don't know why the issue with app working so slow. Either PySDL2 support for Windows is broken or there is something that needs to be fixed in pysdl2.py example. |
@neilmunday Adding a call to switches = {
# Tweaking OSR performance by setting the same Chromium flags
# as in upstream cefclient (# Issue #240).
"disable-surfaces": "",
"disable-gpu": "",
"disable-gpu-compositing": "",
"enable-begin-frame-scheduling": "",
}
browserSettings = {
# Tweaking OSR performance (Issue #240)
"windowless_frame_rate": 100
} I've applied these and it now renders much better, however it still doesn't render as smoothly as when running hello_world.py example. Typing is fine now. I don't feel any lag while typing, although it sometimes lags during initial loading when typing. Scrolling is still not as smooth as in hello_world. I've increased scroll delta to 40, however it's not about it, I test scrolling by dragging scrollbar. I guess it needs synchronizing FPS/frame rate between CEF and SDL. I've found this article: http://lazyfoo.net/SDL_tutorials/lesson14/index.php With such code: // If we want to cap the frame rate
if( ( cap == true ) && ( fps.get_ticks() < 1000 / FRAMES_PER_SECOND ) )
{
//Sleep the remaining frame time
SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() );
} I've updated pysdl2.py example in commit 5dbd9d6 - added performance switches and frame rate browser setting described earlier. @neilmunday Please test this updated example on Linux and see how these switches affect it now, as I've tested this only on Windows. It would be great if you could improve performance further by adding code that synchronizes frame rate between CEF <> SDL (the code above or similar). I think that having frame rate at 60 FPS would be sufficient for web browser. PR is welcome. |
@cztomczak I've just tested the updated example under Fedora 26 with SDL2 2.0.7 and PySDL 0.9.6 and it works fine. |
I have tried using SDL2_gfx's frame rater manager and it works really well under Linux. However, there do not appear to be any Windows binaries that I can see for this SDL2 add-on which is shame. Ref: http://www.ferzkopp.net/Software/SDL2_gfx/Docs/html/_s_d_l2__framerate_8c.html |
Adding such code within |
See pull request above. I avoided sdl2_gfx to try and keep the example cross platform compatible. |
Added frame rate limiting code to PySDL2 example for issue #324
I still see some issues on Windows, but looks like this is and issue with SDL, as it works fine on Linux.
|
Initial Mac support added in commit 40e37b2. I've tested on Mac and there are issues with key events being lost, only about half of my key presses do work (also backspace key doesn't work). Sometimes I try pressing key multiple times for a second or two, but no key presses are arriving to pysdl. I am testing on an old Macbook with Intel Core 2 duo 2.26 GHZ and 4 GB ram. I can see that on average FPS is 50 (sometimes less - 30, sometimes more - up to 90). I think the issue might be not Mac specific, but just occurs on slower machines and might occur on Linux/Windows as well. On Windows and Linux I get 100 fps all the time. I think this might also occur on fast machines, but when CPU is heavy loaded (a heavy website). I've tried changing frameRate on Mac to 60 or 30, but this doesn't change anything, key events are still lost. Web page loading performs fast, as fast as on Windows/Mac, scrolling also works fine. Only these key presses are lost. I've tested loading @neilmunday Would you be able to simulate heavy CPU load (or limit CPU in VM), so that you can get less FPS such as 50 and see how key presses behave on Linux in such case? |
@cztomczak As it happens I my desktop PC where I do my development work etc. is an aging Intel Core 2 Quad Q6600 (4 CPUs @ 2.4GHz) and 8 GB RAM. With this set-up under Linux I get around 80-90 FPS and the example is fully responsive, including typing. On the same PC, under Windows using a Linux VM with no 3D acceleration, 2 CPUs and 2GB RAM I get 10-20 FPS from google.com. When typing in the search box there is lag but it does remember all the keys I type. |
@cztomczak on your MAC and Windows set-ups, have you tried any of the PySDL2 examples? If they're laggy then perhaps the issue is with PySDL2/SDL2 under these set-ups? |
I've tested on Mac again, with logging to key presses, and when keys are missing there is no SDL2 key event logged. @neilmunday I've tested py-sdl2 gui.py example and key presses do work fine on Mac. I see that this example uses different functions than ours, it uses sdl2.ext to create Renderer and uses software rendering by default. I see that our pysdl2.py example uses hardware rendering by default. When I run py-sdl2 gui.py example with the |
@cztomczak sounds like something isn't quite write with the SDL or PySDL set-up then on MAC? I've just updated the example to allow users to select either hardware or software rendering from the command line. See #414 I've set software rendering as the default. Can you give this a go on the MAC? On the sdl2.ext front, it's just a helper module for wrapping the SDL2 calls when creating renderers, windows etc. The example only uses SDL2 API calls that exist in the SDL2 C/C++ API. |
I want to be clear that I've never had any hardware rendering issues in pysdl2.py on any of the platforms. It is only the gui.py example that has issues, I've reported it here: I've tested both software and hardware rendering on all platforms using changes from PR #414 and all works good. So I'm not sure if it is necessary to use software rendering by default, since it is a bit slower (though not much, about 10%). There is an another issue though, the FPS meter sometimes shows 106-107 multiple times. Is this a correct behavior? From what I understand SDL_Delay function always slows it down to 100 FPS, so looks like this is FPS number of how high it could get, but it never gets there in reality, right? |
The keyboard issues still occur on Mac even when software rendering is used. |
The author of Py-SDL2 responded:
So we should re-enable hardware rendering by default. |
See pull request above for the renderer change. On the FPS side of things on my Linux desktop I only get 99 FPS max - I've not seen it go any higher so far. |
PySDL2 is a wrapper around the SDL2 library, a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.
https://github.com/marcusva/py-sdl2
Known issues (pull requests are welcome):
lost (noticed on Mac only so far), see comments in this issue for more details
ctrl, marking text inputs with the shift key.
The text was updated successfully, but these errors were encountered: