I am attempting to optimize a widgetset for a Vaadin Touchkit application.
The application works, but takes too long on its somewhat slow server to load
the first page on mobile devices. I used an http logger program (called
Fiddler) to see the traffic while the app was run, and it showed many messages
loading JavaScript onto the first page – makes sense given the way vaadin
works. By adding up the sizes of mostly .js files downloaded before the first
page was displayed, it was shipping 2-3M. One JS file alone was over 1M.
I have read about optimizing the widgetset; as I understand it, I write code
that informs the system at runtime which connectors are necessary, so that
others can be loaded later, and this limits the amount of information that must
be loaded at application start.
I have read instructions about getting a list of the necessary connectors: run
the application with “?debug” appended to the end of the URL, visit each page
of the application, and then use the little debug window, third tab from the
left, to see instructions. (And yes, I remembered to visit each page of the
application.)
That tab lists the purpose of each of its four tabs, and the third one is for
optimizing widget sets. Unfortunately, though it has all the instructions and
code to be put in the application, it is missing the list of connector names.
Here is what that tab has in it:
import java.util.HashSet;
import java.util.Set;
import com.google.gwt.core.ext.typeinfo.JClassType;
import com.vaadin.client.ui.ui.UIConnector;
import com.vaadin.server.widgetsetutils.ConnectorBundleLoaderFactory;
import com.vaadin.shared.ui.Connect.LoadStyle;
public class OptimizedConnectorBundleLoaderFactory extends
ConnectorBundleLoaderFactory {
private Set<String> eagerConnectors = new HashSet<String>();
{
}
@Override
protected LoadStyle getLoadStyle(JClassType connectorType) {
if (eagerConnectors.contains(connectorType.getQualifiedBinaryName())) {
return LoadStyle.EAGER;
} else {
// Loads all other connectors immediately after the initial view has
// been rendered
return LoadStyle.DEFERRED;
}
}
}
I figure the empty set of braces below the declaration of eagerConnectors
is supposed to have code in it to add names to the set. I figure that without
any names in that set, getLoadStyle will return DEFERRED for all connectors.
The first tab in the debug window shows the component hierarchy, and it has the
names of many connectors in it. I loaded all those into the set by modifying the
above code to this:
// ... without repeating code above this line
private Set<String> eagerConnectors = new HashSet<String>();
{
eagerConnectors.add("UIConnector");
eagerConnectors.add("NavigationManagerConnector");
eagerConnectors.add("NavigationViewConnector");
eagerConnectors.add("NavigationBarConnector");
// ... continuing through all Connector names found in the
// hierarchy tab...
}
When I attempt to run the application this way, it first puts up the little
page saying that I’m evidently running on a desktop browser (which I am), then
it fails to load. Once it just displayed its rotating image without end,
the next time it produced the following stacktrace:
39ms Dispatching: null -> APP_STARTING flags=false true false
208ms Starting application wedding-1225735508
209ms Using theme: wedding
210ms Vaadin application servlet version: 7.3.10
213ms Default implementation of createWidget() does not work for UIConnector. This might be caused by explicitely using super.createWidget() or some unspecified problem with the widgetset compilation.java.lang.IllegalStateException: Default implementation of createWidget() does not work for UIConnector. This might be caused by explicitely using super.createWidget() or some unspecified problem with the widgetset compilation.
at Unknown.Fg(rc.wedding.gwt.jwWidgetSet-0.js@41)
at Unknown.Mg(rc.wedding.gwt.jwWidgetSet-0.js@21)
at Unknown.Qsd(rc.wedding.gwt.jwWidgetSet-0.js@22)
at Unknown.uPb(rc.wedding.gwt.jwWidgetSet-0.js@2331)
at Unknown.kPb(rc.wedding.gwt.jwWidgetSet-0.js@43)
at Unknown.xkd(rc.wedding.gwt.jwWidgetSet-0.js@182)
at Unknown.KWb(rc.wedding.gwt.jwWidgetSet-0.js@430)
at Unknown.ZVb(rc.wedding.gwt.jwWidgetSet-0.js@4411)
at Unknown.Zi(rc.wedding.gwt.jwWidgetSet-0.js@102)
at Unknown.Ri(rc.wedding.gwt.jwWidgetSet-0.js@60)
at Unknown.bj(rc.wedding.gwt.jwWidgetSet-0.js@4623)
at Unknown.Xi(rc.wedding.gwt.jwWidgetSet-0.js@25)
at Unknown.qi(rc.wedding.gwt.jwWidgetSet-0.js@29)
at Unknown.vi(rc.wedding.gwt.jwWidgetSet-0.js@57)
at Unknown.eval(rc.wedding.gwt.jwWidgetSet-0.js@50)
at Unknown.eval(rc.wedding.gwt.jwWidgetSet-0.js@50)
at Unknown.eval(rc.wedding.gwt.jwWidgetSet-0.js@53)
Caused by: com.vaadin.client.metadata.NoDataException: There is no return type for com.vaadin.client.ui.ui.UIConnector.getWidget
at Unknown.Eg(rc.wedding.gwt.jwWidgetSet-0.js@30)
at Unknown.Jg(rc.wedding.gwt.jwWidgetSet-0.js@19)
at Unknown.dtc(rc.wedding.gwt.jwWidgetSet-0.js@20)
at Unknown.Ttc(rc.wedding.gwt.jwWidgetSet-0.js@89)
at Unknown.uPb(rc.wedding.gwt.jwWidgetSet-0.js@2245)
at Unknown.kPb(rc.wedding.gwt.jwWidgetSet-0.js@43)
at Unknown.xkd(rc.wedding.gwt.jwWidgetSet-0.js@182)
at Unknown.KWb(rc.wedding.gwt.jwWidgetSet-0.js@430)
at Unknown.ZVb(rc.wedding.gwt.jwWidgetSet-0.js@4411)
at Unknown.Zi(rc.wedding.gwt.jwWidgetSet-0.js@102)
at Unknown.Ri(rc.wedding.gwt.jwWidgetSet-0.js@60)
at Unknown.bj(rc.wedding.gwt.jwWidgetSet-0.js@4623)
at Unknown.Xi(rc.wedding.gwt.jwWidgetSet-0.js@25)
at Unknown.qi(rc.wedding.gwt.jwWidgetSet-0.js@29)
at Unknown.vi(rc.wedding.gwt.jwWidgetSet-0.js@57)
at Unknown.eval(rc.wedding.gwt.jwWidgetSet-0.js@50)
at Unknown.eval(rc.wedding.gwt.jwWidgetSet-0.js@50)
at Unknown.eval(rc.wedding.gwt.jwWidgetSet-0.js@53)
216ms Could not determine ApplicationConnection for Overlay. Overlay will be attached directly to the root panel
2045ms Ping URL ./PING
2046ms Sending a ping request to the server.
2053ms Dispatching: APP_STARTING -> SERVER_AVAILABLE flags=false true false
2053ms Network Back ONLINE (SERVER_AVAILABLE)
2385ms Starting application wedding-1225735508
2385ms Using theme: wedding
2385ms Vaadin application servlet version: 7.3.10
2387ms Default implementation of createWidget() does not work for UIConnector. This might be caused by explicitely using super.createWidget() or some unspecified problem with the widgetset compilation.java.lang.IllegalStateException: Default implementation of createWidget() does not work for UIConnector. This might be caused by explicitely using super.createWidget() or some unspecified problem with the widgetset compilation.
at Unknown.Fg(rc.wedding.gwt.jwWidgetSet-0.js@41)
at Unknown.Mg(rc.wedding.gwt.jwWidgetSet-0.js@21)
at Unknown.Qsd(rc.wedding.gwt.jwWidgetSet-0.js@22)
at Unknown.uPb(rc.wedding.gwt.jwWidgetSet-0.js@2331)
at Unknown.kPb(rc.wedding.gwt.jwWidgetSet-0.js@43)
at Unknown.xkd(rc.wedding.gwt.jwWidgetSet-0.js@182)
at Unknown.KWb(rc.wedding.gwt.jwWidgetSet-0.js@430)
at Unknown.ZVb(rc.wedding.gwt.jwWidgetSet-0.js@4411)
at Unknown.Zi(rc.wedding.gwt.jwWidgetSet-0.js@102)
at Unknown.Ri(rc.wedding.gwt.jwWidgetSet-0.js@60)
at Unknown.bj(rc.wedding.gwt.jwWidgetSet-0.js@4623)
at Unknown.Xi(rc.wedding.gwt.jwWidgetSet-0.js@25)
at Unknown.qi(rc.wedding.gwt.jwWidgetSet-0.js@29)
at Unknown.vi(rc.wedding.gwt.jwWidgetSet-0.js@57)
at Unknown.eval(rc.wedding.gwt.jwWidgetSet-0.js@50)
at Unknown.eval(rc.wedding.gwt.jwWidgetSet-0.js@50)
at Unknown.eval(rc.wedding.gwt.jwWidgetSet-0.js@53)
Caused by: com.vaadin.client.metadata.NoDataException: There is no return type for com.vaadin.client.ui.ui.UIConnector.getWidget
at Unknown.Eg(rc.wedding.gwt.jwWidgetSet-0.js@30)
at Unknown.Jg(rc.wedding.gwt.jwWidgetSet-0.js@19)
at Unknown.dtc(rc.wedding.gwt.jwWidgetSet-0.js@20)
at Unknown.Ttc(rc.wedding.gwt.jwWidgetSet-0.js@89)
at Unknown.uPb(rc.wedding.gwt.jwWidgetSet-0.js@2245)
at Unknown.kPb(rc.wedding.gwt.jwWidgetSet-0.js@43)
at Unknown.xkd(rc.wedding.gwt.jwWidgetSet-0.js@182)
at Unknown.KWb(rc.wedding.gwt.jwWidgetSet-0.js@430)
at Unknown.ZVb(rc.wedding.gwt.jwWidgetSet-0.js@4411)
at Unknown.Zi(rc.wedding.gwt.jwWidgetSet-0.js@102)
at Unknown.Ri(rc.wedding.gwt.jwWidgetSet-0.js@60)
at Unknown.bj(rc.wedding.gwt.jwWidgetSet-0.js@4623)
at Unknown.Xi(rc.wedding.gwt.jwWidgetSet-0.js@25)
at Unknown.qi(rc.wedding.gwt.jwWidgetSet-0.js@29)
at Unknown.vi(rc.wedding.gwt.jwWidgetSet-0.js@57)
at Unknown.eval(rc.wedding.gwt.jwWidgetSet-0.js@50)
at Unknown.eval(rc.wedding.gwt.jwWidgetSet-0.js@50)
at Unknown.eval(rc.wedding.gwt.jwWidgetSet-0.js@53)
2389ms Could not determine ApplicationConnection for Overlay. Overlay will be attached directly to the root panel
So now I’m stuck again.
Am I right that the instructions in the debug tab are supposed to have the
names of connectors included in their code?
I don’t know another way to get a complete list of connectors, or perhaps
there’s some other problem that I don’t see because this technology is new to
me.
Any help anyone can offer is appreciated.