Jump to content

bad performance when opening big form


snow

Recommended Posts

greetings,

 

the issue is bad performance when opening one of the biggest forms in my program. While in VCL desktop version it takes a few seconds (like 3-4) for the form to open, in uniGUI it takes about 40 seconds. this is unacceptable.

I am aware that this form is quite huge, having around 1200 individual components (all of which were put on the form in the designer (.dfm)). creating this many components takes time, but 40 seconds is way too much. like 4-5 seconds would be acceptable.

 

as a test case, please see attached picture below. it's a newly created project, and the only thing it does is creating instances of TUniComboBox. I timed how long it takes for the form to open by using the FormCreate (you could use FormShow for this, doesnt matter much) and FormAfterShow events. you can interact with the form only after it is shown, so FormAfterShow makes sense to use. as you can see, in this instance it took 47 (usually between 40 and 45) seconds for the form to open. this is an enormous amount of time, considering nothing else is being done. the only thing the user can do is sit around and wait (and maybe fall alseep).

 

please let me know how i can get this tremendous amount of time down to an acceptable level, or significantly improve performance as soon as possible.

 

thank you,

snow

 

 

977970844_UniGUIPerformance.thumb.JPG.63b6abfb333415edf47aa10445c6fa20.JPG

Link to comment
Share on other sites

Although I will leave others for a more technical response, I can only say from my experience that Ajax driven WebBased programming does not lend itself to simple porting from VCL legacy projects, granted Delphi wrapped Sencha objects do make for easy and quick pro-typing. I would encourage you to build your application from the ground up based on this new programming model.  

  • Like 1
Link to comment
Share on other sites

3 hours ago, andyhill said:

Although I will leave others for a more technical response, I can only say from my experience that Ajax driven WebBased programming does not lend itself to simple porting from VCL legacy projects, granted Delphi wrapped Sencha objects do make for easy and quick pro-typing. I would encourage you to build your application from the ground up based on this new programming model.  

1200 UniComboBox?

So many controls,

But I think there will be some method to short the time.

Is there some method like oracle's batch sql  commit?

waiting  for the solution....

Link to comment
Share on other sites

15 hours ago, snow said:

greetings,

 

the issue is bad performance when opening one of the biggest forms in my program. While in VCL desktop version it takes a few seconds (like 3-4) for the form to open, in uniGUI it takes about 40 seconds. this is unacceptable.

I am aware that this form is quite huge, having around 1200 individual components (all of which were put on the form in the designer (.dfm)). creating this many components takes time, but 40 seconds is way too much. like 4-5 seconds would be acceptable.

 

as a test case, please see attached picture below. it's a newly created project, and the only thing it does is creating instances of TUniComboBox. I timed how long it takes for the form to open by using the FormCreate (you could use FormShow for this, doesnt matter much) and FormAfterShow events. you can interact with the form only after it is shown, so FormAfterShow makes sense to use. as you can see, in this instance it took 47 (usually between 40 and 45) seconds for the form to open. this is an enormous amount of time, considering nothing else is being done. the only thing the user can do is sit around and wait (and maybe fall alseep).

 

please let me know how i can get this tremendous amount of time down to an acceptable level, or significantly improve performance as soon as possible.

 

thank you,

snow

 

 

977970844_UniGUIPerformance.thumb.JPG.63b6abfb333415edf47aa10445c6fa20.JPG

Hello, If You  just replace creating combobox with sleep (3); , then You will get 0:00 as time but this is not True.

Simple calculation : 1200 * 3 = 3600 ms , but "s" = 0 ?

 

Link to comment
Share on other sites

On 10/9/2021 at 8:43 AM, irigsoft said:

Hello, If You  just replace creating combobox with sleep (3); , then You will get 0:00 as time but this is not True.

Simple calculation : 1200 * 3 = 3600 ms , but "s" = 0 ?

 

 

as you probably figured out by now, the point of s is to measure the time it takes for the form to show up in the browser. while creating 1200 ComboBoxes takes like 3-4 seconds (or a lot less when you add "visible := False;" to the loop), it still takes 40 seconds for the form to show up in the browser.

if you replace creating ComboBoxes with sleep(3), then the form shows up way faster. because it doesnt have 1200 ComboBoxes on it.

 

 

On 10/9/2021 at 11:32 AM, irigsoft said:

@snow did You seen this: 

 

 

yes, i have seen it. i've looked at a lot of performance related threads, but the tips there do nothing for my specific problem.

 

 

On 10/10/2021 at 8:26 AM, irigsoft said:

Hello again.

I'm doing some kind of test and the performance problem is only with ComboBoxes.

If you use labels, buttons or panels, the speed is more than 10 times faster.

I don't know why creating combo boxes is so slow

 

i've done some more testing myself. turns out TUniDBComboBox and TUniCheckComboBox are way worse.

Link to comment
Share on other sites

if i put the ComboBoxes inside a panel and use UniApplication as panel.Owner, then i get the loading time down to about 13 seconds.

but then i cant set p.parent to self, because p.OwnerForm has to be self.OwnerForm. InsertComponent sets p.Owner to self, but creates a host of problems of its own.

 

 

grafik.png.6182d13224413971c66cb0d245cdb0e4.png

Link to comment
Share on other sites

the bottleneck seems to be TUniItemedFormControl.WebCreate in unit uniMultiItem. times are for 1200 ComboBoxes:

Creating FStore takes about 10 seconds.

JSConfig('proxy', takes about 6 seconds.

JSAddEvent( takes about 15 seconds.

 

since those methods are defined in units we have no access to, there doesnt seem to be a lot i can do. and even then it's JavaScript, which isn't my forte.

 

dear people of uniGUI, please fix this performance issue.

 

grafik.png.5ef5eda1c41c695ffb7e02f08f6749d8.png

Link to comment
Share on other sites

52 minutes ago, Sherzod said:

Hello,

Do you have 1200 combo boxes on your form? I think you should review the logic of your program.

Hello, for me:

1. I have dinamic creation of components after user login.

2. Browser need 3-4 seconds on mobile devices to show created form (Professional version UniGUI). I dont use many comboboxes (less then 10), but I use Button/Speedbuttons/Bitbtns/Labels/Images/DBGrids/Panels/GroupBoxes/ScrollBars, maybe 100 or 200 per Form.

3. I have dinamically created frames  and smallest time to show data is 2 seconds on mobile device (2GB Ram, CPU: 1.7 GHz)

Creations is on server side.

Link to comment
Share on other sites

hi snow

I don't know if this will help you but try it.

- I had to make a frame that have more components than that depend on the user selection I create from 500 up to 1800 unipanel that have labels and other controls ,

running this at one go take up to 50 sec sometimes,

I tested with uniTimer and created the panels in patches each time no more than 200 panel and now it takes 19 sec that is 60% faster.

- another note that surprised me and I cannot explain that documentation and other posts say to create(self) is faster but with testing create(uniParentPanel) saved me one sec.

- lastly try to redesign your frame, removing even one repeating label make deferent at these high numbers

regards

 

Link to comment
Share on other sites

still not understanding what the user will do in a form with 1200 combobox with no data listed. in your example, you haven't even included information in this combobox yet, that will bring more delay in the assembly of the screen

I would solve this in a form with several tabs (pagecontrol), and in each tab would create a limited amount of fields, when accessing the next tab the controls would be created, so I wouldn't need to create everything at once.

Link to comment
Share on other sites

On 10/14/2021 at 8:51 AM, Sherzod said:

Hello,

Do you have 1200 combo boxes on your form? I think you should review the logic of your program.

 

it's about 1200 component in total. there's labels, edits, radiogroups and comboboxes along with panels, groupboxes and the like.

the example form with 1200 empty comboboxes was merely to illustrate the performance issue of comboboxes.

Link to comment
Share on other sites

Hello Unigui experts
The same thing happens to me.
In my case, I have several unitab controls that are created dynamically and inside them many controls: unidbgrid, buttons, edits, combobox, edits, etc. and inside the panels other tabs again.
It takes about 20 seconds to load, which seems too long to me.
Is there any way that these controls are effectively created on the server (as in vcl) and at the end are sent only as a form to the client?

Thanks

Using "suspendlayouts" I could shorten the time just a couple of seconds.
Thanks


Translated with www.DeepL.com/Translator (free version)

Link to comment
Share on other sites

Hello,

Here is an example of how to load 1200 combo boxes with no waiting time. 

The trick is create the comboboxes when the user click for the first time the tab and use "OnBeforeFirstActivate" event:

procedure TMainForm.UniTabSheetBeforeFirstActivate(Sender: TObject; var AllowActivate: Boolean);
begin
  AllowActivate := True;
  GenerateCtrls(Sender as TUniCustomPanel);
end;

procedure TMainForm.GenerateCtrls(AParent: TUniCustomPanel);
var
  I: Integer;
  ComboBox: TUniComboBox;
begin
  SuspendLayouts;
  try
    for I := 0 to 99 do
    begin
      ComboBox := TUniComboBox.Create(Self);
      ComboBox.Parent := AParent;
      ComboBox.Height := 25;
      ComboBox.LayoutConfig.Width := '100%';
      ComboBox.Text := (APArent.Tag * 100 + I).ToString;
    end;
  finally
    ResumeLayouts;
  end;
end;

 

Therefore, you can use this technique to quickly load forms with many components.

In a real world case, it is better to design frames with components and load the frame when the user clicks the tab for the first time.

 

Test2.gif

uniGUI_Dynamic.7z

  • Thanks 2
Link to comment
Share on other sites

29 minutes ago, Pep said:

Hello,

Here is an example of how to load 1200 combo boxes with no waiting time. 

The trick is create the comboboxes when the user click for the first time the tab and use "OnBeforeFirstActivate" event:

procedure TMainForm.UniTabSheetBeforeFirstActivate(Sender: TObject; var AllowActivate: Boolean);
begin
  AllowActivate := True;
  GenerateCtrls(Sender as TUniCustomPanel);
end;

procedure TMainForm.GenerateCtrls(AParent: TUniCustomPanel);
var
  I: Integer;
  ComboBox: TUniComboBox;
begin
  SuspendLayouts;
  try
    for I := 0 to 99 do
    begin
      ComboBox := TUniComboBox.Create(Self);
      ComboBox.Parent := AParent;
      ComboBox.Height := 25;
      ComboBox.LayoutConfig.Width := '100%';
      ComboBox.Text := (APArent.Tag * 100 + I).ToString;
    end;
  finally
    ResumeLayouts;
  end;
end;

 

Therefore, you can use this technique to quickly load forms with many components.

In a real world case, it is better to design frames with components and load the frame when the user clicks the tab for the first time.

 

Test2.gif

uniGUI_Dynamic.7z 23.35 kB · 0 downloads

 

Great PEP  !

Thanks to share

Link to comment
Share on other sites

Thank you for sharing.
However, there is a delay when clicking the first time (activate) as you explained. 
But I have added in design 100 controls to a new tab and these are instantly displayed on the sheet.
I insist that it should be created first on the server side and that the behavior when displaying on the web is faster.
Regards

Untitled.png

Link to comment
Share on other sites

  • 2 weeks later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...