vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
620 stars 167 forks source link

Using UI.setPollInterval should not choke the client-server communication #9512

Open mstahv opened 3 years ago

mstahv commented 3 years ago

Description of the bug / feature

If poll interval is set, the client queues server visits if server cannot be reached or there is an ongoing server visit. Server visit should only be queued if previous server poll has finished. This works fine in Vaadin 8 applications, but with V10+ apps the servervisits are queued and finally dumped to server as fast as possible when the clint-server communication is free again. This may cause extra lag when returning from a bad connection and causes obsolete resource usage.

Minimal reproducible example

@Route
public class MainView extends VerticalLayout {

    public MainView() {
        Button button = new Button("Make a long blockking call",
                e -> {
                    try {
                        Thread.sleep(10000);
                    } catch (InterruptedException ex) {
                        Logger.getLogger(MainView.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    Notification.show("Process done");
                });
        add(button);

        UI.getCurrent().addPollListener(p -> {
            System.out.println("POLL " + LocalDateTime.now());
        });

        UI.getCurrent().setPollInterval(1000);

    }

}

Expected behavior

Server visits should be skipped if the communication has stalled.

Actual behavior

Obsolete server visits.

Versions:

- Vaadin / Flow version: 10+
- Java version: any
- OS version: any
- Browser version (if applicable): any
- Application Server (if applicable): any
- IDE (if applicable): any
Legioth commented 3 years ago

I guess that on a low level, what's missing compared to Vaadin 8 is something corresponding to @Delayed(lastOnly = true).

mstahv commented 3 years ago

I was shortly looking into this and tracked the implementation to this class. Had no idea how to try to solve that. https://github.com/vaadin/flow/blob/master/flow-client/src/main/java/com/vaadin/client/communication/Poller.java

gscaparrotti commented 1 year ago

Is there an ETA for a fix?