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:

  lines: integer;
  COUNT = 10;

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

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

  lines := lines + COUNT;

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

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 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 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


Rainier (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.