Author Topic: Slow scrolling? [Ubuntu]  (Read 89904 times)

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Slow scrolling? [Ubuntu]
« Reply #45 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.
« Last Edit: July 23, 2012, 05:54:29 pm by dmoore »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Slow scrolling? [Ubuntu]
« Reply #46 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.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Slow scrolling? [Ubuntu]
« Reply #47 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?
« Last Edit: July 24, 2012, 03:38:43 am by dmoore »

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Slow scrolling? [Ubuntu]
« Reply #48 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.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Slow scrolling? [Ubuntu]
« Reply #49 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)
« Last Edit: July 24, 2012, 05:30:28 am by dmoore »

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Slow scrolling? [Ubuntu]
« Reply #50 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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Slow scrolling? [Ubuntu]
« Reply #51 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
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Slow scrolling? [Ubuntu]
« Reply #52 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).

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Slow scrolling? [Ubuntu]
« Reply #53 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).

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Slow scrolling? [Ubuntu]
« Reply #54 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.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Slow scrolling? [Ubuntu]
« Reply #55 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.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Slow scrolling? [Ubuntu]
« Reply #56 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.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Slow scrolling? [Ubuntu]
« Reply #57 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).

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Slow scrolling? [Ubuntu]
« Reply #58 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...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Slow scrolling? [Ubuntu]
« Reply #59 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.
« Last Edit: July 24, 2012, 10:42:01 am by jens »