Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Trying to optimize a Touchkit Widgetset
I took an example Touchkit application and started trying things with it, writing an app for my daughter's wedding. It uses NavigationViews with buttons to move to other NavigationViews, essentially.
I've got it running on Tomcat, both locally and on a friend's server. But on the server, with a lower bandwidth, the app takes 20-60 seconds to load the first page. I looked at HTTP traffic (using Fiddler) on my own server, and there's 2-3 Megabytes of information that gets transferred to the phone before it displays the first page.
But I haven't found an explanation of how this works, only an example. So I looked at the two files I understand to be relevant in the Parking App example -- ParkingWidgetset.gwt.xml and WidgetLoaderFactory. I ended up with the following two files, first the gwt.xml:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.5.0/distro-source/core/src/gwt-module.dtd"> <module> <!-- This file is automatically updated based on new dependencies by the goal "vaadin:update-widgetset". --> <!-- Inherit DefaultWidgetSet --> <inherits name="com.vaadin.DefaultWidgetSet" /> <inherits name="com.vaadin.addon.touchkit.gwt.TouchKitWidgetSet" /> <generate-with class="rc.wedding.ui.WidgetLoaderFactory"> <when-type-assignable class="com.vaadin.client.metadata.ConnectorBundleLoader" /> </generate-with> </module>
Then the WidgetLoaderFactory:
And let me just say a word about compiling a Touchkit application -- once you've messed with anything connected to the Widgetset (and I have not yet figured out everything that does), you are in for a treat. Some combination of the following will work, in some order, lots of the time:
- stop the server
- remove the app from the server
- clean the server
- clean the work directory of the server
- maven clean
- maven install
- maven compile
- add the app to the server
- start the server
I can usually count on doing most of these at least twice before the app will start again.
However, with the above two files in the project, the app doesn't start -- I get the "You seem to be using a desktop application" when I'm on my PC, but the page afterwards is just blank.
I don't know where any log messages would be, or any other way to figure out what's wrong. Can someone tell me if I'm missing something?
I think I have connectors for all my components, but if I'm missing one I don't know how to find out. There was a suggestion in one of the articles to use a debugger on a class that had a list of all the components that had been used so far, but I couldn't find the class in eclipse, either source or class.
The best way to collect the list of used connectors is to use the debug dialog (opened by appending "?debug" to the URL). Then navigate throught the apps features and after that click the "magic" button on the third tab of the debug dialog to see the "default" instructions to create the optimized widgetset. You'll see the list there, I think the touchkit documentation originates from era when that feature was not there in the debug dialog. But otherwise I think you should follow the official documentation:
Your startup time seem so slow that you should probably also verify where the real bottleneck really is. Maybe your app is doing some expensive db operation in the beginning. You can get hints of this form the debug dialog as well. Also maybe inspect the app using browsers debugging tools to see what is taking long.
Latest Vaadin versions use GWTs pre-compressing of static resources, so enabling GZIP with other mechanisms probably don't help that much, it will only enable gzip of the actual UI state, the client side engine should already be compressed.
But, something is definitely taking too long for you, especially if also the subsequant app loads takes long. TouchKit should generate you "cache manifest" and not load anything by the initial UI state on subsequent calls. If you can't figure it out yourself, contact our experts via pro support and they'll figure out what is wrong. If you can share a link to you app here on forum, me or somebody else from the community can probably also give additional hints.