snow Posted October 8, 2021 Share Posted October 8, 2021 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 Quote Link to comment Share on other sites More sharing options...
andyhill Posted October 8, 2021 Share Posted October 8, 2021 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. 1 Quote Link to comment Share on other sites More sharing options...
55143681 Posted October 9, 2021 Share Posted October 9, 2021 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.... Quote Link to comment Share on other sites More sharing options...
irigsoft Posted October 9, 2021 Share Posted October 9, 2021 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 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 ? Quote Link to comment Share on other sites More sharing options...
irigsoft Posted October 9, 2021 Share Posted October 9, 2021 @snow did You seen this: Quote Link to comment Share on other sites More sharing options...
irigsoft Posted October 10, 2021 Share Posted October 10, 2021 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 Quote Link to comment Share on other sites More sharing options...
snow Posted October 11, 2021 Author Share Posted October 11, 2021 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. Quote Link to comment Share on other sites More sharing options...
snow Posted October 11, 2021 Author Share Posted October 11, 2021 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. Quote Link to comment Share on other sites More sharing options...
snow Posted October 11, 2021 Author Share Posted October 11, 2021 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. Quote Link to comment Share on other sites More sharing options...
irigsoft Posted October 11, 2021 Share Posted October 11, 2021 Thanks, I have this problems too. For me is very usefull this information. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 14, 2021 Share Posted October 14, 2021 Hello, Do you have 1200 combo boxes on your form? I think you should review the logic of your program. Quote Link to comment Share on other sites More sharing options...
irigsoft Posted October 14, 2021 Share Posted October 14, 2021 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. Quote Link to comment Share on other sites More sharing options...
M.Ammar Posted October 14, 2021 Share Posted October 14, 2021 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 Quote Link to comment Share on other sites More sharing options...
Wilton Ergon Posted October 14, 2021 Share Posted October 14, 2021 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. Quote Link to comment Share on other sites More sharing options...
Fred Montier Posted October 15, 2021 Share Posted October 15, 2021 That's funny ! Sorry, but EVEN IN VCL, that sounds very funny ! Quote Link to comment Share on other sites More sharing options...
snow Posted October 19, 2021 Author Share Posted October 19, 2021 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. Quote Link to comment Share on other sites More sharing options...
x11 Posted October 19, 2021 Share Posted October 19, 2021 Why are you using SuspendLayouts in the OnCreate event? Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted October 19, 2021 Share Posted October 19, 2021 11 hours ago, x11 said: Why are you using SuspendLayouts in the OnCreate event? http://www.unigui.com/doc/online_help/creating--destroying-many-cont.htm Quote Link to comment Share on other sites More sharing options...
Abanto Jose Posted October 20, 2021 Share Posted October 20, 2021 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) Quote Link to comment Share on other sites More sharing options...
Pep Posted October 20, 2021 Share Posted October 20, 2021 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. uniGUI_Dynamic.7z 2 Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted October 20, 2021 Share Posted October 20, 2021 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. uniGUI_Dynamic.7z 23.35 kB · 0 downloads Great PEP ! Thanks to share Quote Link to comment Share on other sites More sharing options...
Abanto Jose Posted October 20, 2021 Share Posted October 20, 2021 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 Quote Link to comment Share on other sites More sharing options...
x11 Posted October 22, 2021 Share Posted October 22, 2021 On 10/20/2021 at 12:44 AM, Abaksoft said: http://www.unigui.com/doc/online_help/creating--destroying-many-cont.htm there are no layouts when the window is creating Quote Link to comment Share on other sites More sharing options...
irigsoft Posted October 22, 2021 Share Posted October 22, 2021 40 minutes ago, x11 said: there are no layouts when the window is creating Okay, but does that cause the problem or does it matter? Quote Link to comment Share on other sites More sharing options...
x11 Posted November 3, 2021 Share Posted November 3, 2021 On 10/20/2021 at 12:44 AM, Abaksoft said: http://www.unigui.com/doc/online_help/creating--destroying-many-cont.htm Are there such functions for the mobile version uniGUI? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.