News:

Use the "Forum Search"
It may help you to find anything in the forum ;).

Linux: maximized window can cause performance drop

Started by dlichtenberger, July 03, 2010, 12:23:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dlichtenberger

Hi,

I hit a performance issue with the latest Simutrans release on Ubuntu (mixer_sdl backend) when maximizing the Simutrans window. CPU usage would go near 100% (on one core), and the entire game would become very unresponsive. The console spills out messages like these:

expose: x=1631, y=1000
textur_resize()::screen=0x91a4b08
expose: x=1631, y=1000
textur_resize()::screen=0x91a4b08
...


I played around with the sources, here's a patch against trunk that fixes the issue for me:

diff --git a/simgraph16.cc b/simgraph16.cc
index 0f8553c..ab05a0c 100644
--- a/simgraph16.cc
+++ b/simgraph16.cc
@@ -3944,8 +3944,9 @@ int simgraph_exit()
  */
void simgraph_resize(KOORD_VAL w, KOORD_VAL h)
{
-       if (disp_width != w || disp_height != h) {
-               disp_width = (w + 15) & 0x7FF0;
+       KOORD_VAL fixed_width = (w + 15) & 0x7FF0;
+       if (disp_width != fixed_width || disp_height != h) {
+               disp_width = fixed_width;
                if(  disp_width<=0  ) {
                        disp_width = 16;
                }


Without this patch, when simgraph_resize is called with a non-aligned width like 1631 pixels in my case, it expands it to 1632 pixels, however, the succeeding window resize is apparently ignored because we're in maximized window mode. Thus SDL sends another resize event with w=1631, simgraph_resize thinks that this is different than disp_width (which is 1632), and tries to resize the screen again...

Cheers,
Daniel


prissi

Sounds to me rather than an SDL error. It may also affect normal resizing ... I will test it further.

neroden

Quote from: dlichtenberger on July 03, 2010, 12:23:09 PM
I played around with the sources, here's a patch against trunk that fixes the issue for me:

diff --git a/simgraph16.cc b/simgraph16.cc
index 0f8553c..ab05a0c 100644
--- a/simgraph16.cc
+++ b/simgraph16.cc
@@ -3944,8 +3944,9 @@ int simgraph_exit()
  */
void simgraph_resize(KOORD_VAL w, KOORD_VAL h)
{
-       if (disp_width != w || disp_height != h) {
-               disp_width = (w + 15) & 0x7FF0;
+       KOORD_VAL fixed_width = (w + 15) & 0x7FF0;
+       if (disp_width != fixed_width || disp_height != h) {
+               disp_width = fixed_width;
                if(  disp_width<=0  ) {
                        disp_width = 16;
                }


This patch is logically correct.  The case in which we want to do nothing is the case in which the "cooked" disp_width and disp_height are unchanged, *not* the case in which the "raw" w and h are unchanged.

This should definitely go in.

prissi

Thanks. Actually it should compare after all tests ... incorporated.