Code Splitting / GWT.runAsync (Web mode vs. Hosted Mode)

69 views
Skip to first unread message

Salman Hemani

unread,
Oct 13, 2011, 1:07:54 PM10/13/11
to Google Web Toolkit
Hi,

I am having some difficulty understanding why my code splitting
functionality is not working as expected in web mode. I have a decent
size application and I've managed to successfully create the split
points. The process goes like this:

1. Load the application which takes you to the first view (login page)
and the initial code is downloaded
2. The next piece of code is executed if login is successful. This is
defined within the GWT.runAsyn(..) call.

The issue is that it works perfectly in hosted mode. But when I launch
it within the browser without hosted mode, the panel that is
initialized under the split point seems like it never actually
initialized (onSuccess() did invoke - I put in a Window.alert to test
it).

Has anyone experienced this before? Or have a suggestion as to where I
might start dig deeper? I'll still keep searching but so far have not
had any luck.

Regards,
Salman

Jens

unread,
Oct 13, 2011, 2:00:55 PM10/13/11
to google-we...@googlegroups.com
The only difference between hosted and web mode is that in hosted mode GWT.runAsync() acts synchronously. A code like:

void onLoginSuccessful() {
  doBeforeAppStart();
  GWT.runAsync( // load app and start app in onSuccess() )
  doAfterAppStart();
}

will behave differently in hosted and web mode. In hosted mode it will be executed in the order above but in web mode onSuccess() can be called after doAfterAppStart() has finished. So you may want to check your code to see if it behaves correctly.

Otherwise I have not seen any problems with split points so far. 

-- J.

 

Kevin Jordan

unread,
Oct 13, 2011, 2:59:16 PM10/13/11
to Google Web Toolkit
Yeah, in hosted mode it just goes directly into the onSuccess callback
whereas in web mode it has to download the piece of javascript needed
for that point and so that requires it to do it asynchronously which
means anything else inside your function where you call runAsync will
be executed while that is still downloading and being parsed. You'll
want to design it like any other server request you'd make as you
should assume it will make server call.

Salman Hemani

unread,
Oct 13, 2011, 5:05:11 PM10/13/11
to Google Web Toolkit
Thanks guys, I am going to give that a shot tonight!

Salman Hemani

unread,
Oct 13, 2011, 9:42:40 PM10/13/11
to Google Web Toolkit
Just wanted to confirm and also let others who run into this issue in
the future know, that based on your hints, I was able to resolve this
issue. Thank you!

Yurgis

unread,
Oct 13, 2011, 7:59:21 PM10/13/11
to google-we...@googlegroups.com
I have a similar problem that I think started after upgrade to 2.4.0
Dev mode works fine, while web mode does not work sometime after some
modifications are done in a part of the code being split.
Making full clean build resolves the problem.
So it might have to be related to "persisted unit cache" feature of
the compiler.

> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to google-we...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-tool...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages