Discussion:
Painfully slow scrolling with wxScrolledWindow when using mouse window
Alec Teal
2014-07-07 06:18:53 UTC
Permalink
Hello there,

Sorry to ask but a quick search said that is issue was resolved 6 years ago:
http://trac.wxwidgets.org/ticket/2251

I am using wxWidgets 2.8 (yes still) and I can't believe I am the first
to come across this.

When scrolling it is churning through at 100% CPU about 3-5 times per
second (on a good computer, but the order of magnitude should be
concerning), regardless of whether or not I handle EVT_PAINT or I let it.

If anyone could help I'd be very grateful, I fear otherwise I shall
condition myself not to use the mousewheel!

Side-to-side scrolling works fine, it just seems to hate the wheel!

Alec
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Alec Teal
2014-07-07 06:27:39 UTC
Permalink
Quick update:

If I catch EVT_SCROLLWIN (on a different computer from where I found
this out, but if that is the wrong event wrong you know the event I
mean) and call refresh inside of it, and scroll I get about 10-14
"Scroll events" before it refreshes. It seems the mouse-wheel is
flooding events.

That said I am not quite sure why it is so slow! Unless there is some
syncing going on, but still 3-5 actual refreshes per second?

Alec
Post by Alec Teal
Hello there,
http://trac.wxwidgets.org/ticket/2251
I am using wxWidgets 2.8 (yes still) and I can't believe I am the
first to come across this.
When scrolling it is churning through at 100% CPU about 3-5 times per
second (on a good computer, but the order of magnitude should be
concerning), regardless of whether or not I handle EVT_PAINT or I let it.
If anyone could help I'd be very grateful, I fear otherwise I shall
condition myself not to use the mousewheel!
Side-to-side scrolling works fine, it just seems to hate the wheel!
Alec
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-07-07 17:03:16 UTC
Permalink
On Mon, 7 Jul 2014 07:18:53 +0100 Alec Teal wrote:

AT> I am using wxWidgets 2.8 (yes still) and I can't believe I am the first
AT> to come across this.

You must be doing something unusual. Please try testing scrolling in the
scroll sample which contains many different wxScrolledWindows, can you
reproduce the problem there? If you can't, try modifying the sample
(changing as little as possible) until you can. If you can, please test
with 3.0.1 (presumably with your changes to the sample from before because
without them things seem to work just fine for me) and check if the problem
is still present there. If it is, please open a ticket (make sure to
mention your platform). If it isn't, you should have your solution by now.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Alec Teal
2014-07-08 14:54:27 UTC
Permalink
Behavior replicated!

To replicate it I had to change the m_nLines in MyScrolledWindowBase to
something higher (like add two zeros)

In my program though I don't wish to draw text, it's actually just a
5000x5000 grid.

I'm not sure why it is slow, I understand for text (it has to wrap
lines) but in my case even when not drawing anything scrolling was the
problem.

Can you point me in the right direction for scrollbars? Or will I find
it in the wxBook? (Train journey tonight so please reply so I have the
message offline!)

Alec
AT> I am using wxWidgets 2.8 (yes still) and I can't believe I am the first
AT> to come across this.
You must be doing something unusual. Please try testing scrolling in the
scroll sample which contains many different wxScrolledWindows, can you
reproduce the problem there? If you can't, try modifying the sample
(changing as little as possible) until you can. If you can, please test
with 3.0.1 (presumably with your changes to the sample from before because
without them things seem to work just fine for me) and check if the problem
is still present there. If it is, please open a ticket (make sure to
mention your platform). If it isn't, you should have your solution by now.
Regards,
VZ
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Eric Jensen
2014-07-08 15:55:57 UTC
Permalink
Hello Alec,

Tuesday, July 8, 2014, 4:54:27 PM, you wrote:

AT> Behavior replicated!

AT> To replicate it I had to change the m_nLines in MyScrolledWindowBase to
AT> something higher (like add two zeros)

AT> In my program though I don't wish to draw text, it's actually just a
AT> 5000x5000 grid.

AT> I'm not sure why it is slow, I understand for text (it has to wrap
AT> lines) but in my case even when not drawing anything scrolling was the
AT> problem.

AT> Can you point me in the right direction for scrollbars? Or will I find
AT> it in the wxBook? (Train journey tonight so please reply so I have the
AT> message offline!)

AT> Alec
AT> I am using wxWidgets 2.8 (yes still) and I can't believe I am the first
AT> to come across this.
You must be doing something unusual. Please try testing scrolling in the
scroll sample which contains many different wxScrolledWindows, can you
reproduce the problem there? If you can't, try modifying the sample
(changing as little as possible) until you can. If you can, please test
with 3.0.1 (presumably with your changes to the sample from before because
without them things seem to work just fine for me) and check if the problem
is still present there. If it is, please open a ticket (make sure to
mention your platform). If it isn't, you should have your solution by now.
Regards,
VZ
Which OS are you using and what exactly is the content of your window?

If it's Windows 8.1 and many controls, it could be related to this problem:
http://trac.wxwidgets.org/ticket/15766

Eric
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Alec Teal
2014-07-09 01:43:42 UTC
Permalink
Linux Mint 13, 15 and 17 - MATE edition - all OSes show it.

I laughed a bit at windows 8.

Alec
Post by Eric Jensen
Hello Alec,
AT> Behavior replicated!
AT> To replicate it I had to change the m_nLines in MyScrolledWindowBase to
AT> something higher (like add two zeros)
AT> In my program though I don't wish to draw text, it's actually just a
AT> 5000x5000 grid.
AT> I'm not sure why it is slow, I understand for text (it has to wrap
AT> lines) but in my case even when not drawing anything scrolling was the
AT> problem.
AT> Can you point me in the right direction for scrollbars? Or will I find
AT> it in the wxBook? (Train journey tonight so please reply so I have the
AT> message offline!)
AT> Alec
AT> I am using wxWidgets 2.8 (yes still) and I can't believe I am the first
AT> to come across this.
You must be doing something unusual. Please try testing scrolling in the
scroll sample which contains many different wxScrolledWindows, can you
reproduce the problem there? If you can't, try modifying the sample
(changing as little as possible) until you can. If you can, please test
with 3.0.1 (presumably with your changes to the sample from before because
without them things seem to work just fine for me) and check if the problem
is still present there. If it is, please open a ticket (make sure to
mention your platform). If it isn't, you should have your solution by now.
Regards,
VZ
Which OS are you using and what exactly is the content of your window?
http://trac.wxwidgets.org/ticket/15766
Eric
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-07-08 22:47:37 UTC
Permalink
On Tue, 8 Jul 2014 15:54:27 +0100 Alec Teal wrote:

AT> Behavior replicated!
AT>
AT> To replicate it I had to change the m_nLines in MyScrolledWindowBase to
AT> something higher (like add two zeros)

Yes, I can see the problem when using 5000 lines, even not under Win8, so
it's not the same bug as mentioned before.

AT> I'm not sure why it is slow, I understand for text (it has to wrap
AT> lines) but in my case even when not drawing anything scrolling was the
AT> problem.

I didn't profile this properly (it would be nice if you took time to do
it), but the loop in wxScrollHelperBase::HandleOnMouseWheel() seems
suspicious to me. Can you add a

wxLogDebug("Sending %d scroll events", times);

line before it to see how many times is it called in your case? I suspect
dispatching (and redispatching) the same event again and again may take
quite some time on its own, wx event system is anything but efficient.

Unfortunately I don't have any ideas about how could this be optimized
easily. The straightforward way to do it would be to just scroll the window
directly in HandleOnMouseWheel() instead of forwarding to the event
handlers but this would break the existing code expecting to receive these
events for the mouse wheel too (in addition to scrollbar arrow presses and
cursor keys).

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Alec Teal
2014-07-09 01:45:41 UTC
Permalink
Post by Eric Jensen
AT> Behavior replicated!
AT>
AT> To replicate it I had to change the m_nLines in MyScrolledWindowBase to
AT> something higher (like add two zeros)
Yes, I can see the problem when using 5000 lines, even not under Win8, so
it's not the same bug as mentioned before.
AT> I'm not sure why it is slow, I understand for text (it has to wrap
AT> lines) but in my case even when not drawing anything scrolling was the
AT> problem.
I didn't profile this properly (it would be nice if you took time to do
it), but the loop in wxScrollHelperBase::HandleOnMouseWheel() seems
suspicious to me. Can you add a
wxLogDebug("Sending %d scroll events", times);
line before it to see how many times is it called in your case? I suspect
dispatching (and redispatching) the same event again and again may take
quite some time on its own, wx event system is anything but efficient.
Will do on Friday (I'm not near the computer ATM)
Post by Eric Jensen
Regards,
VZ
My solution for now is to use scrollbars instead. I do find it odd that
the slowdown occurs though - with text I can see why (it has to wrap it
and stuff) but with an empty space?

Most curious, I shall look into it!
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Loading...