Gwt-App totally blocks Browser-UI

334 views
Skip to first unread message

tanteanni

unread,
Nov 2, 2011, 5:57:06 AM11/2/11
to google-we...@googlegroups.com
At the start of my App the Browser has to load some stuff and create some data objects (Trees). The Problem is, that this blocks the the whole browser (no tab switching no reaction on user interactions, even my animated loading.gif is not loaded/animated). In swing applications the is a "SwingWorker" to keep the ui running - for example to display a progress bar.
But how to achieve this with GWT? My guess is to use Scheduler some how?! I want to get the loading more in background and keep the browser more responsive. But how to do this?


thx in advance


Paul Robinson

unread,
Nov 2, 2011, 6:27:19 AM11/2/11
to google-we...@googlegroups.com
Javascript is single threaded, so you shouldn't do too much in one go.

You can use Scheduler.get().scheduleIncremental(repeatingCmd) to do some work in pieces. If the problem is that it's slow while dealing with large RPC messages, then you may need smaller messages.

HTH
Paul

tanteanni

unread,
Nov 2, 2011, 7:27:48 AM11/2/11
to google-we...@googlegroups.com
thx,

are there any examples how to use scheduleIncremental? I don't want/can't to split the work that has to be done manually but i want to give the browser a chance to do other stuff - is it possible to interrupt a task for some time? 
In my case the main work has two parts: loading of data (one ArrayList containing the tree structure) and creating a tree widget with it. but splitting the work in this two parts wouldn't be enough - the second part alone could block a browser on a slow machine for up to 10seconds - very bad.
(optimizing the code or give back some work to server is part of another discussion - not to be led here)

Paul Robinson

unread,
Nov 2, 2011, 9:59:54 AM11/2/11
to google-we...@googlegroups.com
Sounds like you're creating a tree with too many items. (How many?)

Maybe you need some lazy creating of tree items.

Paul

> --
> You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/OsqLAj1awYIJ.
> 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.

tanteanni

unread,
Nov 3, 2011, 3:23:11 AM11/3/11
to google-we...@googlegroups.com
it's an tree with 16k items (all administrative units of germany) - the main advantage to load all items is, i got a very fast live search on the tree. but as i said before i don't want to discuss this here. i ask how to get an loading overlay/progress bar that doesn't freeze on loading.
i saw many of them in all the gwt/other framework's showcases. so how to use scheduler or something else to keep a loading icon moving and the browser responsive?

thx in advance?

Jens

unread,
Nov 3, 2011, 5:34:40 AM11/3/11
to google-we...@googlegroups.com
If you load that 16k items with GWT-RPC your first problem that freezes your browser is probably the deserialization process when receiving the answer from the server (converting the string received back to your object graph / list). So comment out all your tree stuff and first solve the freeze caused by the request itself.
What you can try is to avoid GWT-RPC for this request and instead use plain JSON. If your browser freezes even with JSON then you have to load less data or live with the freeze. Keep in mind that an animated loading indicator (e.g. animated gif) will also freeze once the browser freezes because the browser does not have the time to animate the image.

Once you have solved the freeze caused by GWT-RPC you can optimize the tree view if you still see some freeze. A good way to optimize a view is to only add the specific data to the view that is currently visible or if you really need to add everything then use an IncrementalCommand with the Scheduler.

tanteanni

unread,
Nov 4, 2011, 10:01:10 AM11/4/11
to google-we...@googlegroups.com
thx for the info jens,

do you say there is no way to keep the browser responsive but to do less work/ transfer less data on/to client? is there at least a way to keep browser responsive if browser has to do much work/logic?

if i understood it right: transfer much data is worse than to do much work on client side? so all efforts should go into reducing data amounts transfered to client? but lets assume for a moment that the rpc-call isn't the problem but the logic that handles the data received. could this cause a freeze of the browser? if yes how to avoid it? probably by using schedulInterupted? how to use it?

or how to optimize the view in the way you suggested? At the moment the view shows the filtered tree and keeps an unfiltered tree to provide the tree faster if user clears the filter/resets the tree. the tree rendeing and realtime filtering is very fast - i think no incremental command is necessary. the only problem is the first loading/rendering of the tree - the tree is submitted in an very special data structure (arrayList, composite pattern) that makes live filter as fast as it is.

i could try to create this structure on client side (more logic less data)...

Reply all
Reply to author
Forward
0 new messages