Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
eriklumme opened this issue Aug 21, 2019 · 7 comments · Fixed by #16657
Closed

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

eriklumme opened this issue Aug 21, 2019 · 7 comments · Fixed by #16657

Comments

@eriklumme
Copy link

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.

@pleku
Copy link

pleku commented Jan 20, 2020

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.

@Legioth
Copy link
Member

Legioth commented Mar 29, 2021

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.

@sirbris
Copy link

sirbris commented Jul 19, 2022

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

@mstahv
Copy link
Member

mstahv commented Apr 20, 2023

Started drafting this feature in #16657

@Legioth
Copy link
Member

Legioth commented Apr 21, 2023

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.

mcollovati pushed a commit that referenced this issue Apr 27, 2023
Notifies server about closed UIs using a beacon request on pagehide event.

At the same time unifies behaviour in certain edge cases, where Safari maintained the state when brought back from page cache. Previously Safari in some situations kept the state.

Tested manually with Safari, Chrome, Firefox and validated results using VisualVM.

Closes #6293
tltv pushed a commit that referenced this issue Nov 24, 2023
Notifies server about closed UIs using a beacon request on pagehide event.

At the same time unifies behaviour in certain edge cases, where Safari maintained the state when brought back from page cache. Previously Safari in some situations kept the state.

Tested manually with Safari, Chrome, Firefox and validated results using VisualVM.

Closes #6293
tltv pushed a commit that referenced this issue Nov 27, 2023
Notifies server about closed UIs using a beacon request on pagehide event.

At the same time unifies behaviour in certain edge cases, where Safari maintained the state when brought back from page cache. Previously Safari in some situations kept the state.

Tested manually with Safari, Chrome, Firefox and validated results using VisualVM.

Closes #6293
mcollovati pushed a commit that referenced this issue Nov 27, 2023
Notifies server about closed UIs using a beacon request on pagehide event.

At the same time unifies behaviour in certain edge cases, where Safari maintained the state when brought back from page cache. Previously Safari in some situations kept the state.

Tested manually with Safari, Chrome, Firefox and validated results using VisualVM.

Closes #6293

Co-authored-by: Matti Tahvonen <matti@vaadin.com>
tltv added a commit that referenced this issue Nov 28, 2023
* feat: More eager cleanup for UIs using Beacon API (#16657)

Notifies server about closed UIs using a beacon request on pagehide event.

At the same time unifies behaviour in certain edge cases, where Safari maintained the state when brought back from page cache. Previously Safari in some situations kept the state.

Tested manually with Safari, Chrome, Firefox and validated results using VisualVM.

Closes #6293

* chore: updated test to run with older selenium API

* chore: clean up

* chore: fixed window index in IT

---------

Co-authored-by: Matti Tahvonen <matti@vaadin.com>
@danielzweng
Copy link

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)

@mcollovati
Copy link
Collaborator

Could be related to #19305 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants