TableView speed

I have an iOS app which has a TMS TableView as the detail control of a TMS Popup. When I ask it to pop up, with a pre-loaded list of about 20 items, it takes a fair few seconds, 4 or 5, to appear. This is the same on an iPod Touch, and an iPad 2. Is this normal? How can I get better performance please? 

I should add that it occurs on my PC too, so that may be useful.

Are you using BeginUpdate/EndUpdate calls during add the items?

The list is filled in FormCreate, with about 20 items. I do nothing more with it, except ask the popup to display which then shows the list.

As stated and asked before, are you using BeginUpdate and EndUpdate. Please post your code here so we can investigate. More information can be found on 
http://www.tmssoftware.com/site/tmsfmxtableview.asp?s=faq&show=561 for using BeginUpdate and EndUpdate

My code is below, but how does this affect anything? These "wrappers" usually cause updates to be slower. This is not an update issue, as the delay is long after the items were added.


procedure TfrmIphoneControl.FormCreate(Sender: TObject);
begin
LogReport(leInformation, 'Application start ' + DateTimeToStr(Now));
FillItemsList;
end;

procedure TfrmIphoneControl.FillItemsList;
var
xOptions : TStringList;
xResponses : TStringList;
nLoop: Integer;
xItem : TTMSFMXTableViewItem;
szBuild : String;
nResponseLoop: Integer;
begin
xOptions := nil;
xResponses := nil;
try
xOptions := TStringList.Create;
xResponses := TStringList.Create;

FillResponseList(xOptions);
lstOptionView.Items.Clear;
for nLoop := 0 to xOptions.Count - 1 do
begin
xItem := lstOptionView.Items.Add;
xItem.Caption := xOptions[nLoop];

szBuild := '';
FillOptionsList(xOptions[nLoop], xResponses);
xResponses.Delete(0);
for nResponseLoop := 0 to xResponses.Count - 1 do
begin
if szBuild <> '' then
szBuild := szBuild + ', ';
szBuild := szBuild + xResponses[nResponseLoop];
            end;
xItem.Description := szBuild;
end;

// cboResponses.Items := xStrings;
finally
FreeAndNil(xOptions);
FreeAndNil(xResponses);
end;

end;

// The list items are of the form:  AddList('Low-High' , 'c,High,Medium,Low' );

procedure TfrmIphoneControl.btnOptionsClick(Sender: TObject);
begin
popOptions.Popup; // this is where the seconds are taken
end;

// The lfm popup

    object popOptions: TTMSFMXPopup
      Position.Point = '(106,8)'
      Width = 281.000000000000000000
      Height = 385.000000000000000000
      Visible = False
      StyleLookup = 'popOptionsStyle1'
      TabOrder = 17
      AutoPosition = False
      DetailControl = lstOptionView
      Placement = plTopCenter
      PlacementTarget = aniWorking
      HeaderButtons = <>
      FooterButtons = <
        item
          Width = 50.000000000000000000
          Kind = bkDone
        end>
      HeaderText = 'Options'
      FooterHeight = 24.000000000000000000
      HeaderHeight = 24.000000000000000000
      ArrowPosition = paRightCenter
      ArrowHeight = 11.000000000000000000
      ArrowWidth = 23.000000000000000000
      Version = '1.1.0.3'
      OnFooterButtonClick = popOptionsFooterButtonClick
      object lstOptionView: TTMSFMXTableView
        Position.Point = '(16,40)'
        Width = 233.000000000000000000
        Height = 233.000000000000000000
        Visible = False
        StyleLookup = 'lstOptionViewStyle1'
        TabOrder = 0
        Fill.Kind = bkSolid
        Stroke.Kind = bkSolid
        StrokeThickness = 1.000000000000000000
        CanFocus = True
        SelectedItemIndex = 2
        Items = <
          item
            Caption = 'Item 0'
            Description = 'Description of Item 0'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 1'
            Description = 'Description of Item 1'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 2'
            Description = 'Description of Item 2'
            DataBoolean = False
            Selected = True
          end
          item
            Caption = 'Item 3'
            Description = 'Description of Item 3'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 4'
            Description = 'Description of Item 4'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 5'
            Description = 'Description of Item 5'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 6'
            Description = 'Description of Item 6'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 7'
            Description = 'Description of Item 7'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 8'
            Description = 'Description of Item 8'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 9'
            Description = 'Description of Item 9'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 10'
            Description = 'Description of Item 10'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 11'
            Description = 'Description of Item 11'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 12'
            Description = 'Description of Item 12'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 13'
            Description = 'Description of Item 13'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 14'
            Description = 'Description of Item 14'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 15'
            Description = 'Description of Item 15'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 16'
            Description = 'Description of Item 16'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 17'
            Description = 'Description of Item 17'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 18'
            Description = 'Description of Item 18'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 19'
            Description = 'Description of Item 19'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 20'
            Description = 'Description of Item 20'
            DataBoolean = False
            Selected = False
          end>
        Categories = <>
        MarkText = 'Mark'
        MoveText = 'Move'
        ArchiveText = 'Archive'
        HeaderText = 'Header'
        Version = '1.1.0.3'
        OnItemClick = lstOptionViewItemClick
      end
    end


It is impossible that BeginUpdate and EndUpdate makes thing slower, whenever you call Items.Add the list will update itself. With a BeginUpdate and EndUpdate that update call is bundled and postponed until and EndUpdate is called. 


However, since you are adding the items in the formcreate, that is indeed not the issue that the list is not showing directly. Can you specify on which operating system you are working, which update you have installed on Rad Studio XE2 and if you can reproduce this issue and help us investigate by sending a sample that reproduces this issue?

It is important to know how many items are added.

We have tested this here with your popup object code and with 20 items inside and could not see any issues with performance.

Kind Regards, 
Scheldeman Pieter 

I've tested on iOS 4.3, iOS5.1, and Windows7-64.
 XE2 update 4.  I will see if I can make a sample for you.


(I mentioned in the first message, and again, that it was not the fill that mattered)
unit fPopupTest;

interface

uses
  SysUtils, Types, UITypes, Classes, Variants, FMX_Types, FMX_Controls, FMX_Forms,
  FMX_Dialogs, FMX_TMSTableView, FMX_TMSBaseControl, FMX_TMSPopup,
  FMX_TMSBarButton;

type
  TForm2 = class(TForm)
    Panel1: TPanel;
    Button1: TButton;
    TMSFMXPopup1: TTMSFMXPopup;
    TMSFMXTableView1: TTMSFMXTableView;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure TMSFMXPopup1FooterButtonClick(Sender: TObject; AButton:
TTMSFMXPopupButton; AButtonShape: TTMSFMXBarButton);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

procedure TForm2.FormCreate(Sender: TObject);
var
nLoop : Integer;
xItem : TTMSFMXTableViewItem;
begin
for nLoop := 0 to 30 do
begin
xItem := TMSFMXTableView1.Items.Add;
xItem.Caption := 'Caption ' + IntToStr(nLoop + 1);

xItem.Description := 'Description, ' + IntToStr(nLoop + 1) + ', more, less';
end;
end;

procedure TForm2.Button1Click(Sender: TObject);
begin
TMSFMXPopup1.Popup;
end;

procedure TForm2.TMSFMXPopup1FooterButtonClick(Sender: TObject; AButton:
TTMSFMXPopupButton; AButtonShape: TTMSFMXBarButton);
begin
TMSFMXPopup1.Close;
end;

{$R *.lfm}

end.

Okay, I'll put my comment here, as I got stopped from posting the LFM too as the forum thinks I'm spamming. 


Just running this code in Windows and not on the slower iOS devices gets about two seconds delay from click to appearance.

object Form2: TForm2
  Left = 0
  Top = 0
  Caption = 'Form2'
  ClientHeight = 480
  ClientWidth = 320
  Visible = False
  OnCreate = FormCreate
  StyleLookup = 'backgroundstyle'
  object Panel1: TPanel
    Position.Point = '(8,8)'
    Width = 305.000000000000000000
    Height = 441.000000000000000000
    TabOrder = 0
    object Button1: TButton
      Position.Point = '(104,8)'
      Width = 105.000000000000000000
      Height = 41.000000000000000000
      OnClick = Button1Click
      TabOrder = 0
      Text = 'Button1'
    end
    object TMSFMXPopup1: TTMSFMXPopup
      Position.Point = '(106,8)'
      Width = 281.000000000000000000
      Height = 385.000000000000000000
      Visible = False
      StyleLookup = 'popOptionsStyle1'
      TabOrder = 1
      AutoPosition = False
      DetailControl = TMSFMXTableView1
      Placement = plBottomCenter
      PlacementTarget = Button1
      HeaderButtons = <>
      FooterButtons = <
        item
          Width = 50.000000000000000000
          Kind = bkDone
        end>
      HeaderText = 'Options'
      FooterHeight = 24.000000000000000000
      HeaderHeight = 24.000000000000000000
      ArrowPosition = paRightCenter
      ArrowHeight = 11.000000000000000000
      ArrowWidth = 23.000000000000000000
      Version = '1.1.0.3'
      OnFooterButtonClick = TMSFMXPopup1FooterButtonClick
      object TMSFMXTableView1: TTMSFMXTableView
        Position.Point = '(8,48)'
        Width = 265.000000000000000000
        Height = 313.000000000000000000
        Visible = False
        TabOrder = 0
        Fill.Kind = bkSolid
        Stroke.Kind = bkSolid
        StrokeThickness = 1.000000000000000000
        CanFocus = True
        Items = <
          item
            Caption = 'Item 0'
            Description = 'Description of Item 0'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 1'
            Description = 'Description of Item 1'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 2'
            Description = 'Description of Item 2'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 3'
            Description = 'Description of Item 3'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 4'
            Description = 'Description of Item 4'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 5'
            Description = 'Description of Item 5'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 6'
            Description = 'Description of Item 6'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 7'
            Description = 'Description of Item 7'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 8'
            Description = 'Description of Item 8'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 9'
            Description = 'Description of Item 9'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 10'
            Description = 'Description of Item 10'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 11'
            Description = 'Description of Item 11'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 12'
            Description = 'Description of Item 12'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 13'
            Description = 'Description of Item 13'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 14'
            Description = 'Description of Item 14'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 15'
            Description = 'Description of Item 15'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 16'
            Description = 'Description of Item 16'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 17'
            Description = 'Description of Item 17'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 18'
            Description = 'Description of Item 18'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 19'
            Description = 'Description of Item 19'
            DataBoolean = False
            Selected = False
          end
          item
            Caption = 'Item 20'
            Description = 'Description of Item 20'
            DataBoolean = False
            Selected = False
          end>
        Categories = <>
        MarkText = 'Mark'
        MoveText = 'Move'
        ArchiveText = 'Archive'
        HeaderText = 'Header'
        FooterText = 'Footer'
        Version = '1.1.0.3'
      end
    end
  end
end

Thank you for your sample.

We have investigated this here and we can confirm the 2 second delay on windows. 

Since you are on update 4, unfortunately, performance has significantly been reduced compared to update 3.
This can be fixed by using GlobalUseDirect2D in the project source file.

program Project222;

uses
  FMX_Forms,
  FMX_Types,
  Unit650 in 'Unit650.pas' {Form650};

{$R *.res}

begin
  GlobalUseDirect2D := False;
  Application.Initialize;
  Application.CreateForm(TForm650, Form650);
  Application.Run;
end.

However this will not fix the issue on iOS side. On iOS the performance dramatically reduces when using effects. Since the popup is using a shadoweffect by default on windows, you need to switch that off on iOS. This is also an issue that needs to be fixed in a future update (hopefully). Switching the shadow off can be done in the OnApplyStyleLookup for iOS (you can use {$IFDEF FPC} or include tmsfdefsios.inc (rename it to tmsdefs.inc on xcode side) and include {$IFDEF IOS}.

procedure TForm1.TMSFMXPopup1ApplyStyleLookup(Sender: TObject);
begin
  {$IFDEF FPC}
  (TMSFMXPopup1.FindStyleResource('popupshadoweffect') as TEffect).Enabled := False;
  {$ENDIF}
end;

To further increase performance you can set the Buffersize to for example 10. specially when you are on iOS side, there is no need to display / load all items at once.
TTMSFMXTableView1.BufferSize := 10.

Hopefully these improvements will generate more performance, but unfortunately as stated before, since update 4 performance is dramatically reduced on both Windows / Mac / iOS.

Kind Regards, 
Scheldeman Pieter 

Thank you. I will try that on iOS just as soon as I recover from the mistake of upgrading to the latest XCode, which breaks the whole dev system.

Okay, got it working on iOS 4.3, and that makes it twice as long. It seems to be transparent, so maybe that is why.

Okay, did a quick test, and removed the DetailControl which is the TableView, and it pops up instantly. This points at the TableView being the slow part. I notice there are some animations in the styles - one to do with opacity. Might that be a cause? On iOS, with the simple data above, I'm able to count to 12 seconds (in my head) before the list appears.


If it would be better on another form or something, I'll try that. But knowing the cause would be ideal, then we can work around it. Obviously update 4 is involved, but we are where we are.

I have to say also that this is a really nice control, and feels great on the iPhone when it is there. Far better than the FMX list!

Matthew , Thanks for introducing me to this component . It is indeed very cool and I can think of doing so much with it. I just wish it was smoother or even better than the iphone native version.


I am experiencing similar performance issue. It feels fine in the simulator and on windows. But there is some kind of slowness.

I report this scroll bug:

If you set the LayoutMode to lmGroup. The scroll appears aligned on the right with the items (not the normal right side). When you click on the category to see detail view of an item and then click back button the scroll appears on the correct position.

I just hope the update4 hotfix comes out before i am finished and ready for submission.





Hi,


Thank you for your feedback, we will investigate this further to see if we can make any performance fixes
on iOS side. 

Kind Regards, 
Scheldeman Pieter