CPU use when clicking on empty space.

Hi,

Any idea why clicking on empty space (anywhere on a VerticalLayout for example) in a vaadin app results heavy CPU use?

Clicking multiple times a second can easily max a core on a modern system.

Go to http://demo.vaadin.com/sampler and click to the right of ‘Home’ on the top left and watch the CPU use.

I suspect event handlers and have profiled a simple app doing this using FireBug and seen a tonne of JS calls. Unfortunately I have not found out how to compile my (maven) app with the JS non-obfuscated so can’t easily figure out what the JS functions are.

Thanks.

Can’t say I have noted this but the reason is probably JS events. To recompile the widgetset as non-obfuscated you should use the -style=PRETTY parameter for the GWT compiler. If I remember correctly you can do this in Maven by changing

<extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
<extraJvmArgs>-Dgwt.style=PRETTY -Xmx512M -Xss1024k</extraJvmArgs>

in the pom.xml where the widgetset is compiled (configuration for gwt-maven-plugin)

Thanks, the PRETTY param only seems to affect custom GWT widgets. Should that param cause the entire Vaadin framework to be compiled with PRETTY? I am still seeing two letter JS function names in the FireBug profiler.

You always have only one widgetset that contains the javascript for all widgets, including those in the Vaadin core. You should double check that you are using the widgetset you compiled (web.xml parameter, FireBug also shows what it loaded) and that the browser is not giving you an old/cached version.

FireBug says that I am using com.vaadin.terminal.gwt.DefaultWidgetSet. When using PRETTY do I also need to specify the default widget set in the plugin:


<plugin>                                                                                                                                                                                       
        <groupId>com.vaadin</groupId>                                                                                                                                                                
        <artifactId>vaadin-maven-plugin</artifactId>                                                                                                                                                 
        <version>1.0.1</version>                                                                                                                                                                     
        <executions>                                                                                                                                                                                 
          <execution>                                                                                                                                                                                
            <configuration>                                                                                                                                                                          
              <!-- if you don't specify any modules, the plugin will find them -->                                                                                                                   
              <!-- <modules> <module>com.enbridge.gwt.ColorPickerWidgetSet</module> </modules> -->                                                                                                   
            </configuration>                                                                                                                                                                         
            <goals>                                                                                                                                                                                  
              <goal>update-widgetset</goal>                                                                                                                                                          
            </goals>                                                                                                                                                                                 
          </execution>                                                                                                                                                                               
        </executions>                                                                                                                                                                                
      </plugin> 

When dong a ‘mvn package’ on vaadin-archetype-sample I notice it compiling ColorPickerWidgetSet but not the core.

The plugin vaadin-maven-plugin only updates the widgetset .gwt.xml file (or creates one if a module is specified but does not exist). Also, you might have been using an old version of the archetype, I cannot recall if you have to move the configuration section out of the executions for some of the parameters to be correctly taken into account for this plugin, but at least for the gwt-maven-plugin you probably do.

In any case, the widgetset compilation is performed by gwt-maven-plugin, not vaadin-maven-plugin, so that is where you need to configure the JVM args etc. First move the configuration section out of the executions section if it is inside.

There is only one widgetset in use at any given time, so your com.enbridge.gwt.ColorPickerWidgetSet does contain the core components based on an “inherits DefaultWidgetSet” in it - otherwise you would see nothing when trying to load the application. Also make sure your web.xml (or portlet.xml) specifies (only) your widgetset to be used with an init parameter.

Just a reset… If I

  1. get the latest vaadin-arghetype-sample from http://vaadin.com/wiki/-/wiki/Main/Using%20Vaadin%20with%20Maven
  2. add the -Dgwt.style=PRETTY
  3. run mvn compile

it appears (to my vaadin-noob eyes) to only compile the custom widget. Can you confirm that this is true? If so can you also show how, starting from that archetype, to get it to compile all the widgets. Thanks.

Excerpt from the pom:


     <plugin>                                                                                                                                                                                       
        <groupId>org.codehaus.mojo</groupId>                                                                                                                                                         
        <artifactId>gwt-maven-plugin</artifactId>                                                                                                                                                    
        <version>1.3-SNAPSHOT</version>                                                                                                                                                              
        <configuration>                                                                                                                                                                              
          <!-- if you don't specify any modules, the plugin will find them -->                                                                                                                       
          <!-- <modules> <module>com.enbridge.gwt.ColorPickerWidgetSet</module> </modules> -->                                                                                                       
          <webappDirectory>${project.build.directory}/${project.build.finalName}/VAADIN/widgetsets</webappDirectory>                                                                                 
          <!-- On Mac running Snow Leopard, add "-d32" -->                                                                                                                                           
          <!-- This causes error messages (but build works) in phase "package": two processes would use the same debug                                                                               
            port -->                                                                                                                                                                                 
          <!--extraJvmArgs>-Xmx512M -Xss1024k -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8998</extraJvmArgs -->                                                                
          <extraJvmArgs>-Dgwt.style=PRETTY -Xmx512M -Xss1024k</extraJvmArgs>                                                                                                                         
          <runTarget>vaadin-sample</runTarget>                                                                                                                                                       
          <hostedWebapp>${project.build.directory}/${project.build.finalName}</hostedWebapp>                                                                                                         
          <noServer>true</noServer>                                                                                                                                                                  
          <port>8080</port>                                                                                                                                                                          
          <soyc>false</soyc>                                                                                                                                                                         
        </configuration>                                                                                                                                                                             
        <executions>                                                                                                                                                                                 
          <execution>                                                                                                                                                                                
            <goals>                                                                                                                                                                                  
              <goal>resources</goal>                                                                                                                                                                 
              <goal>compile</goal>                                                                                                                                                                   
            </goals>                                                                                                                                                                                 
          </execution>                                                                                                                                                                               
        </executions>                                                                                                                                                                                
      </plugin>                                                                                                                                                                                      
      <plugin>                                                                                                                                                                                       
        <groupId>com.vaadin</groupId>                                                                                                                                                                
        <artifactId>vaadin-maven-plugin</artifactId>                                                                                                                                                 
        <version>1.0.1</version>                                                                                                                                                                     
        <executions>                                                                                                                                                                                 
          <execution>                                                                                                                                                                                
            <configuration>                                                                                                                                                                          
              <!-- if you don't specify any modules, the plugin will find them -->                                                                                                                   
              <!-- <modules> <module>com.enbridge.gwt.ColorPickerWidgetSet</module> </modules> -->                                                                                                   
            </configuration>                                                                                                                                                                         
            <goals>                                                                                                                                                                                  
              <goal>update-widgetset</goal>                                                                                                                                                          
            </goals>                                                                                                                                                                                 
          </execution>                                                                                                                                                                               
        </executions>                                                                                                                                                                                
      </plugin>                                      

It is not possible to compile only one widget. You always compile the whole widgetset and that will include the core widgets (from DefaultWidgetSet) and possibly your added custom widgets.