TMSFNCRichEditor slow performance with line count of 1000+

I'm using TMSFNCRichEditor to display a log of transactions, but when the log reaches a size of 1000+ lines, the control becomes slow. Are there any settings to improve performance?

All updates takes place between BeginUpdate and EndUpdate and I'm making use of colouring the text based on the transaction state.

In what sense do you see 'slowness'? Adding lines? Displaying lines?

I retested this here with:

var
  lines: integer;
const
  COUNT = 10;

procedure TForm1.Button1Click(Sender: TObject);
var
  i: integer;
  t: DWORD;
begin
  t := GetTickCount;
  TMSFNCRichEditor1.BeginUpdate;
  for i := 1 to COUNT do
    begin
      TMSFNCRichEditor1.AddText('a new log line '+ (i + lines).ToString+ ' inserted here ');
      TMSFNCRichEditor1.AddLineBreak;
    end;
  TMSFNCRichEditor1.EndUpdate;
  TMSFNCRichEditor1.Repaint;

  Caption := (GetTickCount - t).ToString+'/'+lines.ToString;

  lines := lines + COUNT;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  lines := 0;
end;

and while there is a slight decrease in time to add lines after a couple of hundreds of lines, I could not see a problematic slowness.
What exactly are you doing different?

Hi Bruno,

The slow performance is observed when scrolling the control, the addition of the lines are fine and I do nothing different as in the code you have provided.

I have attached a small experimental FMX project that also illustrate the problem.

The project allows you to load a FMX.style file into the RichEditor and the RichEditor is then used to highlight all the hex colors so that you can change them to your taste.

To reproduce the problem follow the next steps:

  1. Load the given Dark.style file
  2. If you click the next button the caret will be moved to the next color in the file and in the beginning the control response is 100%
  3. Now use the scroll bar and scroll about 80% of the file and click on a hexcolor
  4. Now if you click the Next button the control becomes very slow

Regards,

Rainier

FMXStyle.zip (44.7 KB)

We could see this slow performance, partially due to

  1. FMX framework text rendering / text size calculation that is notorious to be slow
  2. large richeditor surface, so large area to redraw
  3. We'll investigate if we can increase performance at algorithm level in the rich editor

Hi Bruno,

Thanks for the response.
There is no rush, I have changed my code to keep the content much smaller.

Regards,

Rainier