Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Nosferax on March 11, 2010, 12:24:52 am

Title: Slow scrolling? [Ubuntu]
Post by: Nosferax on March 11, 2010, 12:24:52 am
Hi everyone!

I am using code blocks and so far I have had a better experience than with Eclipse, which is really nice because I want to get rid of that app really bad (memory hog, laggy interface, whatever).

I am experiencing slow scrolling (for pretty much all scrollbars of code blocks, but it is different for the editor window).

In the editor window, if I scroll fast, every full scroll (i.e. as much as I can) just scrolls about 6 lines of code, which is pretty much useless. However if I scroll -slowly- waiting half a second before each increment of mouse wheel it will go down about 20ish lines of code for the same number of mouse wheel increments. I don't know if I am clear enough. Some mouse events seem to be forgotten/not catched.

For the rest, it is often a feeling of sluggishness.. if I compare to other applications, scrolling feels sharp and instantaneous, however in code blocks there seems to be a little lag between the scrolling and the actual update of the GUI. Exemple of places where I remarked this are the Project file browser and the 'Start here' pane. This one seems trickier even.. Anyone else experienced this?

I am using this under Ubuntu 9.10 32 bit and using an SVN build (revision 6181). Computer is not extremely powerful but decent enough to run other applications fine :P (Intel centrino 1.6Ghz and 1G ram).

[Btw sorry if this is in the wrong forum...]

Thanks!
Nox
Title: Re: Slow scrolling? [Ubuntu]
Post by: oBFusCATed on March 11, 2010, 12:31:20 am
Does scite (another editor, which uses the same editor component as c::b) scroll fast with the same file?
Title: Re: Slow scrolling? [Ubuntu]
Post by: Nosferax on March 12, 2010, 08:31:51 pm
I tested with scite and it doesn't scroll as slow. There are jumps in the document but it scrolls a lot more lines in one wheel roll.

Nox
Title: Re: Slow scrolling? [Ubuntu]
Post by: richarduk on March 13, 2010, 07:46:27 pm
I've noticed this too, and seems to be a lot worse in latest version. 8.02 does it but not that bad but my SVN 6187 version it's really bad.
Title: Re: Slow scrolling? [Ubuntu]
Post by: koso on March 13, 2010, 08:54:48 pm
Can you check your CPU usage during that "slow" scrolling?

In my case, it jumps higher than any other editors. And btw. in my case, scrolling using keyboard (holding down arrow) is also slow.

Im using Kubuntu 10.04 - self built svn trunk.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Nosferax on March 19, 2010, 01:05:07 am
CPU was higher than when idle, but it didn't max out. It stays between 20-35%.
Title: Re: Slow scrolling? [Ubuntu]
Post by: oBFusCATed on March 19, 2010, 10:48:25 am
CPU usage on my machine is around 35% on one of the cores, while scrolling (fast for me though).

Specs: q6600 @ 3.6 ghz  :lol:
Title: Re: Slow scrolling? [Ubuntu]
Post by: richarduk on March 22, 2010, 09:43:54 pm
Yes mine too is also around the 30% mark. Dual core AMD chip so no Intel monster speed demon. It really feels like the mouse wheel messages are being missed / ignored.
Title: Re: Slow scrolling? [Ubuntu]
Post by: koso on March 22, 2010, 09:56:09 pm
I am getting about 80% on one, and 60% on another core when scrolling with keyboard. It is C2D @ 1,66 GHz, probably in some sleep state (1000 GHz). I am using KDE4 enviroment + intel graphics card => even desktop effects are laggy :((
Title: Re: Slow scrolling? [Ubuntu]
Post by: Kalith on July 23, 2011, 03:41:58 pm
Sorry for the thread resurrection, but this issue is still present in the latest nightly (even 7288 from Jens' repository) with Ubuntu 11.04.

I don't know if this is related, but it seems to also impact on typing, which can get very unresponsive (half a second delay between key press and character written on screen), when the editor has been open for a while and many files (~15) are open (CPU is then 100%). Closing all files helps to reduce the typing delay, but scrolling is always slow (except, like the OP says, if you scroll slowly : then all scroll ticks are received and the scrolling amount is correct).
I've tried to disable all plugins and use a fresh configuration file but nothing changed.

A have a quite good CPU (4 cores, 2.4Ghz), better than the one I have on my XP machine, which runs perfectly.

Do you have any tip to solve this issue ? Is it a problem on my side or not ?
Title: Re: Slow scrolling? [Ubuntu]
Post by: oBFusCATed on July 23, 2011, 08:00:01 pm
What is the graphics cards? Does scite works fast? Have you tried to disable all plugins (even codecompletion)?
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on July 24, 2011, 11:51:13 am
Still no problems here.
And I have just a Core2Duo with 2MHz and 4GB Ram.
Graphics card is ATI/AMD X1400 Mobility, with free linux-driver.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Kalith on July 24, 2011, 10:33:54 pm
I have an Intel integrated graphics card (Intel(R) Ironlake Mobile GEM 20100330, I guess).
Scite is much faster than C::B, I can't feel any delay, and scrolling works well.
wyoEditor also, although fonts were not antialiased.

Quote from: myself
I've tried to disable all plugins and use a fresh configuration file but nothing changed.
... including CC, of course.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Kalith on August 10, 2011, 05:01:24 pm
I've recently tried Geany, which uses Scintilla and GTK2, and it works very well while rendering the exact same output.
That's not a very useful information, but I hope it can help you see what could cause such a big difference.
Title: Re: Slow scrolling? [Ubuntu]
Post by: secks on July 16, 2012, 06:00:31 pm
I've been seeing this ever since I started using c::b .. it drives me nuts .. if i do a full scroll using my mouse wheel in scite i scroll ~192 lines .. if i do the same in codeblocks i only scroll ~22 lines .. and this is on a beefy i7 box, although im using intel video ..

we have 6 developers here at the office all using c::b and we all are experiencing the same thing .. some have mint 11, some ubuntu, some amd, some i7, some q6600 .. i haven't had time to look into the actual cause of this (im not familiar with using wxScintilla) ..

does anyone have any clues as to what the issue might be?
Title: Re: Slow scrolling? [Ubuntu]
Post by: MortenMacFly on July 16, 2012, 06:13:03 pm
does anyone have any clues as to what the issue might be?
- Try to turn of CC
  -> if that help, try to only turn off real-time parsing of CC
- Try to turn off the SpellChecker plugin
- Try if other scintilla based editor like SciTE does slow-down, too
  -> if so, its a window manager issue
Title: Re: Slow scrolling? [Ubuntu]
Post by: secks on July 16, 2012, 06:18:17 pm
does anyone have any clues as to what the issue might be?
- Try to turn of CC
  -> if that help, try to only turn off real-time parsing of CC
- Try to turn off the SpellChecker plugin
- Try if other scintilla based editor like SciTE does slow-down, too
  -> if so, its a window manager issue
I tried --safe-mode (which should disable CC and spell checker) .. still the same effect ..
scite scrolls just fine .. as i mentioned scite scrolls about 10x more per full-wheel-scroll than does c::b
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on July 16, 2012, 10:39:53 pm
does anyone have any clues as to what the issue might be?
- Try to turn of CC
  -> if that help, try to only turn off real-time parsing of CC
- Try to turn off the SpellChecker plugin
- Try if other scintilla based editor like SciTE does slow-down, too
  -> if so, its a window manager issue
I tried --safe-mode (which should disable CC and spell checker) .. still the same effect ..
scite scrolls just fine .. as i mentioned scite scrolls about 10x more per full-wheel-scroll than does c::b

This is an old, old issue that hasn't been resolved. I spent a bunch of time trying to figure this out but I wasn't able to isolate the cause to a single factor. I can't remember if anyone tried running a minimal wxScintilla sample to see if the same performance issue shows up there. That may be worth exploring.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Kalith on July 16, 2012, 11:53:43 pm
What about wxWidgets samples (http://svn.wxwidgets.org/viewvc/wx/wxWidgets/trunk/samples/stc/) (if I understand correctly, wxScintilla has been integrated into wxWidget as wxStyledTextCtrl) ?
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on July 17, 2012, 12:03:28 am
What about wxWidgets samples (http://svn.wxwidgets.org/viewvc/wx/wxWidgets/trunk/samples/stc/) (if I understand correctly, wxScintilla has been integrated into wxWidget as wxStyledTextCtrl) ?

Is slow here too (wx2.9.5 from trunk).
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on July 17, 2012, 07:17:04 am
This is an old, old issue that hasn't been resolved. I spent a bunch of time trying to figure this out but I wasn't able to isolate the cause to a single factor. I can't remember if anyone tried running a minimal wxScintilla sample to see if the same performance issue shows up there. That may be worth exploring.

If I remember correctly there are two different issues:

The first issue can be related to several things, one is that the mousewheelevents are blocked as long as the last one took to be processed.
Quote from: wxScintilla::OnMouseWheel
    // Prevent having an event queue with wheel events that cannot be processed
    // reasonably fast (see ticket #9057) by ignoring all of them that happen
    // during the time interval corresponding to the time it took us to handle
    // the last one.

The second issue is a wxWidgets restriction, because the mousewheel-event always returns three as linesperaction.
We could work around that by introducing a (configurable) factor that is multiplied with the default number of linesperaction, in the call to DoMousewheel in wxScintilla::OnMouseWheel.
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on July 17, 2012, 04:13:25 pm
If I remember correctly there are two different issues:
  • the scrolling is slow, even if the scrollbar is dragged
  • the scrolling in priciple is fast enough, but the amount of lines scrolled per mousewheel-delta is very low

The first issue is the higher priority for me. On low end hardware, scrolling performance sucks (It's still noticeable, but good enough for me on my desktop). Others might feel more strongly about the mousewheel-delta.
Title: Re: Slow scrolling? [Ubuntu]
Post by: secks on July 17, 2012, 04:39:22 pm
Quote from: wxScintilla::OnMouseWheel
    // Prevent having an event queue with wheel events that cannot be processed
    // reasonably fast (see ticket #9057) by ignoring all of them that happen
    // during the time interval corresponding to the time it took us to handle
    // the last one.
This sounds like the culprit .. So it must be overhead from c::b that causes the events to hang and be discarded .. scite scrolls the same file at nearly 10x the lines per wheel..

The second issue is a wxWidgets restriction, because the mousewheel-event always returns three as linesperaction.
We could work around that by introducing a (configurable) factor that is multiplied with the default number of linesperaction, in the call to DoMousewheel in wxScintilla::OnMouseWheel.
This sounds like the only viable option .. I have a wedding coming up and am short on free time .. I'll look into it when I get a chance but I have no clue on when that will be .. If someone else can get to it before me, then by all means .....  :)
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on July 17, 2012, 04:50:53 pm
Quote from: wxScintilla::OnMouseWheel
    // Prevent having an event queue with wheel events that cannot be processed
    // reasonably fast (see ticket #9057) by ignoring all of them that happen
    // during the time interval corresponding to the time it took us to handle
    // the last one.
This sounds like the culprit .. So it must be overhead from c::b that causes the events to hang and be discarded .. scite scrolls the same file at nearly 10x the lines per wheel..
It was neither a C::B bug nor a C::B patch.
As far as I know, it is a wxScintilla patch, and you find it in wxwidgets stc also.
It is most probably related to wxwidgets event handling.
If I remove all the slowing stuff scrolling still works.
I did not look into the original bug-report, so I don't know whether it is really (still) needed or not.

The second issue is a wxWidgets restriction, because the mousewheel-event always returns three as linesperaction.
We could work around that by introducing a (configurable) factor that is multiplied with the default number of linesperaction, in the call to DoMousewheel in wxScintilla::OnMouseWheel.
This sounds like the only viable option .. I have a wedding coming up and am short on free time .. I'll look into it when I get a chance but I have no clue on when that will be .. If someone else can get to it before me, then by all means .....  :)

I can create a patch for it, but if it makes it into trunk is not only my decision.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on July 17, 2012, 04:52:39 pm
If I remember correctly there are two different issues:
  • the scrolling is slow, even if the scrollbar is dragged
  • the scrolling in priciple is fast enough, but the amount of lines scrolled per mousewheel-delta is very low

The first issue is the higher priority for me. On low end hardware, scrolling performance sucks (It's still noticeable, but good enough for me on my desktop). Others might feel more strongly about the mousewheel-delta.
I don't have a slowdown here, so it might be related to the graphics driver.
Did you test it with pure scite, so no wxwidgets-stuff is between scintilla and the system ?
Title: Re: Slow scrolling? [Ubuntu]
Post by: secks on July 17, 2012, 05:00:03 pm
I don't have a slowdown here, so it might be related to the graphics driver.
Did you test it with pure scite, so no wxwidgets-stuff is between scintilla and the system ?
I'm on Mint 12 - Lisa (oneiric) .. Using i7 intel video .. I installed scite from the repo (Version: 2.25-1) .. The scrolling is very fast (around 200-250 lines per full wheel) where c::b only does around 20

EDIT: also, another employee here has a nvidia geforce 8600 gts .. it's not the beefiest card, but that thing is only scrolling a few lines at a time ..
Title: Re: Slow scrolling? [Ubuntu]
Post by: secks on July 17, 2012, 05:08:21 pm
I install juffed and eric (qscintilla) .. those are slow too .. both are at ~50 lines
Title: Re: Slow scrolling? [Ubuntu]
Post by: Kalith on July 17, 2012, 05:48:30 pm
This sounds like the culprit .. So it must be overhead from c::b that causes the events to hang and be discarded ..
I'd say the fact that C::B scrolls slowly is a single symptom of a more general problem, that is the overall slowdown of the whole IDE when dealing with text rendering. I don't code on linux no more these days, but from what I recall, selecting and even typing text could become laggy (I wrote it in my first post in this topic, by the way, and also here (http://forums.codeblocks.org/index.php/topic,9266.0.html)).
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on July 17, 2012, 05:51:58 pm
If I remember correctly there are two different issues:
  • the scrolling is slow, even if the scrollbar is dragged
  • the scrolling in priciple is fast enough, but the amount of lines scrolled per mousewheel-delta is very low

The first issue is the higher priority for me. On low end hardware, scrolling performance sucks (It's still noticeable, but good enough for me on my desktop). Others might feel more strongly about the mousewheel-delta.

I don't have a slowdown here, so it might be related to the graphics driver.

Yes tested on various scintilla based editors, which were by and large free of the issue (I don't think I ever got around to testing the wxWidgets sample, but will do). My suspicion is that it is something specific to the wxWidgets wrapper. The bug fix implemented for that ticket #9057 (http://trac.wxwidgets.org/ticket/9057) is probably just masking the real bug (or performance problems) in the rendering/event pipeline.
Title: Re: Slow scrolling? [Ubuntu]
Post by: p2rkw on July 18, 2012, 03:05:00 am
So, it seems that is only linux related bug. Maybe its problem of wxGtk: http://comments.gmane.org/gmane.comp.lib.wxwidgets.devel/12412 and http://old.nabble.com/why-do-wxMac-and-wxGTK-always-erase-window-background--td20532056.html ?

btw. I can't find PlatGTK.cxx, found only PlatWX.cxx. What's location of this file?
Title: Re: Slow scrolling? [Ubuntu]
Post by: eranif on July 18, 2012, 06:31:14 am
Hello,

I wanted to add my 10 cents:

I also noticed performance problems on GTK few years ago on Linux while scrolling with the mouse.
After a long debugging sessions, I changed the following in my code:

- Never call SetStatusMessage directly from the editor, instead fire a custom event using 'AddPendingEvent' in the OnScintillaUpdateUI (EVT_SCI_UPDATEUI) event handler
so my code looks like this:

Code
void Editor::OnScintillaUpdateUI(wxScintillaEvent &e) 
{
...
//update line number
wxString message;

message << wxT("Ln ")
<< curLine+1
<< wxT(",  Col ")
<< GetColumn(pos)
<< wxT(",  Pos ")
<< pos;

// Always update the status bar with event, calling it directly causes performance degredation
DoSetStatusMessage(message, 1);
...
}

void Editor::DoSetStatusMessage(const wxString &msg, int col)
{
        // fire custom event
wxCommandEvent e(wxEVT_UPDATE_STATUS_BAR);
e.SetEventObject(this);
e.SetString(msg);
e.SetInt(col);
wxTheApp->GetTopWindow()->GetEventHandler()->AddPendingEvent(e);
}

- Line number margin: use a hard coded line margin width, calling TextWidth is a real pain under Linux:
Code
	// Line number margin
#ifdef __WXMSW__
int pixelWidth = 4 + 5*TextWidth(wxSCI_STYLE_LINENUMBER, wxT("9"));
#else
int pixelWidth = 4 + 5*8;
#endif

// Show number margin according to settings.
SetMarginWidth(NUMBER_MARGIN_ID, options->GetDisplayLineNumbers() ? pixelWidth : 0);

- Two phase drawing, buffered drawing settings are different from one OS to another here are the settings I am using:

Code
#if defined(__WXMAC__)
// turning off these two greatly improves performance
// on Mac
SetTwoPhaseDraw(false);
SetBufferedDraw(false);

#elif defined(__WXGTK__)
SetTwoPhaseDraw(true);
SetBufferedDraw(false);

#else // MSW
SetTwoPhaseDraw(true);
SetBufferedDraw(true);
#endif

Adding these 3 changes improved performance noticeably on GTK and Mac for me


Eran
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on July 18, 2012, 05:22:06 pm
Here's an update.

I played around with the stc example (both C++ and python). The test machine is a netbook running ubuntu 12.04. My test of scrolling responsiveness is to hold the down arrow key for about 10 seconds. On Code::Blocks, in safe mode, scrolling lags badly. I release the key and the editor keeps scrolling for another 10 seconds. I tried switching off the handlers to all of the wxSCI_EVT, but that didn't appear to do much. Similarly tried all of eranif's tips, with no obvious improvement. I also tried switching off some (but not all) idle handlers and timers, and all of the styling calls.

When I run the wxWidgets samples (both C++ and Python) there is no lag. Scrolling stops when you release the key. (I wouldn't say that scrolling is super snappy, however.) Could it be something as simple as the key repeat rate in C::B being set too high?

What is left to switch off in C::B that might help isolate the cause?
Title: Re: Slow scrolling? [Ubuntu]
Post by: oBFusCATed on July 18, 2012, 05:48:23 pm
dmoore: Have you tried to use a profiler? oprofile for example?
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on July 18, 2012, 11:42:55 pm
dmoore: Have you tried to use a profiler? oprofile for example?

Someone would suggest a rational approach...  :-[

Is oprofile any better than perf? I tried running perf, but the output didn't seem all that useful (most likely user error). I couldn't figure out if there  was a way to collapse the lower level calls into the calling code::blocks routines. In the run I did there was a lot of time spent in cairo and pango calls, but that's not really surprising when all i was doing was scrolling.

I also tried valgrind, but having some weird ubuntu issue with callgrind_control:

Code
moi@home:~$ callgrind_control 
No active callgrind runs detected.

I guess the biggest difference between C::B and the STC sample is the sheer size of C::B. Would it make sense that a single STC event will propagate through many more handlers in C::B than in  a stripped down sample?
Title: Re: Slow scrolling? [Ubuntu]
Post by: oBFusCATed on July 19, 2012, 12:50:30 am
dmoore: Is this perf: https://perf.wiki.kernel.org/index.php/Main_Page ?
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on July 19, 2012, 01:21:20 am
dmoore: Is this perf: https://perf.wiki.kernel.org/index.php/Main_Page ?

Yep.
Title: Re: Slow scrolling? [Ubuntu]
Post by: MortenMacFly on July 19, 2012, 07:57:05 am
Quote from: dmoore
I guess the biggest difference between C::B and the STC sample is the sheer size of C::B. Would it make sense that a single STC event will propagate through many more handlers in C::B than in  a stripped down sample?
Did you try:
- temporarily really *remove* all plugins, so C::B becomes an editor
- create a scintilla project using wxSmith with an embedded wxScintilla control?
- did you try to disable "hijacking" the scintilla events in cbEditor:
  - do not connect the events not really needed in cbEditor::CreateEditor
?
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on July 22, 2012, 05:51:30 pm
A few more tests...

So I suspect the problem really is a result of the sheer size of C::B and the number of events floating around. (Of course it's still possible there is some issue with too many events being fired off)

Quote from: wxScintilla::OnMouseWheel
   // Prevent having an event queue with wheel events that cannot be processed
    // reasonably fast (see ticket #9057) by ignoring all of them that happen
    // during the time interval corresponding to the time it took us to handle
    // the last one.
This sounds like the culprit .. So it must be overhead from c::b that causes the events to hang and be discarded .. scite scrolls the same file at nearly 10x the lines per wheel..

Given it looks like it is going to be hard to improve overall performance, why don't we come up with a better patch for this one. To be clear, this would help resolve the issue that user secks reported: when you scroll the mousewheel really quickly you get far less movement than if you had scrolled the same amount, but moving the mousewheel slowly. Perhaps one simple workaround would be to discard mousewheel events based on the lower of the time it took to process the last one and some absolute threshold (instead of just looking at the time to process that last one).
Title: Re: Slow scrolling? [Ubuntu]
Post by: oBFusCATed on July 22, 2012, 05:56:08 pm
What are the steps to reproduce the slow scrolling?
On my machine gentoo 64bit+core2quad+nvidia binary scrolling is responsive and non-laggy.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on July 22, 2012, 07:00:25 pm
Quote from: wxScintilla::OnMouseWheel
   // Prevent having an event queue with wheel events that cannot be processed
    // reasonably fast (see ticket #9057) by ignoring all of them that happen
    // during the time interval corresponding to the time it took us to handle
    // the last one.
This sounds like the culprit .. So it must be overhead from c::b that causes the events to hang and be discarded .. scite scrolls the same file at nearly 10x the lines per wheel..

Given it looks like it is going to be hard to improve overall performance, why don't we come up with a better patch for this one.

If we do so, we should post it in wxWidgets mailing list also, because it's a wxWidgets patch and not a C::B patch.
And it only affects the scrolling with the mouse-wheel and not the scrolling at all.
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on July 22, 2012, 07:22:34 pm
What are the steps to reproduce the slow scrolling?
On my machine gentoo 64bit+core2quad+nvidia binary scrolling is responsive and non-laggy.

Wouldn't be surprised if it was a Ubuntu problem.

To reproduce:
1. Open a large cpp file with lots of text on each line
2. Compare
a. Ripping the mouse wheel really quickly
b. Moving the mouse wheel slowly the same distance
3. Hold down arrow for about 10s. When you release scrolling will continue for several seconds.

My desktop is 2 yo dual core, older nvidia card. Ubuntu 12.04
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on July 22, 2012, 07:42:38 pm

If we do so, we should post it in wxWidgets mailing list also, because it's a wxWidgets patch and not a C::B patch.
And it only affects the scrolling with the mouse-wheel and not the scrolling at all.

Agree on both counts.

Perhaps a better fix than my first suggestion would be to put a cap on how many mousewheel events get queued. Events should only be discarded after exceeding a decent threshold. (Should be willing to trade off a little lag).
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on July 23, 2012, 11:40:07 am
A little test from my side:

So it looks like it's obviously related to doing the text layout in scintilla.
But the obvious is not necessary the truth, so further investigation is needed.

By the way making the amount of lines per wheel-click configurable is a good thing in my opinion.
Shall I prepare a patch for it ?
Title: Re: Slow scrolling? [Ubuntu]
Post by: oBFusCATed on July 23, 2012, 11:43:38 am
By the way making the amount of lines per wheel-click configurable is a good thing in my opinion.
Shall I prepare a patch for it ?
I think the problem with the scrolling is that there is no acceleration, not that the scrolling is slow.
At least firefox seems to have some acceleration in it, but I may be wrong as my mouse doesn't have a lock which limits the rotations (the mechanism making the mouse click when scrolling).
Title: Re: Slow scrolling? [Ubuntu]
Post by: MortenMacFly on July 23, 2012, 01:51:11 pm
Shall I prepare a patch for it ?
Feel free to do. I have some changes related to wxScintilla pending, but I can handle...
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on July 23, 2012, 05:00:15 pm
By the way making the amount of lines per wheel-click configurable is a good thing in my opinion.
Shall I prepare a patch for it ?
I think the problem with the scrolling is that there is no acceleration, not that the scrolling is slow.
At least firefox seems to have some acceleration in it, but I may be wrong as my mouse doesn't have a lock which limits the rotations (the mechanism making the mouse click when scrolling).

put another way, discarding mousewheel events prevents scrolling above a certain speed.

EDIT: I should add that I think making the mousewheel scrolling increment customizable is nonetheless a good idea. Happy to test a patch.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on July 23, 2012, 09:03:57 pm
Could you please test the attached patch to Editor.cxx.

It should optimize scrolling of just a few lines, but at least on gtk (when calling ScintillaWX::ScrollText() ) it seems to slow down scrolling a lot.
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on July 24, 2012, 03:32:07 am
Could you please test the attached patch to Editor.cxx.

It should optimize scrolling of just a few lines, but at least on gtk (when calling ScintillaWX::ScrollText() ) it seems to slow down scrolling a lot.

Well done Jens! Looks like that's the fix. Many thanks. I don't think I would ever have found this myself. (Curious how you figured out that this was the problem).

This appears to fix mousewheel scrolling too! (or trackpad scrolling, at least)

So the odd thing is that, at least for me, those calls seemed to only create problems with C::B. When I run the STC sample I don't have a problem. Even if I put a scintilla widget in a separate window in C::B, which you think would be as close to the wxWidgets STC sample as possible, the problem returns. Is it possible that the drawing to screen was creating problems with wxAUI?
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on July 24, 2012, 04:06:48 am
So this is odd:

Code
void Editor::ScrollText(int /* linesToMove */) {
//Platform::DebugPrintf("Editor::ScrollText %d\n", linesToMove);
Redraw();
}

So if they hadn't done this

Code
void ScintillaWX::ScrollText(int linesToMove) {
    int dy = vs.lineHeight * (linesToMove);
    sci->ScrollWindow(0, dy);
    sci->Update();
}

(Editor is a base class of SctinillaWX)

Then there would be no lag.
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on July 24, 2012, 04:16:11 am
So this patch actually seems to give slightly better performance

Code
Index: src/sdk/wxscintilla/src/ScintillaWX.cpp
===================================================================
--- src/sdk/wxscintilla/src/ScintillaWX.cpp (revision 8138)
+++ src/sdk/wxscintilla/src/ScintillaWX.cpp (working copy)
@@ -417,7 +417,7 @@
 void ScintillaWX::ScrollText(int linesToMove) {
     int dy = vs.lineHeight * (linesToMove);
     sci->ScrollWindow(0, dy);
-    sci->Update();
+//    sci->Update(); //causes slow-down on GTK+ systems (Linux)
 }
 
 void ScintillaWX::SetVerticalScrollPos() {

I don't know if the missing Update will create artifacts? I didn't see any issues. (Maybe on windows? -- I did not test)
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on July 24, 2012, 05:28:04 am
We can probably also drop the crap related to ticket #9057. (Although it doesn't seem to do any harm either)

BTW, comparing scite with C::B without the sci->update call:
* by default, scite scrolls 4 lines per wheel motion vs 3 lines in C:::B.
* a full mousewheel motion (moving as much as possible in one motion) in scite scrolls about 70 lines vs 35 lines in C::B.

I personally prefer C::B's current behavior, but it would be good to add the customization to the lines per motion. But perhaps scite also allows for some acceleration of the step size upon repeated moves? That might be nice to have.
Title: Re: Slow scrolling? [Ubuntu]
Post by: MortenMacFly on July 24, 2012, 06:20:28 am
Could you please test the attached patch to Editor.cxx.
Ah - my favourite again: "Error: Chunk info expected.". :( Nevermind - these few lines I can do by hand... :P
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on July 24, 2012, 06:23:39 am
Could you please test the attached patch to Editor.cxx.
Ah - my favourite again: "Error: Chunk info expected.". :( Nevermind - these few lines I can do by hand... :P

The one liner I propose about would be instead of the one Jens supplied (a mere refinement of his fine work, of course).
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on July 24, 2012, 06:39:13 am
Could you please test the attached patch to Editor.cxx.
Ah - my favourite again: "Error: Chunk info expected.". :( Nevermind - these few lines I can do by hand... :P
I will test it with tortoise later the day.
It should wotk, but I removed the comment lines from git manually, maybe I removed too much (it was late yesterday).
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on July 24, 2012, 06:47:28 am
So this is odd:

Code
void Editor::ScrollText(int /* linesToMove */) {
//Platform::DebugPrintf("Editor::ScrollText %d\n", linesToMove);
Redraw();
}

So if they hadn't done this

Code
void ScintillaWX::ScrollText(int linesToMove) {
    int dy = vs.lineHeight * (linesToMove);
    sci->ScrollWindow(0, dy);
    sci->Update();
}

(Editor is a base class of SctinillaWX)

Then there would be no lag.
I thought about doing this way, but I decided to patch scintilla's sources (again), because the (admittedly small) overhead for is not needed at all.
I did not do any exact measuring which of the two ways is shorter.
But the original ScrollTo took about 35 ~ 50 ms per line and the "new" one takes 0 ~ 1 ms, so it does not really matter if it is takes another 0.5 ms or not I think.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on July 24, 2012, 06:47:45 am
We can probably also drop the crap related to ticket #9057. (Although it doesn't seem to do any harm either)

BTW, comparing scite with C::B without the sci->update call:
* by default, scite scrolls 4 lines per wheel motion vs 3 lines in C:::B.
* a full mousewheel motion (moving as much as possible in one motion) in scite scrolls about 70 lines vs 35 lines in C::B.

I personally prefer C::B's current behavior, but it would be good to add the customization to the lines per motion. But perhaps scite also allows for some acceleration of the step size upon repeated moves? That might be nice to have.

At least the amount of scrolled lines can be made configurable (as posted before), because wxWidgets uses three lines in any cases (until) they find a way to find the systems preferred scroll amount.
It might also be possible to accelerate the scrolling, if more scroll events come in in short time, but this needs a threshhold to determin what is short and a threshhold for the maximal acceleration.
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on July 24, 2012, 06:55:09 am
I thought about doing this way, but I decided to patch scintilla's sources (again), because the (admittedly small) overhead for is not needed at all.
I did not do any exact measuring which of the two ways is shorter.
But the original ScrollTo took about 35 ~ 50 ms per line and the "new" one takes 0 ~ 1 ms, so it does not really matter if it is takes another 0.5 ms or not I think.

On my netbook I thought there was a slight performance improvement to doing the patch the way I proposed (just removing the sci->Update call). I could be imagining things, but it did seem to help to have the partial scroll instead of full redraw.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on July 24, 2012, 07:46:58 am
I did a short mesurement with wx2.9, because the stopwatch there has µs.
The avaregd time call to ScrollTo differs for about 25 µs, so it is probably better to change ScintillWX instead of scintilla's sources (again).
Title: Re: Slow scrolling? [Ubuntu]
Post by: MortenMacFly on July 24, 2012, 08:50:17 am
so it is probably better to change ScintillWX instead of scintilla's sources (again).
...meaning your patch is obsolete and superseeded by the ones of dmoore? I wonder if it has side-effects on Windows...
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on July 24, 2012, 10:33:56 am
so it is probably better to change ScintillWX instead of scintilla's sources (again).
...meaning your patch is obsolete and superseeded by the ones of dmoore? I wonder if it has side-effects on Windows...
It's basically the same, it avoids the call of wxWindows::Update() on every scrol, which immediately updates the whole invalidated area.
But the original scintilla Redraw() invalidates the whole client area and the other one (most likely) only the scrolled part.

But in both cases real repainting is done later.

I will test it on windows.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on July 24, 2012, 01:54:04 pm
As far as I see, it works fine on windows 7 with wx2.8 and actual trunk.

By the way:
the patch I attached above works flawlessly with my tortoise 1.7.7, so it might be (another) issue of SmartSVN with patches.
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on July 24, 2012, 03:17:36 pm
As far as I see, it works fine on windows 7 with wx2.8 and actual trunk.

Any thoughts on removing the ticket #9057 junk?

Also, the advantage of patching wx instead of scintilla is at least the wx guys are likely to accept the patch in the next 5 years. :)
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on July 24, 2012, 03:28:27 pm
As far as I see, it works fine on windows 7 with wx2.8 and actual trunk.

Any thoughts on removing the ticket #9057 junk?

Also, the advantage of patching wx instead of scintilla is at least the wx guys are likely to accept the patch in the next 5 years. :)
I will open a ticket there or probably reopen #9057 this evening.

And as far as I can see the "workaround" is no longer needed and can therefore be removed.

Other devs:
any objections against doing it ?
Removing the #9057 "workaround" and the problematic call to update ?

If not I will commit it this evening.

If the whole C::B breaks down  :P , we can still revert it.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on July 30, 2012, 12:19:00 am
The fixes have been committed to wxWidgets trunk:
http://trac.wxwidgets.org/changeset/72254 (http://trac.wxwidgets.org/changeset/72254)
http://trac.wxwidgets.org/changeset/72255 (http://trac.wxwidgets.org/changeset/72255)
Title: Re: Slow scrolling? [Ubuntu]
Post by: Kalith on July 30, 2012, 02:44:13 am
That is good news! Does that mean we'll see these patches applied in the next nightly?
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on July 30, 2012, 08:04:08 am
That is good news! Does that mean we'll see these patches applied in the next nightly?
We do not use wxSTC, but a more or less patrched version based on it.

The changes are in our sources since a week and will therefore be in the next nightly, or if you use my debian or RedHat/CentOS repo you have it there already.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Kalith on July 30, 2012, 02:29:57 pm
I can confirm the two patches work very well. Thank you :)
Title: Re: Slow scrolling? [Ubuntu]
Post by: secks on July 30, 2012, 08:00:36 pm
the patches did speed it up a bit .. instead of getting 20 some lines i now get around 100 per full-wheel-scroll :) a coworker here was only scrolling 3 or so lines lol .. his bumped up to around 30 now .. weeeeeeeeeeee!  thanks for taking time on this one everyone
Title: Re: Slow scrolling? [Ubuntu]
Post by: Alpha on September 02, 2012, 04:18:50 am
It's basically the same, it avoids the call of wxWindows::Update() on every scrol, which immediately updates the whole invalidated area.
But the original scintilla Redraw() invalidates the whole client area and the other one (most likely) only the scrolled part.
It seems that matching brace highlights, which should be invalidated (and redrawn) no longer are consistently.
Code
int main()
{
    return 0;
}|
Place the cursor where the pipe symbol is, then press the up arrow key once.  The first curly brace remains highlighted.

Could this be related to the changes discussed in this thread?

(Ubuntu LTS 32bit; svn 8328)
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on September 02, 2012, 08:54:00 am
It's basically the same, it avoids the call of wxWindows::Update() on every scrol, which immediately updates the whole invalidated area.
But the original scintilla Redraw() invalidates the whole client area and the other one (most likely) only the scrolled part.
It seems that matching brace highlights, which should be invalidated (and redrawn) no longer are consistently.
Code
int main()
{
    return 0;
}|
Place the cursor where the pipe symbol is, then press the up arrow key once.  The first curly brace remains highlighted.

Could this be related to the changes discussed in this thread?

(Ubuntu LTS 32bit; svn 8328)
I can not reproduce it here.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Alpha on September 03, 2012, 01:55:28 am
I can not reproduce it here.
Code
word word word word word word word word

word word word word word


word word word word word word word word


word word


word word word
Select the last "word" - all of the words should be highlighted (this is normal).  Press the up arrow key once.  On Windows Vista; svn 8330, all the words except the last three remain highlighted.

If no one can duplicate it, maybe something is wrong with my computer.  (However, I do not believe this is the case.  These problems are not present in my tests of svn 8133.)
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on September 03, 2012, 03:43:41 am
I can not reproduce it here.
Code
... word ...
Select the last "word" - all of the words should be highlighted (this is normal).  Press the up arrow key once.  On Windows Vista; svn 8330, all the words except the last three remain highlighted.

If no one can duplicate it, maybe something is wrong with my computer.  (However, I do not believe this is the case.  These problems are not present in my tests of svn 8133.)
I confirm (ubuntu 12.04, latest trunk). Why do these features rely on the update call and other feature not?
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on September 04, 2012, 09:17:02 pm
If I move the caret away from the selected word, the word gets unselected and all the other highlighted words are shown normal.
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on September 04, 2012, 09:57:40 pm
If I move the caret away from the selected word, the word gets unselected and all the other highlighted words are shown normal.

Well, I still have the problem, but it has nothing to do with the small patch you applied here. I tried reverting the patch and it made no difference. Also tried from a fresh config and still have the problem. Note that the problem only occurs when you move the cursor with either keyboard or mouse, but don't scroll. As soon as you scroll the full screen refreshes.
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on September 04, 2012, 10:52:50 pm
This patch might do the trick, but not sure if that kills performance on Linux again

Code
Index: src/sdk/cbeditor.cpp
===================================================================
--- src/sdk/cbeditor.cpp (revision 8351)
+++ src/sdk/cbeditor.cpp (working copy)
@@ -502,6 +504,8 @@
         // Set Styling:
         // clear all style indications set in a previous run (is also done once after text gets unselected)
         m_pOwner->GetControl()->IndicatorClearRange(0, eof);
+        m_pOwner->GetControl()->Refresh();
 
         // check that feature is enabled,
         // selected text has a minimal length of 3 and contains no spaces
Title: Re: Slow scrolling? [Ubuntu]
Post by: Alpha on September 05, 2012, 02:28:09 am
Bisected: revision 8278 introduces the problem.  Something must have gone wrong with the Scintilla update.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on September 05, 2012, 06:34:53 am
So we should not touch it for the moment, but search the real cause.

Now I see it here also (I tested it with 8248).
Hope to find it soon.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on September 05, 2012, 11:03:50 am
First I thoght it is caused by changes in ScintillWX.cpp:DoPaint(), but it works correctly in the stc-sample of wxWidgets trunk (after patching it to highlight occurrences).
And they have the same changes (in fact they are taken from there, I guess).
The call to Refresh as workaround, after the ClearRange call should not be too harmful.
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on September 05, 2012, 04:41:30 pm
I think the issue is in Editor::NotifyModified (line 4578 of Editor.cxx), in particular:

Code
	if (mh.modificationType & (SC_MOD_CHANGESTYLE | SC_MOD_CHANGEINDICATOR)) {
if (mh.modificationType & SC_MOD_CHANGESTYLE) {
pdoc->IncrementStyleClock();
}
if (paintState == notPainting) { //  ***********************
if (mh.position < pdoc->LineStart(topLine)) {
// Styling performed before this view
Redraw();
} else {
InvalidateRange(mh.position, mh.position + mh.length);
}
}
if (mh.modificationType & SC_MOD_CHANGESTYLE) {
llc.Invalidate(LineLayout::llCheckTextAndStyle);
}


Because we have a cursor move paintstate!=notPainting, (see the line marked with ********) but that cursor move only invalidates the region between the new and old positions, we don't get the full redraw that we need. A simple (but potentially inefficient) fix would be to skip the paintstate check.

I think we could also make a highlight mode code a little more efficient by only clearing the highlight if we have previously set it.
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on September 05, 2012, 04:55:44 pm
btw, either approach seems to work fine on my netbook (doesn't slow things down too much). I would still advocate reducing the number of ClearRange calls, because that could be expensive on a really big file.

I don't understand why this wouldn't also affect the wx demo.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on September 05, 2012, 04:57:47 pm
What makes me wonder, is that IncrementalSearch still works, but HighlightOccurrences does not.
And the ClearRange code is the same in both cases.

We can do the Refresh as workaround for the moment, but it looks like there must be some deeper issue that should be fixed, before it bites us at another place.

At the moment I would prefer not to change the (wx)scintilla code, if it is not definitely caused by it.
But (as I posted) before, HighlightOccurrences work with wxSTC and IncrementaSearch works with "our" wxScintilla.
So it might still be something in ouzr code, probably in our (wx)scintilla-changes.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on September 05, 2012, 04:58:59 pm
btw, either approach seems to work fine on my netbook (doesn't slow things down too much). I would still advocate reducing the number of ClearRange calls, because that could be expensive on a really big file.

I don't understand why this wouldn't also affect the wx demo.

ClearRange is only called once for every selection change, so it does not happen too often.
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on September 05, 2012, 05:02:21 pm
ClearRange is only called once for every selection change, so it does not happen too often.

probably right, but scrolling by holding the down arrow on a really big file could have a decent sized performance hit. (think of the children... err... netbooks)
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on September 05, 2012, 05:17:13 pm
What makes me wonder, is that IncrementalSearch still works, but HighlightOccurrences does not.
And the ClearRange code is the same in both cases.

because (painstate==notpainting)  == true for incremental search. IMHO it's a scintilla bug.
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on September 05, 2012, 05:46:56 pm
So how about this:

1. Use the refresh workaround wherever it is needed
2. File a bug with scintilla (checking their bug tracker and sources first)

I will do some testing of the performance of the clear indicator calls on a large file on my netbook and propose a patch if necessary. (I used to have highlighting switched off because of the scrolling performance but it may not be so bad after the scrolling patch.)
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on September 05, 2012, 07:25:10 pm
What makes me wonder, is that IncrementalSearch still works, but HighlightOccurrences does not.
And the ClearRange code is the same in both cases.

because (painstate==notpainting)  == true for incremental search. IMHO it's a scintilla bug.
Why does it work in wxSTC then ?
It also uses scintilla internally and the chnage that discovered the issue is in ScintillaWx.cpp:DoPaint() .
Before the change Refresh was called from there (or more exactly from FullPaint()) .
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on September 05, 2012, 07:58:14 pm
Why does it work in wxSTC then ?

Do you have a link to the code you tested? (I suspect there must be a full refresh/update being called somewhere or for whatever reason the editor is in a notPainting state)

Quote
It also uses scintilla internally and the chnage that discovered the issue is in ScintillaWx.cpp:DoPaint() .
Before the change Refresh was called from there (or more exactly from FullPaint()) .

Yes, I see that here (http://svn.berlios.de/wsvn/codeblocks?manualorder=1&op=comp&compare%5B0%5D=%2Ftrunk%2Fsrc%2Fsdk%2Fwxscintilla&compare_rev%5B0%5D=8230&compare%5B1%5D=%2Ftrunk%2Fsrc%2Fsdk%2Fwxscintilla&compare_rev%5B1%5D=8278&comparesubmit=Compare+Paths). (search the page for "refresh", it's the second instance.)

But I think that change is the right thing to do because they are trying to minimize on the amount of screen they repaint to be more efficient on things like VMs. But now they can no longer assume that a paint in progress will result in a full redraw, such as in that NotifyModified code.

EDIT: Less sure about this, because the DoPaint stuff is a wx-specific change. I guess the question is whether there is equivalent code for the non-wx implementations.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on September 05, 2012, 08:27:05 pm
Another strange thing:
if I do the exact same call to ClearRange from inside IncSearch (for the Indicator used in HighlightOccurences), it clears the indicators.
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on September 05, 2012, 09:04:45 pm
Another strange thing:
if I do the exact same call to ClearRange from inside IncSearch (for the Indicator used in HighlightOccurences), it clears the indicators.

Is that call from inside a handler to wxEVT_SCI_UPDATEUI ? I think that is why paintState != notPainting in the cbEditor code.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on September 05, 2012, 10:07:05 pm
Another strange thing:
if I do the exact same call to ClearRange from inside IncSearch (for the Indicator used in HighlightOccurences), it clears the indicators.

Is that call from inside a handler to wxEVT_SCI_UPDATEUI ? I think that is why paintState != notPainting in the cbEditor code.
No, it's from inide a key-event handler.

And what's more:
after using the wxScintilla UI-Event in the stc-sample to call HighlightOccurrences instead the wxUpdatUI event, the issue is there also.

That means you are right and it is most likely a scintilla and not a wxScintilla issue (bug?).

I did a simple measuring with a wxStopwatch and mikroseconds ( not very exact I know, but hopefully enough to see a possible difference).
There is no significant difference between scrolling with the cursor through a source-file with a call to Refresh() and without it.
In all cases each step takes between 60 and 120 µs (average a little less than 100 µs).

So the Refresh workaround should do it.
Title: Re: Slow scrolling? [Ubuntu]
Post by: p2rkw on September 05, 2012, 11:32:35 pm
I found another strange issue, sometimes curly braces aren't correctly highlighted.
Here's my test case:
Code
int func()
{
return 0;
}

word word word word word word word word  /*line b*/

call(arg0,
arg1, arg2
)

word word word word word word word word /*line a*/

word word word word word
Select "word" in line 'a', and move cursor up to func(). Notice that highlight gone when cursor meet ')' (whole screen redraw?), curly braces should by highlighted correctly. After that move cursor down to '}' - matching curly bracket isn't highlighted, but if you for instance add breakpoint or toggle bookmark, brace will be highlighted.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Alpha on September 06, 2012, 05:27:10 am
Bisected: revision 8278 introduces the problem.  Something must have gone wrong with the Scintilla update.
I forgot to mention, that was on Windows.
Now I see it here also (I tested it with 8248).
... which means that either I incorrectly bisected (which is a possibility), or there are multiple (platform specific?) items that are contributing to the problem.  Although, it sounds as though the source may already have been found.
And what's more:
after using the wxScintilla UI-Event in the stc-sample to call HighlightOccurrences instead the wxUpdatUI event, the issue is there also.

That means you are right and it is most likely a scintilla and not a wxScintilla issue (bug?).
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on September 06, 2012, 05:42:49 am
Now I see it here also (I tested it with 8248).
... which means that either I incorrectly bisected (which is a possibility), or there are multiple (platform specific?) items that are contributing to the problem.
That was not clear, sorry.

I meant I tested with 8248 before (when I had no issue).
It's definiotely 8278.
Until then every DoPaint-call which ended with paintState abandone did a Refresh() of the control.
The no longer existing refresh might also be the cause for the not correctly working HighlightBraces, because the appropriate function is called from the UpdateUI function also.

In cbAuiNotebook I stumbled over similar issues when doing the MinimizeFreeSpace-calls (to move the tabs as far to the right as possible, if there is free space).
It did not work from inside the OnResize event, so I just set a flag in the OnResize event-chain and do the real work in an OnIdle call.
Maybe we need something similar here (setting a flag that an UpdateUI-event occured and do the real work from inside an OnIdle call).
We would need just one flag for all painting related stuff inside the UpdateUI-function, even if we would have more things later.

I will not be at home today, so I can not follow the discussion until this evening.
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on September 06, 2012, 05:55:10 am
The no longer existing refresh might also be the cause for the not correctly working HighlightBraces, because the appropriate function is called from the UpdateUI function also.

Makes sense. Doesn't that feature also rely on indicators?

Quote
Maybe we need something similar here (setting a flag that an UpdateUI-event occured and do the real work from inside an OnIdle call).
We would need just one flag for all painting related stuff inside the UpdateUI-function, even if we would have more things later.

I guess that would work, but doesn't it force an extra paint each keypress? (Probably doesn't make a difference to performance)
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on September 07, 2012, 08:52:31 am
The no longer existing refresh might also be the cause for the not correctly working HighlightBraces, because the appropriate function is called from the UpdateUI function also.

Makes sense. Doesn't that feature also rely on indicators?

Yes !

Quote
Maybe we need something similar here (setting a flag that an UpdateUI-event occured and do the real work from inside an OnIdle call).
We would need just one flag for all painting related stuff inside the UpdateUI-function, even if we would have more things later.

I guess that would work, but doesn't it force an extra paint each keypress? (Probably doesn't make a difference to performance)

Why should there be an extra paint ?

You can try the attached patch.
I also moved the NotifyPlugins call into the OnIdle-function, to ensure plugins that want to paint if the UI is updated do not run into the same trouble.
Title: Re: Slow scrolling? [Ubuntu]
Post by: MortenMacFly on September 07, 2012, 12:06:32 pm
Until then every DoPaint-call which ended with paintState abandone did a Refresh() of the control.
Wait a sec... you should also have a look at the scintilla repo. From what I see there is a bugfix recently which may cover this, too (I am unable to present a link to a diff though). Or is this really a wxScintilla issue?
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on September 07, 2012, 12:09:52 pm
Until then every DoPaint-call which ended with paintState abandone did a Refresh() of the control.
Wait a sec... you should also have a look at the scintilla repo. From what I see there is a bugfix recently which may cover this, too (I am unable to present a link to a diff though). Or is this really a wxScintilla issue?
It might be a scintilla issue, but it's discovered by a change in wxScintilla.

I try if I find the bugfix you mentioned.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on September 07, 2012, 12:53:23 pm
The only thing I can find in scintillas repo, what is related to painting and comes after the source was tagged to 3.2.2 is this:
http://scintilla.hg.sourceforge.net/hgweb/scintilla/scintilla/rev/c39df2a9f97a
But it is gtk3 and toolbar retlated and does not change anything.
Title: Re: Slow scrolling? [Ubuntu]
Post by: MortenMacFly on September 07, 2012, 12:57:02 pm
http://scintilla.hg.sourceforge.net/hgweb/scintilla/scintilla/rev/c39df2a9f97a
But it is gtk3 and toolbar related and does not change anything.
Yes, that's what I meant. I did only recall the part with "paintAbandoned". So its not related... that's fine.
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on September 07, 2012, 02:21:46 pm
I think it must be a wxScintilla issue. I got some help from the scintilla developer here (https://groups.google.com/forum/?fromgroups=#!topic/scintilla-interest/oZFLNUj1jt4)

For some reason the DoFullPaint after the paintAbandoned in DoPaint doesn't seem to do a full redraw. (As we've been discussing, you can see the changes to DoPaint that might be causing this here (http://svn.berlios.de/wsvn/codeblocks?manualorder=1&op=comp&compare%5B0%5D=%2Ftrunk%2Fsrc%2Fsdk%2Fwxscintilla%2Fsrc%2FScintillaWX.cpp&compare_rev%5B0%5D=8277&compare%5B1%5D=%2Ftrunk%2Fsrc%2Fsdk%2Fwxscintilla%2Fsrc%2FScintillaWX.cpp&compare_rev%5B1%5D=8278&comparesubmit=Compare+Paths)). I wonder if the full redraw might be somehow being clipped because they need to reset the clip area? (Pure speculation)

Title: Re: Slow scrolling? [Ubuntu]
Post by: Jenna on September 07, 2012, 03:32:28 pm
As stated here (https://groups.google.com/forum/?fromgroups=#!msg/scintilla-interest/oZFLNUj1jt4/x_2PFCf0Z34J):
Quote
Some platforms behave differently when redraw calls are made inside paints so may need to schedule a paint on idle. They also differ in the information they provide about the paint region so may require overriding PaintContains.
It might be needed to paint in OnIdle-function as my patch doese.

Refresh() just invalidates the whole DC and initiates a repaint in the next message loop (this means outside the actual paint-event).
I don't know which solution is the better one.
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on September 08, 2012, 05:57:45 am
I don't know which solution is the better one.

Either one will work and should have about the same performance, so I doubt it matters.

Is it worth filing a bug against wxScintilla?

I tried to get to the bottom of this one, but keep hitting a wall. I stepped through the code with the debugger. After paintAbandoned is triggered a new DoFullPaint gets called from DoPaint. As far as I can tell the Paint call in DoFullPaint does attempt to redraw every line as should happen, but it seems to get clipped. I try clearing the clip region of the DC before the paint call, but that doesn't seem to do anything. It's hard to debug, because the debugger will often hang (especially on linux).
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on September 08, 2012, 02:08:56 pm
So I guess that I have to give up and say that there is some platform limitation that prevents repaints outside the clip region in a paint handler. This affects both GTK and Windows. Not sure if it also affects Mac.

Reverting part of the 3.2.2 patch as follows would fix the problem:

Code
Index: src/sdk/wxscintilla/src/ScintillaWX.cpp
===================================================================
--- src/sdk/wxscintilla/src/ScintillaWX.cpp (revision 8358)
+++ src/sdk/wxscintilla/src/ScintillaWX.cpp (working copy)
@@ -911,7 +911,8 @@
     if (paintState == paintAbandoned) {
         // Painting area was insufficient to cover new styling or brace
         // highlight positions
-        FullPaintDC(dc);
+        FullPaint();
     }
     paintState = notPainting;
 }
@@ -919,8 +920,12 @@
 
 // Force the whole window to be repainted
 void ScintillaWX::FullPaint() {
-    wxClientDC dc(sci);
-    FullPaintDC(&dc);
+#ifndef __WXMAC__
+    sci->Refresh(false);
+#endif
+    sci->Update();
 }

And at least on GTK seems to be free of nasty sideeffects such as generating duplicate SCN_UPDATEUI events.
  
However, something very similar (http://scintilla.hg.sourceforge.net/hgweb/scintilla/scintilla/file/d312df95d23e/win32/ScintillaWin.cxx#l2389) to this FullPaint/FullpaintDC code appears in the native windows Scintilla port, so if it is broken here why isn't it also broken on the native windows version? The GTK version invalidates the window (http://scintilla.hg.sourceforge.net/hgweb/scintilla/scintilla/file/d312df95d23e/gtk/ScintillaGTK.cxx#l1094), and so effectively orders a full redraw. There's a recent change (http://scintilla.hg.sourceforge.net/hgweb/scintilla/scintilla/diff/5e349827eaf4/cocoa/ScintillaCocoa.mm) to the Mac version because I guess trying to repaint on the same DC didn't work there either:

i.e. Is attempting to re-paint during a paint a "platform limitation" that applies to all known platforms? :)
Title: Re: Slow scrolling? [Ubuntu]
Post by: MortenMacFly on September 11, 2012, 01:25:31 pm
Reverting part of the 3.2.2 patch as follows would fix the problem:
If it works, feel free to commit, but please encapsulate it into /* C::B begin */, /* C::B end */ comments. In fact, I was indeed a bit curious about that change, because I also saw that in SciTE and ScintillaQT this is handled differently. Hence I thought "the wx guys should know" but it seems I was wrong. I didn't realise this bug until posted here... sorry.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Alpha on September 12, 2012, 12:32:18 am
I have tested this patch on Windows Vista and 7; it worked fine for me in those environments.
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on September 13, 2012, 10:14:14 pm
I committed a one-liner (http://svn.berlios.de/wsvn/codeblocks?manualorder=1&op=comp&compare%5B0%5D=%2Ftrunk%2F&compare_rev%5B0%5D=8383&compare%5B1%5D=%2Ftrunk%2F&compare_rev%5B1%5D=8384&comparesubmit=Compare+Paths) that should take care of the problem efficiently. Doing Refresh(false) seems to be enough to reset the clip region, at least on windows.
Title: Re: Slow scrolling? [Ubuntu]
Post by: Alpha on September 13, 2012, 11:28:08 pm
It works on Ubuntu as well (and the performance seems fine).
Title: Re: Slow scrolling? [Ubuntu]
Post by: dmoore on September 13, 2012, 11:55:04 pm
Thanks for testing. I wonder if it is needed on Mac? The older, working code skipped the Refresh call for WXMAC. Perhaps we should do the same here.