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.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4235
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 » Thu May 14, 2020 3:45 pm

PB,
Maybe it is time to actually run a profiler and see where the time is spent?

Thank you.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2466
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 4:10 pm

ONEEYEMAN wrote:
Thu May 14, 2020 3:45 pm
PB,
Maybe it is time to actually run a profiler and see where the time is spent?
I profiled the code (see the picture in my first post in this thread), last few posts are based on the results.

hneubauer
Earned a small fee
Earned a small fee
Posts: 11
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 » Mon May 18, 2020 8:55 am

It is really great that you have found the cause of the problem so quickly here. Thanks a lot for that :).

If I see it right, there is no quick solution for the problem. Right? Is there any workaround that I can use to solve the problem?

Does it make sense that I patch the code of the old wxWidgets version into the new one as a workaround? What was the original problem that caused the change?

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2466
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 » Mon May 18, 2020 9:31 am

I would report the issue, at least on wx-users, if not create a ticket on wxTrac outright.

But I would also try the wxWidgets builds before and with the commit referenced above, to make sure it is really the root of the issue to make the things easier for wxWidgets developers...

EDIT
I tried building and running the example code with wxWidgets branches based on
  1. The commit assumed to be causing the issue reported in this thread: https://github.com/wxWidgets/wxWidgets/ ... e6ecf9f79e
  2. The commit preceding the commit from (1): https://github.com/wxWidgets/wxWidgets/ ... 323e9083c2
The code with (2) runs as expected, i.e., the frame shows immediately and can be normally resized. Neither applies for the code based on commit (1).

To conclude, it seems that our suspection that the fix for the large client area causes the issue reported in this thread was correct.

catalin
Moderator
Moderator
Posts: 1575
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 » Mon May 18, 2020 10:37 am

PB wrote:
Mon May 18, 2020 9:31 am
The code with (2) runs as expected, i.e., the frame shows immediately and can be normally resized.
I'm still curious about what "as expected" should actually mean. From what I tried, by disabling the code in that commit (changed MSWIsPositionDirectlySupported() to always return true), the frame did show immediately, but that was pretty much the only positive effect. Resizing and scrolling were still awfully slow (as describes in bug #15766, years before the mentioned change), and positioning of windows only worked for values below short limit (just scroll down until you see a large blank area where window positioning has no effect any longer). Do you mean that you did not see any of those problems in the build without that workaround?

In current code, the problem for me seems to be with large client size and many child windows positioned after the 'short' limit. I'm on Win 10 with all latest updates (or somewhere very close to that).

hneubauer
Earned a small fee
Earned a small fee
Posts: 11
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 » Mon May 18, 2020 10:51 am

I know the problem of not showing children at large size.

We use our own scrollbars and therefore overwrite some methods of the wxScrolledWindow. And after some trial and error, it has proven to be a workaround to trigger a layout in the DoScroll method when the virtual size reaches about 32000 pixels.

For performance reasons this was not great, but still worked halfway fluently with about 1000 children and an average computer.

Code: Select all

void ScrollPanelWindow::DoScroll(int x, int y) {

   // set own scrollbar
   setCustomPickerPos(y);

   // ugly workaround for Windows to avoid cutting of children
   m_win->Layout();

   wxScrolledWindow::DoScroll(x, y);

}

catalin
Moderator
Moderator
Posts: 1575
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 » Mon May 18, 2020 10:59 am

Can you try with changing wxWindowMSW::MSWIsPositionDirectlySupported() to always return true, and see if your workaround still runs as in the older version?

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2466
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 » Mon May 18, 2020 12:21 pm

catalin wrote:
Mon May 18, 2020 10:37 am
PB wrote:
Mon May 18, 2020 9:31 am
The code with (2) runs as expected, i.e., the frame shows immediately and can be normally resized.
I'm still curious about what "as expected" should actually mean. From what I tried, by disabling the code in that commit (changed MSWIsPositionDirectlySupported() to always return true), the frame did show immediately, but that was pretty much the only positive effect. Resizing and scrolling were still awfully slow (as describes in bug #15766, years before the mentioned change), and positioning of windows only worked for values below short limit (just scroll down until you see a large blank area where window positioning has no effect any longer). Do you mean that you did not see any of those problems in the build without that workaround?
I have not done any extensive testing, just cursory observation.

Fixed version (commit 5784745 i.e. introducing MSWMoveWindowToAnyPosition())
When launching the application, the computer (Windows 10.0.18362.836, AMD Ryzen 5 2600, 16 GB RAM, Geforce RTX 2060) becomes unresponsive for 20+ seconds before the frame fully appears.
Resizing is virtually impossible (the frame size lags way too much behind cursor movement), just hovering the mouse cursor on the gripper seems to be enough to make the frame unresponsive.
Scrolling speed seems normal.
All the panels are displayed.

Unfixed version (commit f751f15)
When launching the application, the frame appears and become responsive immediately.
I do not experience any unexpected lag when scrolling and resizing the frame.
The panels in the bottom third or so of the frame are not displayed.

hneubauer
Earned a small fee
Earned a small fee
Posts: 11
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 » Mon May 25, 2020 5:17 am

Good morning,

I needed some time to build a new version of wxWidgets with wxWindowMSW::MSWIsPositionDirectlySupported() to always returning true, but now I can test builds with code changes myself :).

And indeed, my workaround works. It runs still as in the older version. In my minimal example I don't use our own scrollbar instead of the original and there it is possible to see both effects. Scrolling with the scrollbar shows the cut children at some position (it seems there is DoScroll not called). Scrolling with keyboard and overwritten DoScroll-Method using Layout shows the children.

hneubauer
Earned a small fee
Earned a small fee
Posts: 11
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 » Mon May 25, 2020 5:22 am

May I perhaps ask one of you to report the issue as you understand the background of the problem, while I am more or less a user and don't really have expertise when it comes to the depths of wxWidgets.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2466
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 » Tue May 26, 2020 9:25 am

I realized only quite deep in the thread that catalin here is probably catalinr who actually wrote MSWMoveWindowToAnyPosition(). So I guess he will take care of reporting or even fixing the issue.

catalin
Moderator
Moderator
Posts: 1575
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 » Tue May 26, 2020 11:06 am

PB wrote:
Tue May 26, 2020 9:25 am
catalin here is probably catalinr who actually wrote MSWMoveWindowToAnyPosition().
:) Yup, guilty as charged... But my use case back then only had a few windows positioned beyond SHRT_MAX, and didn't notice this problem.
PB wrote:
Tue May 26, 2020 9:25 am
So I guess he will take care of reporting or even fixing the issue.
Actually I did intend to open a new bug about this, did not find the time and I'm still quite busy currently. But anybody can open a new bug, and a new person is even better :wink:.
As for fixing it, I don't even know what would be better, not ruling out disabling/reverting the current fix and applying [a more optimized version of] OP's workaround (another reason to have the OP involved in the bug report).

rsb
I live to help wx-kind
I live to help wx-kind
Posts: 156
Joined: Fri May 29, 2015 7:26 pm

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

Post by rsb » Wed Jul 08, 2020 3:29 pm

We have a similar problem using wxScrolledWindow. Scroll up and down, then move the dialog around and the
dialog freezes for about 30-40 seconds.

We build the application using wxWidgets version 3.1.0, Compiler MSVC 14 on Windows 10, Version 1909.

We found that when running the application on Windows 10, Version 2004 the problem goes away.
But we really want to fix this issue because not all Windows computers can be updated to this version.

Has there been any progress in solving this problem? Or a workaround?

Thanks.
RSB

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4235
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 Jul 08, 2020 3:35 pm

Hi,
Can you try the code in this thread to see if it solves it for you?

Thank you.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2466
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 » Wed Jul 08, 2020 3:46 pm

I think the issue may be related to ticket 15766.

It is stated there it is a MS Windows problem, see here for more information and possible workaround
https://trac.wxwidgets.org/ticket/15766#comment:22

Post Reply