Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 359508

Summary: Performance issue when dragging a new type of widget to the VE
Product: z_Archived Reporter: fahua jin <jinfahua>
Component: EDTAssignee: Huo Zhen Zhong <huozz>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3 CC: chenzhh, huozz, mayunf
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Patch
lasher: iplog+
Patch 2 none

Description fahua jin CLA 2011-09-29 23:10:07 EDT
Build Identifier: 0.7.0.v201109292101

You'll see a couple of seconds are spent to drag a new type of widget (one widget has not been dragged to the VE before), which annoys user. 

Reproducible: Always
Comment 1 Huo Zhen Zhong CLA 2011-09-30 03:54:29 EDT
Add Ji Yong in the copy list

Every time add a new widget in the Handler, it will render the whole page, that make it slow. JS runtime should provide a new dynamic loading mechanism first since the generated HTML is different of RBD.
Comment 2 Huo Zhen Zhong CLA 2011-10-10 03:14:31 EDT
*** Bug 359355 has been marked as a duplicate of this bug. ***
Comment 3 Yun Feng Ma CLA 2011-10-10 04:17:01 EDT
Created attachment 204857 [details]
Patch

Here is a patch. Thanks.
Comment 4 Huo Zhen Zhong CLA 2011-10-12 01:06:01 EDT
Hi team,

The change for 359508  has been checked in, below is how the js dynamic loading works in VE.

For Widget and Handler, the RED codes are generated into "eze$$setInitial"  method  to dynamically load the missed js files and css files, below is an example:
"eze$$setInitial" : function () {
try  { egl.enter( "<init>" , this ,arguments);
egl.loadScript( "org.eclipse.edt.rui.widgets" , "GridLayout"  );
egl.loadScript( "org.eclipse.edt.rui.widgets" , "GridLayoutData"  );
egl.loadScript( "org.eclipse.edt.rui.widgets" , "TextField"  );
egl.loadScript( "org.eclipse.edt.rui.widgets" , "Button"  );
egl.loadScript( "com.services" , "MyLib"  );
egl.loadCSS( "css/ProjectA.css"  );
this .eze$$setEmpty();
egl.atLine( this .eze$$fileName,17,431,11, this );
this .ui.setColumns(3);

Widget/Handler contains egl.loadScript  only for directly referenced parts.

Below is an execution flow example:
Three parts: HandlerA, WidgetB, LibraryC
HandlerA initially doesn't contain WidgetB and LibraryC.
WidgetB references LibraryC.

1. HandlerA is showing in VE
2. Drag WidgetA into HandlerA in Design view, or add WidgetA into HandlerA in Sourve view
3. HandlerA is generated into js, containing below egl.loadScript  code
    egl.loadScript( "widgets.pkg", " WidgetA "  );
4. VE destroys HandlerA instance and reload the new HandlerA.js and re-instance a new HandlerA
5. When the code in step 3 is executed, the WidgetA.js will be load
6. WidgetA.js contains below   egl.loadScript  code
   egl.loadScript( "lib.pkg", " LibraryC "  );
7. When a WidgetA instance is created, the code in step 6 is executed, and LibraryC.js is loaded
8. Drag a new WidgetA into HandlerA, new HandlerA.js is generated
9. VE destroys HandlerA instance and reload the new HandlerA.js and re-instance a new HandlerA
10. the code in step 3 is executed, but the WidgetA.js is loaded, so it returns immediately.
11. If there is any error when loading a js, the whole page will be reloaded.
Comment 5 fahua jin CLA 2011-10-12 04:18:11 EDT
Verified in 0.7.0.v201110110900.

Thanks Jimmy for your great work. I do see the improvements, but I think it would be better if you can provide an accurate improvement number with your fix.
Comment 6 Yun Feng Ma CLA 2011-10-13 01:10:23 EDT
Created attachment 205081 [details]
Patch 2

A new fix. Thanks.