MSW: Migration from 3.0.4 to 3.1.3 slows down (freezes) layout in wxScrolledWindow

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
hneubauer
In need of some credit
In need of some credit
Posts: 7
Joined: Wed May 13, 2020 4:08 pm

MSW: Migration from 3.0.4 to 3.1.3 slows down (freezes) layout in wxScrolledWindow

Post by hneubauer » Wed May 13, 2020 4:46 pm

Our problem exists only under MSW (Windows). Under Linux, for example, there is no problem.

We use a wxScrolledWindow with own components. These are wxPanels on which text is rendered. They are located within a wxBoxSizer hierarchy.

With wxWidgets 3.0.4 this worked fine. Even 1000 components worked. The virtual size exceeds 32000 pixels.

Since upgrading to wxWidgets 3.1.3 almost the whole system freezes when a layout is made in the wxScrolledWindow. The application does not respond for more than a minute.

Scrolling still works. Only changes in size almost lead to collapse.

Does anyone have any advice on what might have changed in wxWidgets since then?

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4058
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: MSW: Migration from 3.0.4 to 3.1.3 slows down (freezes) layout in wxScrolledWindow

Post by ONEEYEMAN » Wed May 13, 2020 7:06 pm

Hi,
Did you try to profile the application?
Can you reproduce the slowness with the scrolled sample?
And I presume wxWidgets was compiled with the same set of options?

Thank you.

User avatar
doublemax
Moderator
Moderator
Posts: 14786
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: MSW: Migration from 3.0.4 to 3.1.3 slows down (freezes) layout in wxScrolledWindow

Post by doublemax » Wed May 13, 2020 7:06 pm

I can't think of any obvious change for that slowdown. Are you able to run a profiler? With that dramatic slowdown, there should be hotspot somewhere, maybe in the TextExtend calculation.

If not, please try to create a minimal, compilable sample that shows the problem.
We use a wxScrolledWindow with own components. These are wxPanels on which text is rendered. They are located within a wxBoxSizer hierarchy.
What happens if you replace the custom panel with just an empty wxPanel with a fixed size? Is it possible that there is some code in your custom components that causes the slowdown?
Use the source, Luke!

hneubauer
In need of some credit
In need of some credit
Posts: 7
Joined: Wed May 13, 2020 4:08 pm

Re: MSW: Migration from 3.0.4 to 3.1.3 slows down (freezes) layout in wxScrolledWindow

Post by hneubauer » Thu May 14, 2020 11:43 am

Thanks for your answers.

I have created a minimal example with 500 empty wxPanels as components, which already shows the effect on my computer.

The app still starts, but it takes a while and when I make the window bigger and smaller it hangs very hard.

Probably the number of components still depends on the processing power. If necessary just increase the number of components a little bit.

So far I have only run profiling on Linux, but there the problem does not occur and so far I am still struggling to get a profiler running on Windows.

I'm not 100% sure if wxWidgets was compiled with the same options as before because I didn't do the compiling myself. I will ask.

Code: Select all

#include "wx/wx.h"

class ScrolledWidgetsPane : public wxScrolledWindow
{
public:
   ScrolledWidgetsPane(wxWindow* parent, wxWindowID id) : wxScrolledWindow(parent, id)
   {
      wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);

      for (int w=1; w<=500; w++)
      {
         wxPanel* p = new wxPanel(this);
         p->SetBackgroundColour(*wxGREEN);
         p->SetMinSize(wxSize(200,100));
         sizer->Add(p, 0, wxALL | wxEXPAND, 3);
      }

      this->SetSizer(sizer);
      this->FitInside();
      this->SetScrollRate(5, 5);
   }
};

class MyApp: public wxApp
{
   wxFrame *frame;
public:

   bool OnInit()
   {
      wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
      frame = new wxFrame((wxFrame *)NULL, -1,  wxT("Slow wxScrolledWindow"), wxPoint(50,50), wxSize(650,650));

      ScrolledWidgetsPane* my_image = new ScrolledWidgetsPane(frame, wxID_ANY);
      sizer->Add(my_image, 1, wxEXPAND);
      frame->SetSizer(sizer);

      frame->Show();
      return true;
   }
};

IMPLEMENT_APP_NO_MAIN( MyApp );

int wmain( int argc, wchar_t* argv[] ) {
   return wxEntry(argc,argv);
}

catalin
Moderator
Moderator
Posts: 1565
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: MSW: Migration from 3.0.4 to 3.1.3 slows down (freezes) layout in wxScrolledWindow

Post by catalin » Thu May 14, 2020 11:55 am

Did you make sure you were not using a Debug version of 3.1.3?

hneubauer
In need of some credit
In need of some credit
Posts: 7
Joined: Wed May 13, 2020 4:08 pm

Re: MSW: Migration from 3.0.4 to 3.1.3 slows down (freezes) layout in wxScrolledWindow

Post by hneubauer » Thu May 14, 2020 12:46 pm

Yes, the problem exists in the release and debug version. It doesn't matter which version you use.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2387
Joined: Sun Jan 03, 2010 5:45 pm

Re: MSW: Migration from 3.0.4 to 3.1.3 slows down (freezes) layout in wxScrolledWindow

Post by PB » Thu May 14, 2020 12:58 pm

I can confirm the issue, running the provided (not sure how realistic) example.

Even my not so slow system is brought to it knees when the application is launched (Win10, MSVC 2019, wxWidgets master), regardless of Debug/Release configuration.
scrollprof.png
scrollprof.png (62.53 KiB) Viewed 160 times
The code compiled with 3.0.4 seems to run just fine even in the Debug build.
Last edited by PB on Thu May 14, 2020 1:03 pm, edited 1 time in total.

catalin
Moderator
Moderator
Posts: 1565
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: MSW: Migration from 3.0.4 to 3.1.3 slows down (freezes) layout in wxScrolledWindow

Post by catalin » Thu May 14, 2020 1:02 pm

Can you break in a debugger during startup?

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2387
Joined: Sun Jan 03, 2010 5:45 pm

Re: MSW: Migration from 3.0.4 to 3.1.3 slows down (freezes) layout in wxScrolledWindow

Post by PB » Thu May 14, 2020 1:11 pm

I wonder if this commit has anything to do with the issue
https://github.com/wxWidgets/wxWidgets/ ... e6ecf9f79e

Should not be hard to test the version before it and with it... However, that could possibly find the issue but not fix it.

But how the OP's code could properly work when the frame client size was over the SHORT range?

catalin
Moderator
Moderator
Posts: 1565
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: MSW: Migration from 3.0.4 to 3.1.3 slows down (freezes) layout in wxScrolledWindow

Post by catalin » Thu May 14, 2020 1:26 pm

Another test would be to add Some Freeze()/Thaw() in MSWMoveWindowToAnyPosition(), around ::ScrollWindow() calls.

The problem with positioning children outside Short range was visible only when scrolling to / over maximum Short values. Children located below those values would look just fine.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2387
Joined: Sun Jan 03, 2010 5:45 pm

Re: MSW: Migration from 3.0.4 to 3.1.3 slows down (freezes) layout in wxScrolledWindow

Post by PB » Thu May 14, 2020 1:31 pm

I may be wrong, but the code executed for large client sizes (added in a commit I referenced above) does not use deferred sizing, which could make it much more slower?

catalin
Moderator
Moderator
Posts: 1565
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: MSW: Migration from 3.0.4 to 3.1.3 slows down (freezes) layout in wxScrolledWindow

Post by catalin » Thu May 14, 2020 1:42 pm

Anything is possible, but the long time appears to be spent inside ::ScrollWindow(), which would be needed even if deferred sizing was used.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2387
Joined: Sun Jan 03, 2010 5:45 pm

Re: MSW: Migration from 3.0.4 to 3.1.3 slows down (freezes) layout in wxScrolledWindow

Post by PB » Thu May 14, 2020 1:48 pm

catalin wrote:
Thu May 14, 2020 1:26 pm
Another test would be to add Some Freeze()/Thaw() in MSWMoveWindowToAnyPosition(), around ::ScrollWindow() calls.
I have tried that (both for the window and its parent), did not help.
catalin wrote:
Thu May 14, 2020 1:42 pm
Anything is possible, but the long time appears to be spent inside ::ScrollWindow(), which would be needed even if deferred sizing was used.
It is possible. I thought the time spent there was due to a very high count of calls. But I do not understand complicated things, so I am likely wrong...

catalin
Moderator
Moderator
Posts: 1565
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: MSW: Migration from 3.0.4 to 3.1.3 slows down (freezes) layout in wxScrolledWindow

Post by catalin » Thu May 14, 2020 2:01 pm

Oh, so quickly! If you're still curious and still have some time, maybe you can just comment the 2 ::ScrollWindow() calls in MSWMoveWindowToAnyPosition() and see if that changes anything.

If ::ScrollWindow() is the cause, using deferred sizing along with it would not change anything.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2387
Joined: Sun Jan 03, 2010 5:45 pm

Re: MSW: Migration from 3.0.4 to 3.1.3 slows down (freezes) layout in wxScrolledWindow

Post by PB » Thu May 14, 2020 3:36 pm

catalin wrote:
Thu May 14, 2020 2:01 pm
Oh, so quickly! If you're still curious and still have some time, maybe you can just comment the 2 ::ScrollWindow() calls in MSWMoveWindowToAnyPosition() and see if that changes anything.
It seems to help somewhat but the application is still quite unusable. With 3.0.4 everything is snappy.

Post Reply