wbstr / vaadin-multifileupload

12 stars 23 forks source link

Unresponsive UI during upload #10

Closed reynoldsjj closed 10 years ago

reynoldsjj commented 10 years ago

When I upload a file the UI becomes unresponsive and I cannot on click anything, including the cancel button. If I use the SlowUpload in the example WidgetTestApplication, the addon works as expected. But, removing the sleeping thread in SlowUploadStatePanel causes the UI to freeze until the upload finishes. Am I missing a step?

Note: I am using vaadin 7.1.7.

juger89 commented 10 years ago

Could you provide a sample code for example in a GitHub repository? The example should work without the sleeping thread too. If you test it in local without sleep, the file upload may become so fast that the upload state window will not show up, but there is no freezing at all. Which browser and web server are you using?

reynoldsjj commented 10 years ago

Unfortunately, I don't have my application on a public repository, but I setup my upload component like you do and put it in a CssLayout.

I am using your WidgetTestApplication in your repository where the only changes I make are: https://github.com/wbstr/vaadin-multifileupload/blob/master/src/main/java/com/wcs/wcslib/vaadin/widget/multifileupload/WidgetTestApplication.java

private class SlowUploadStatePanel extends UploadStatePanel {

        public SlowUploadStatePanel(UploadStateWindow window) {
            super(window);
        }

        @Override
        public void onProgress(StreamVariable.StreamingProgressEvent event) {
            //try {
                //Thread.sleep((int) uploadSpeed);
            //} catch (InterruptedException ex) {
                //Logger.getLogger(WidgetTestApplication.class.getName()).log(Level.SEVERE, null, ex);
            //}
            super.onProgress(event);
        }
    }
UploadStateWindow window = new UploadStateWindow();
window.setWindowPosition(WindowPosition.TOP_RIGHT);
UploadFinishedHandler handler = new UploadFinishedHandler() {
    @Override
    public void handleFile(InputStream stream, String fileName, String mimeType, long length) {
        // Doing nothing still causes the application to freeze.
    }
};
fileUpload = new SlowUpload(handler , window, false);
// I am not setting a file size limit.
fileUpload.setPanelCaption("Multiple Upload");
fileUpload.getSmartUpload().setUploadButtonCaptions("Upload File", "Upload Files"); 
fileUpload.getSmartUpload().setUploadButtonIcon(new ThemeResource("icons/chalkwork/basic/document_add_16x16.png"));
fileUpload.addStyleName("myupload");
addComponent(fileUpload);

If I upload a large file (>5MB) the Vaadin loading indicator will spin/freeze until the upload finishes. I can see the upload state window, but it doesn't update as often as it should and I cannot click on the cancel button. If I try to click anywhere within the application I get a 'Warning: Unresponsive script' notification.

I have tried it in Google Chrome: Version 31.0.1650.63 and Firefox: 24.0, 26.0. I am using Resin 4.0.37 as the web server both locally and remotely (I get the same results either way).

I have also tried to use the upload and upload monitor in the Vaadin Sampler by itself and I experience the same issue. http://demo.vaadin.com/sampler/#ui/data-input/other/upload

reynoldsjj commented 10 years ago

Solved.

Multifileupload version 1.6 uses a Progress Indicator that sets a Polling-interval. In Vaadin 7.1, enabling both a Polling-Interval and Push support at the same time can cause issues. I had to modify Multifileupload to use a Progress Bar and make sure it did not set a Polling-Interval.

juger89 commented 10 years ago

Thanks for the solution, I've replaced ProgressIndicator to ProgressBar in version 1.7.