TMSFMXTreeView - Strange interaction with TTimer on IOS

Hello,

I've got a very particular problem with the TMSFMXTreeView-component.

In one of my apps, I am using a simple context-menu-construct in conjunction with the Treeview that works as follows:
MouseDown-event starts 500ms-TTimer, MouseUp stops the Timer and does something if the Timer hasn't run out yet.
Should the Timer run out first, the context menu is made visible instead.
The result: Tapping an Treeview-Item does something, whereas holding the Treeviewitem pressed opens the context menu. An old construct, but one that has worked so far reliably.

The problem is as following:
On newer Iphones such as the Iphone 11 or 12 series this construct behaves irregular.
Sometimes the contextmenu appears after 0,5 secs as it should, sometimes it takes as long as 5 secs or anything between.

Here is what I know:

  • The context-menu-construct as described works perfectly with other components, such as for example Buttons, Listboxitems etc.
  • The TTimer works perfectly normal. Logging the events shows that about 500 + 10-20 ms pass between starting the Timer (Intervall = 500) in MouseDown and the end of OnTimer.
  • A different, but functionally equivalent construct utilizing an anonymous Thread with Sleep(500) and Queue etc has exactly the same problem.
  • The context-menu ist not the problem: Even applying a minor change such as changing the text of a label has the same problem.
  • The construct works perfectly fine on Android in general and apparently on older IOS-devices such as for example the IphoneX (All devices have IOS 14.X).

So far I have only wild speculations for what the problem might be since it is such a particular combination of factors, therefore my hope is that you might have an idea about what might be the issue.
The version of the TMSFMXTreeview-component in usage is 1.1.4.10.

Hi,

Without some code snippets I think it is difficult to try to find out what is going wrong. Can you provide a sample, or a code snippet that shows how this is done?

Hello,

I was just reproducing the problem in a small test project for the purpose of providing you a code snippet and found something out: The problem only occurs when the Treeview is placed onto a TabControl. If you just put it onto the Form itself, everything works fine.

A test project can be constructed very simply:

  • Place a Button with Align "Top" on an empty Form
  • Place a TabControl with Align "Client" below and create an TabItem
  • Place a TMSFMXTreeview onto the Tab Item. The example data it contains is sufficient.
  • Place a TTimer onto the Form, set enabled := false and Interval := 500
  • Create a MouseDown & MouseUp-event for the Treewview and an OnTimer-event for the Timer just as in the following code-snippet of the test project
type
  TForm2 = class(TForm)
    Button1: TButton;
    Timer1: TTimer;
    TabControl1: TTabControl;
    TabItem1: TTabItem;
    TreeView: TTMSFMXTreeView;
    procedure TreeViewMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Single);
    procedure TreeViewMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Single);
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    Counter : Integer;
  public
  end;

var
  Form2: TForm2;

implementation

{$R *.fmx}

procedure TForm2.FormCreate(Sender: TObject);
begin
Counter := 0;
end;

procedure TForm2.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
Inc(Counter);
Button1.Text   := 'Test' + IntToStr(Counter);
end;

procedure TForm2.TreeViewMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Single);
begin
Timer1.Enabled := True;
end;

procedure TForm2.TreeViewMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Single);
begin
Timer1.Enabled := False;
end;

If you now keep your finger pressed onto a TreeviewItem until the text of the Button changes and then repeat this process, you will see that the amount of time that passes until the text changes is irregular and most often longer than the 0,5 seconds, sometimes significantly longer.

For a contrast you can remove the Treeview from the Tabcontrol und place it directly onto the Form.
If try it out now you will see that the text change occurs reliably after 0,5 seconds every single time, as it should be.

And, as mentioned in the first post: I reproduced the problem on an iPhone 12. When I run the same project on an iPhoneX, it works reliably.
I am using Delphi 10.4.1 and tried both a IOS 13.5 & 14.3 SDK.
This might just be one of the most obscure problems I ever encountered.

Are you able to reproduce this issue with another component such as a TGrid or a TListView?
It seems very strange that this would be related to the TTMSFMXTreeView alone. It is strange that the behavior is not reproducible directly on the main form which makes me think that there is something going on inside a TTabItem. We unfortunately don't have access to an iPhone 12 here so we'll look into to this as soon as possible.

You don't necessarily need an iPhone12. The problem also occured on an iPad Air 4th generation and on a simple iPhone 11. I would assume that it will generally occur on newer iPhone/iPad-models.

As soon as I've got the opportunity I'll try to experiment a bit more with other components.
As said, probably one of the strangest issues I've ever had.