GWT应用程序在最新的Firefox 21及更高版本中崩溃

时间:2013-09-17 03:52:44

标签: firefox gwt

我们有一个GWT应用程序在Firefox 21及更高版本中崩溃,包括最新版本23.0.1。在早期版本的Firefox和IE 9中,它运行正常。这是在部署模式下,而不是因为GWT插件。它崩溃的情况是当有大量的RPC调用时,可能大约在300到400之间。

由于它发生的应用程序相当复杂,我试图用一个简单的原型来模拟这个问题。我观察到当RPC调用次数达到100000时我的原型崩溃。但是在我的应用程序中,使用Firebug观察到RPC调用大约为300-400时,这种情况不太可能发生。

我试图找出我原型中缺少的其他内容,以便它也会因300-400次RPC调用而崩溃。

GWT版本 - 2.4 GXT版本 - 2.2.5

package com.ganesh.check.firefox.client;
public class FirefoxCrash implements EntryPoint {

private static final String SERVER_ERROR = "An error occurred while "
        + "attempting to contact the server. Please check your network "
        + "connection and try again.";


private final GreetingServiceAsync greetingService = GWT
        .create(GreetingService.class);

public native static void consoleLog(String text)/*-{
                                        $wnd.console.log(text);
                                        }-*/;

public void onModuleLoad() {
    final Button sendButton = new Button("Send");
    final TextBox nameField = new TextBox();
    nameField.setText("GWT User");
    final Label errorLabel = new Label();
    final Label countLabel = new Label();

    // We can add style names to widgets
    sendButton.addStyleName("sendButton");

    // Add the nameField and sendButton to the RootPanel
    // Use RootPanel.get() to get the entire body element
    RootPanel.get("nameFieldContainer").add(nameField);
    RootPanel.get("sendButtonContainer").add(sendButton);
    RootPanel.get("errorLabelContainer").add(errorLabel);
    RootPanel.get("count").add(countLabel);

    // Focus the cursor on the name field when the app loads
    nameField.setFocus(true);
    nameField.selectAll();

    // Create the popup dialog box
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("Remote Procedure Call");
    dialogBox.setAnimationEnabled(true);
    final Button closeButton = new Button("Close");
    // We can set the id of a widget by accessing its Element
    closeButton.getElement().setId("closeButton");
    final Label textToServerLabel = new Label();
    final HTML serverResponseLabel = new HTML();
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.addStyleName("dialogVPanel");
    dialogVPanel.add(new HTML("<b>Sending name to the server:</b>"));
    dialogVPanel.add(textToServerLabel);
    dialogVPanel.add(new HTML("<br><b>Server replies:</b>"));
    dialogVPanel.add(serverResponseLabel);
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
    dialogVPanel.add(closeButton);
    dialogBox.setWidget(dialogVPanel);

    // Add a handler to close the DialogBox
    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
            sendButton.setEnabled(true);
            sendButton.setFocus(true);
        }
    });


    class MyHandler implements ClickHandler, KeyUpHandler {

        private int resultCount = 0;

        /**
         * Fired when the user clicks on the sendButton.
         */
        public void onClick(ClickEvent event) {
            sendNameToServer();
        }

        public void onKeyUp(KeyUpEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                sendNameToServer();
            }
        }


        private void sendNameToServer() {
            // First, we validate the input.
            errorLabel.setText("");
            String textToServer = nameField.getText();

            // Then, we send the input to the server.
            textToServerLabel.setText(textToServer);
            serverResponseLabel.setText("");
            final int loopCount = Integer.parseInt(textToServer);
            resultCount=0;

            for (int i = 0; i < loopCount; i++) {
                greetingService.getResult(textToServer,
                        new AsyncCallback<ResultBean>() {
                            public void onFailure(Throwable caught) {
                                consoleLog(caught.getMessage());
                            }

                            public void onSuccess(ResultBean result) {
                                //countLabel.setText(++resultCount + "");
                                resultCount++;
                                if(resultCount==loopCount){
                                    countLabel.setText(resultCount + "");
                                }
                                consoleLog("Result returned for "+resultCount);
                            }
                        });
            }
        }
    }

    // Add a handler to send the name to the server
    MyHandler handler = new MyHandler();
    sendButton.addClickHandler(handler);
    nameField.addKeyUpHandler(handler);
}
}

public class GreetingServiceImpl extends RemoteServiceServlet implements
GreetingService {

public ResultBean getResult(String name) {
  ResultBean result = new ResultBean();
  Random random = new Random();
  int suffix = random.nextInt();

  result.setName("Name "+suffix);
  result.setAddress("Address "+suffix);
  result.setZipCode(suffix);
  result.setDoorNumber("Door "+suffix);
  return result;
}


public class ResultBean implements Serializable {
public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getAddress() {
    return address;
}

public void setAddress(String address) {
    this.address = address;
}

public int getZipCode() {
    return zipCode;
}

public void setZipCode(int zipCode) {
    this.zipCode = zipCode;
}

public String getDoorNumber() {
    return doorNumber;
}

public void setDoorNumber(String doorNumber) {
    this.doorNumber = doorNumber;
}

private String name;
private String address;
private int zipCode;
private String doorNumber;

  }

0 个答案:

没有答案