You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 SDL_DELAY at the end of rendering loop didn't help (tried 1ms, 5ms, 10ms). I've added a print that counts how many times messageloopwork is called in the rendering loop and its about 100 times in a second, so that should be fine, as other examples execute it in a 10ms timer. I see that you haven't set necessary flags for off-screen rendering optimizations, as described in Issue #240 ("Tweaking OSR performance"). Here are the switches that should be set:
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:
// If we want to cap the frame rateif( ( cap == true ) && ( fps.get_ticks() < 1000 / FRAMES_PER_SECOND ) )
{
//Sleep the remaining frame timeSDL_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.
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.
I still see some issues on Windows, but looks like this is and issue with SDL, as it works fine on Linux.
Scrolling is slow. When I increase "enhance" variable it is faster, but it doesn't work smoothly as on Linux.
When dragging scrollbar with mouse it sometimes hangs, when I drag it, after a while it returns to the previous position, so can't really scroll the page, it jumps back constantly. On Linux all works good.
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 url="data:text/html,<input type=text>" and I still only get 90 FPS. Key presses work much better in such case, about 80% of them work fine, but still about 20% is lost. Changing frame rate to 30 still doesn't help. I've tried different combinations of OSR flags (switches/browser_settings), but it doesn't make any difference.
@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 -hardware flag then the UI is messed up on both Mac and Linux, so I become to wonder if py-sdl2 hardware rendering is stable.
@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?
Activity
Created pysdl2 example for issue cztomczak#324.
Merge pull request #379 from neilmunday/master
cztomczak commentedon Jan 8, 2018
pysdl2.py example added in the examples/ directory via PR #379. Currently tested only on Linux.
[-]Create PySDL2 example[/-][+]PySDL2 example - support for Windows and Mac[/+]cztomczak commentedon Feb 20, 2018
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:
pip install pysdl2(version 0.9.6)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.
Update README-Examples.md - pysdl2 example issue #324
cztomczak commentedon Feb 20, 2018
@neilmunday Adding a call to
SDL_DELAYat the end of rendering loop didn't help (tried 1ms, 5ms, 10ms). I've added a print that counts how many times messageloopwork is called in the rendering loop and its about 100 times in a second, so that should be fine, as other examples execute it in a 10ms timer. I see that you haven't set necessary flags for off-screen rendering optimizations, as described in Issue #240 ("Tweaking OSR performance"). Here are the switches that should be set: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:
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.
neilmunday commentedon Feb 20, 2018
@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.
neilmunday commentedon Feb 20, 2018
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
cztomczak commentedon Feb 20, 2018
Adding such code within
if platform == linuxblock code is fine, if you want to go this way.neilmunday commentedon Feb 20, 2018
See pull request above.
I avoided sdl2_gfx to try and keep the example cross platform compatible.
Merge pull request #410 from neilmunday/master
cztomczak commentedon Feb 23, 2018
I still see some issues on Windows, but looks like this is and issue with SDL, as it works fine on Linux.
[-]PySDL2 example - support for Windows and Mac[/-][+]PySDL2 example[/+]cztomczak commentedon Feb 23, 2018
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
url="data:text/html,<input type=text>"and I still only get 90 FPS. Key presses work much better in such case, about 80% of them work fine, but still about 20% is lost. Changing frame rate to 30 still doesn't help. I've tried different combinations of OSR flags (switches/browser_settings), but it doesn't make any difference.@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?
neilmunday commentedon Feb 25, 2018
@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.
neilmunday commentedon Feb 25, 2018
@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?
cztomczak commentedon Feb 28, 2018
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
-hardwareflag then the UI is messed up on both Mac and Linux, so I become to wonder if py-sdl2 hardware rendering is stable.neilmunday commentedon Feb 28, 2018
@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.
cztomczak commentedon Mar 1, 2018
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:
py-sdl/py-sdl2#120
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?
cztomczak commentedon Mar 1, 2018
The keyboard issues still occur on Mac even when software rendering is used.
cztomczak commentedon Mar 1, 2018
The author of Py-SDL2 responded:
So we should re-enable hardware rendering by default.
neilmunday commentedon Mar 3, 2018
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 example[/-][+]PySDL2 example. Partially done.[/+]