On Tue, Sep 11, 2012 at 6:03 PM, Ray Cromwell <cromwell...@google.com>wrote:

> 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)


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

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

Reply via email to