flow icon indicating copy to clipboard operation
flow copied to clipboard

Immediately detach the old UI when the browser tab is closed or refreshed

Open eriklumme opened this issue 4 years ago • 3 comments

The Beacon API is now relatively widely available, making it possible to propagate an unload event to the server when a tab is closed/refresh without affecting user experience.

This could be used to close UIs on close/refresh immediately, without waiting for expiration due to missed heartbeats. This has the potential to improve performance, primarily by decreasing memory consumption.

The heartbeat expiration or similar is still needed for when the unload event can not be propagated to the server, e.g. when the user loses network connectivity.

eriklumme avatar Aug 21 '19 08:08 eriklumme

Now with Flow 3.0 and Vaadin 15, the needed API is available in all the supported browsers as IE11 and Safari 11 are not supported anymore. This means that there is no real blockers for implementing the API for Java driven UIs (15+).

For Vaadin 14, this could be maybe considered backported as an "experimental" feature that can be enabled. Not sure if there is any trouble for users if UIs are cleaned up eagerly for some browsers, but not all.

pleku avatar Jan 20 '20 12:01 pleku

We've implemented a Beacon handler as part of Collaboration Engine. It would be great if it could be moved over to the core framework instead.

Legioth avatar Mar 29 '21 13:03 Legioth

Is it possible to distinguish between closing a tab or refreshing it via the Beacon handler?

sirbris avatar Jul 19 '22 15:07 sirbris

Started drafting this feature in https://github.com/vaadin/flow/pull/16657

mstahv avatar Apr 20 '23 16:04 mstahv

Is it possible to distinguish between closing a tab or refreshing it via the Beacon handler?

No. The trigger for sending a Beacon request is the unload event that is fired by the browser in both cases. There are probably privacy reasons for why the browser doesn't let the page know what the user is doing next.

Legioth avatar Apr 21 '23 08:04 Legioth

This feature seems to work in every browser at the moment, except Firefox. Any suggestions what could cause this issue?

Using Vaadin 24.3

Tested browsers:

  • Chrome 124 (Win 11)
  • Edge 124 (Win 11)
  • Firefox 125 (Win 11 & MacOS Ventura 13.6.6)

danielzweng avatar May 08 '24 11:05 danielzweng

Could be related to https://github.com/vaadin/flow/issues/19305#issuecomment-2095273857

mcollovati avatar May 08 '24 11:05 mcollovati