Firefox hang

15 views
Skip to first unread message

jimirwin

unread,
Jan 24, 2008, 9:12:14 AM1/24/08
to Google Web Toolkit
I just got started with using GWT to test the feasibility with using
it in our legacy app. I have a number of existing pages which I would
like to turn into split windows, so that I can add a tree to the left
pane and show the existing legacy content in the right pane. I
downloaded GWT 1.4.61 for windows and installed it. I followed the
FAQs for using my own server in hosted mode and for changing the
location of the cache/nocache files. All that works OK.

I compile the following code and run it in Firefox. When I access the
page the first time, everything loads correctly and my legacy content
appears in the right pane. However, if I navigate to another page,
for instance by following a link to another page on my site, and then
navigate back to my page, Firefox hangs and goes to 100% processor
utilization. Eventually, Firefox pops up a dialog saying
"A script may be busy or has stopped responding. ...".

If I had to guess, I would guess that there is some kind of race
condition that is affected by cache content. On the first access,
some code could be delayed by the server, and so the page loads with
no problem. On the second access, something could already be in cache
so some timing-dependent code could execute differently and enter a
non-terminating loop.

Here is my entry point. This is the only code that I've written, so
there is no other GWT code being executed in the page.

public void onModuleLoad() {
final HorizontalSplitPanel splitter = new HorizontalSplitPanel();
splitter.setHeight("600px");
splitter.setSplitPosition("200px");
final FlowPanel leftPane = new FlowPanel();
final FlowPanel rightPane = new FlowPanel();
splitter.setLeftWidget(leftPane);
splitter.setRightWidget(rightPane);
final Label leftLabel = new Label("Left");
leftPane.add(leftLabel);
final Element content = DOM.getElementById("_content");

if (content != null)
DOM.appendChild(rightPane.getElement(), content);
RootPanel.get("splitter").add(splitter);
}

The code constructs a HorizontalSplitPanel and two FlowPanels for the
left and right widgets. I put a label in the left pane. I find the
DOM element for my old legacy content, a DIV element, and move it into
the right pane. Finally I attach the splitter Widget to its slot in
the page.

It turns out that if I comment out the code that moves the old content
into the right panel, then Firefox no longer hangs when I navigate
from and to the page. Unfortunately, the whole point is to put the
legacy content inside the splitter.

I initially tried the following to move the legacy content into the
right pane:
RootPanel content = RootPanel.get("_content");
rightPane.add(content);

However, that causes an exception:
java.lang.IllegalStateException: Should only call onAttach when the
widget is detached from the browser's document
at com.google.gwt.user.client.ui.Widget.onAttach(Widget.java:107)
at com.google.gwt.user.client.ui.Panel.doAttachChildren(Panel.java:
162)
at com.google.gwt.user.client.ui.Widget.onAttach(Widget.java:113)
at com.google.gwt.user.client.ui.Panel.doAttachChildren(Panel.java:
162)
at com.google.gwt.user.client.ui.Widget.onAttach(Widget.java:113)
at com.google.gwt.user.client.ui.Widget.setParent(Widget.java:241)
at com.google.gwt.user.client.ui.Panel.adopt(Panel.java:119)
at com.google.gwt.user.client.ui.ComplexPanel.add(ComplexPanel.java:
85)
at com.google.gwt.user.client.ui.AbsolutePanel.add(AbsolutePanel.java:
68)
at com.mycompany.test.client.MyTest.onModuleLoad(...)

I found that by using the DOM methods to move the element, the
exception does not occur.

Is there something that I have done incorrectly that might explain the
Firefox hang? Is there another way I should move the legacy content
into the splitter?


jimirwin

unread,
Jan 24, 2008, 9:36:35 AM1/24/08
to Google Web Toolkit
Here's another odd symptom. When I load the page in IE, the browser
doesn't hang, but it does keep the processor continuously busy at
about 30-50% utilization after the page has loaded and is displayed.
If I comment out the code that moves the legacy content into the
splitter, the browser processor utilization drops to about 0% after
the page loads.

Adam T

unread,
Jan 24, 2008, 11:04:23 AM1/24/08
to Google Web Toolkit
Hi,

Not sure I can really comment on if what you are doing has various
issues or not. However, I do something similar in one of my apps, but
use slightly different DOM methods and I haven't seen the performance
issues you mention. Maybe you might get some mileage changing some of
the methods; here is what I have:


String intro =
DOM.getInnerHTML(RootPanel.get("introduction").getElement());
HTML introHTML = new HTML(intro);
introHTML.setStyleName("text");
tp.add(introHTML, "introduction");
DOM.setInnerHTML(RootPanel.get("introduction").getElement(), "");

This moves the content of my "introduction" div from legacy HTML into
its own panel (in this case part of a (badly) named tabbed panel, tp)
- the only thing it doesn't do is "clone" the style so I have to
reapply the style name in the code.

//Adam

jimirwin

unread,
Jan 24, 2008, 11:46:23 AM1/24/08
to Google Web Toolkit
Thanks. I think I found another solution that also solves the
problem.

I subclassed Widget to create a class that acts as a wrapper around my
legacy content:

class ContentWrapper extends Widget {
ContentWrapper(Element element) {
super();
this.setElement(element);
}
}

I instantiate the ContentWrapper object using the Element I obtain
from DOM:

final Widget content = new
ContentWrapper(DOM.getElementById("_content"));

Now that content widget can simply be added to the pane:

rightPane.add(content);

This seems to solve all the problems that I observed before. IE no
longer consumes processor cycles after the page loads, and Firefox no
Reply all
Reply to author
Forward
0 new messages