GWT 2.5 RC1 increases mgwt showcase by 22%

453 views
Skip to first unread message

Daniel Kurka

unread,
Jun 30, 2012, 12:58:18 AM6/30/12
to google-web-tool...@googlegroups.com
I just had a few hours of spare time and went ahead and checked out the GWT release candidate together with mgwt showcase.

I was quite staggered to see that it increases the Javascript size by 22%. I just took a brief look at the SOYC report and it seems that it fails to remove unused CSS from different permutations (that are actually not active). Somehow CSS for the blackberry permutations ends up in the iPhone permutation....

I am going to drill deeper into this, but to me this is quite critical.

-Daniel






Daniel Kurka

unread,
Jun 30, 2012, 1:07:21 AM6/30/12
to google-web-tool...@googlegroups.com
I Just took a quick look and its actually not just client bundle thats affected. If someone wants to take a look here are both soyc reports: https://www.dropbox.com/s/2edw73vpmde9oz4/soyc.zip

-Daniel

Manuel Carrasco Moñino

unread,
Jul 11, 2012, 1:10:49 PM7/11/12
to google-web-tool...@googlegroups.com
I migrated a couple of projects to 2.5.0-rc1 and the size decreased in a high degree, one of them is using mgwt btw, of course I dont use all your stuff  but I use many of the bundles, so I dont see any reason that mgwt is the cause.

It is weird that you get an increment in gwtLang specially the ClassLiteralHolder

FYI I have used this configuration for the comparison

      <properties>
        <gwt.style>OBF</gwt.style>
        <gwt.compiler.compileReport>false</gwt.compiler.compileReport>
        <gwt.draftCompile>false</gwt.draftCompile>
        <gwt.compiler.optimizationLevel>9</gwt.compiler.optimizationLevel>
        <gwt.disableClassMetadata>true</gwt.disableClassMetadata>
        <gwt.disableCastChecking>true</gwt.disableCastChecking>
        <gwt.extraJvmArgs>-Xmx1g</gwt.extraJvmArgs>
        <gwt.enableAssertions>false</gwt.enableAssertions>
      </properties>

- Manolo



Rajeev Dayal

unread,
Jul 18, 2012, 5:26:38 PM7/18/12
to google-web-tool...@googlegroups.com, Ray Cromwell, Alan Leung
Hey Daniel,

Did you find out anything more about this? Sorry for the long delay in reply - many people were on vacation after the holiday break.

I'd agree that we need to fix this for RC2/final.

Would you be able to file a bug for this so we can track it?


Rajeev

Daniel Kurka

unread,
Jul 22, 2012, 6:58:16 AM7/22/12
to google-web-tool...@googlegroups.com
I am very busy this week with other priorities. I already wanted to produce a simple bug report on which we can easily track this down.
I`ll try to do it asap.

-Daniel


Ray Cromwell

unread,
Jul 23, 2012, 12:24:00 AM7/23/12
to google-web-tool...@googlegroups.com

Are you using any Cell widgets by any chance?

I've seen that the Mail sample and ShowCase sample both shrunk, but the MobileWebApp sample increased in size. This leads me to believe it's not a compilation issue, but something in the user library pulling in a lot of extra code.

Rajeev Dayal

unread,
Jul 23, 2012, 12:21:22 PM7/23/12
to google-web-tool...@googlegroups.com
Daniel mentioned that somehow the CSS for the blackberry permutation is ending up in the iPhone permutation. That can't just be a Cell Widget issue.

On Mon, Jul 23, 2012 at 12:24 AM, Ray Cromwell <cromw...@google.com> wrote:

Are you using any Cell widgets by any chance?

I've seen that the Mail sample and ShowCase sample both shrunk, but the MobileWebApp sample increased in size. This leads me to believe it's not a compilation issue, but something in the user library pulling in a lot of extra code.

Daniel Kurka

unread,
Jul 23, 2012, 3:54:20 PM7/23/12
to google-web-tool...@googlegroups.com
We are not using any cell widgets (we wrote our own for mgwt, because the current ones don work for mobile).

I already have a good guess where this might be coming from. I'll try to provide a decent test case for it (without mgwt dependencies).

-Daniel



2012/7/23 Rajeev Dayal <rda...@google.com>

Daniel Kurka

unread,
Jul 29, 2012, 11:16:06 AM7/29/12
to google-web-tool...@googlegroups.com
I didn't have the time yet to build a test case without mgwt put here is a very basic entry point.

Compiled with GWT 2.4 its around 30k with GWT 2.5-rc its 45k (many styles not being removed):

I have attached an entrypoint which can be run with the latest mgwt jar in the classpath: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=com.googlecode.mgwt&a=mgwt&e=jar&v=LATEST

<inherits name="com.googlecode.mgwt.MGWT" />

Let me know if you need more input.

-Daniel







2012/7/23 Daniel Kurka <kurka....@gmail.com>
MGWTEntryPoint.java

Ray Cromwell

unread,
Sep 11, 2012, 6:03:02 PM9/11/12
to google-web-tool...@googlegroups.com
I finally tracked this down, it appears Android client bundles are not
being optimized out of the Iphone build, for example. This code:

public MGWTThemeBaseThemeStandardImpl() {

if (MGWT.getOsDetection().isAndroidPhone()) {
bundle = GWT.create(MGWTClientBundleBaseThemeAndroid.class);
}

if (MGWT.getOsDetection().isAndroidTablet()) {
bundle = GWT.create(MGWTClientBundleBaseThemeAndroidTablet.class);
}

if (MGWT.getOsDetection().isIPhone()) {
if (MGWT.getOsDetection().isRetina()) {
bundle = GWT.create(MGWTClientBundleBaseThemeRetina.class);
} else {
bundle = GWT.create(MGWTClientBundleBaseThemeIPhone.class);
}
}

if (MGWT.getOsDetection().isIPad()) {
if (MGWT.getOsDetection().isIPadRetina()) {
bundle = GWT.create(MGWTClientBundleBaseThemeIPadRetina.class);
} else {
bundle = GWT.create(MGWTClientBundleBaseThemeIPad.class);
}

}
...
}

on GWT 2.5 is optimized into:

function MGWTThemeBaseThemeStandardImpl_0(){
($clinit_MGWT() , false) && (this.bundle = new
MGWTClientBundleBaseThemeAndroid_iphone_safari_default_InlineClientBundleGenerator_0);
this.bundle = new
MGWTClientBundleBaseThemeIPhone_iphone_safari_default_InlineClientBundleGenerator_0;
}

This is essentially if(false) { android bundle}

I'm a little perplexed since the compiler has never really optimized
stuff like (clinit(), boolean) && blah, since it would need to hoist
the clinit() out of there which it doesn't do yet. I probably won't be
able to fix this for 2.5, but one workaround is to inline the
GWT.create(OsDetection) into the bundle theme and avoid calling MGWT
(which has a non-empty clinit)
> --
> http://groups.google.com/group/Google-Web-Toolkit-Contributors

John A. Tamplin

unread,
Sep 12, 2012, 10:35:35 AM9/12/12
to google-web-tool...@googlegroups.com
I haven't looked at MGWT at all, but I am confused -- if they are using deferred binding (if they aren't, it should be no surprise that all the mobile bundles show up since they are all in the safari permutation), why do the ifs and rely on the compiler optimizing it away, rather than just substituting a different MGWTClientBundleBaseTheme in the .gwt.xml rules?

--
John A. Tamplin

Daniel Kurka

unread,
Sep 12, 2012, 7:04:59 PM9/12/12
to google-web-tool...@googlegroups.com
Hi Ray, hi John,

I haven`t had the time to track down why this got optimized in 2.4 but does not in 2.5 anymore. We are seeing huge gains on many different mgwt apps with GWT 2.5.

@John
With mobile browsers you get a lot of small inconsistencies across many different places. I initially went ahead and build an interface with different implementations and used deferred binding in the gwt.xml file.
The problem was the amount of overhead you had to do for a simple one liner. So I went ahead and used a Generator to build an interface that is based on a property provider. The interface basically just returns true or false.

All the stuff used to compile out in gwt 2.2 so we could do something like:

if(MGWT.getIsDetection().isIphone()){
//do some small workaround
}

So right now we have a lot of places where we use those one liners to fix things. (we also use a lot of deferred binding as well).

@Ray
I am really interested in knowing why this used to work and right now it doesn't.
I just went ahead and changed the code inside the client bundle to cache an instance of OsDetection to get around the clinit.

OsDetection detection = MGWT.getOsDetection();

if (detection.isAndroidPhone()) {
bundle = GWT.create(MGWTClientBundleBaseThemeAndroid.class);
}

if (detection.isAndroidTablet()) {
bundle = GWT.create(MGWTClientBundleBaseThemeAndroidTablet.class);
}

This actually dropped code size of more than 29%. I think we got a lot of places still being affected by this change, but at this point I can go through the codebase and apply the workaround or even decide to bite some bullets on more direct deferred binding. The thing I am still wondering about what broke that we do see this problem now. I could offer some work time to go and build every version between GWT 2.5rc1 and GWT 2.4 to get a better feeling for what the actual commit is and if this is something we need to look further?! What do you think?

-Daniel
> --
> http://groups.google.com/group/Google-Web-Toolkit-Contributors

Ray Cromwell

unread,
Sep 12, 2012, 7:28:20 PM9/12/12
to google-web-tool...@googlegroups.com
I'm bogged down at the moment, but when I get free time, I can
probably figure this out via -Dgwt.jjs.traceMethod on the client
bundle in question. Probably will have to wait a few days.
> --
> http://groups.google.com/group/Google-Web-Toolkit-Contributors
Reply all
Reply to author
Forward
0 new messages