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

feat: More eager cleanup for UIs using Beacon API #16657

Merged
merged 16 commits into from
Apr 27, 2023

Conversation

mstahv
Copy link
Member

@mstahv mstahv commented Apr 20, 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

Type of change

  • Bugfix
  • Feature

Checklist

  • I have read the contribution guide: https://vaadin.com/docs/latest/guide/contributing/overview/
  • I have added a description following the guideline.
  • The issue is created in the corresponding repository and I have referenced it.
  • I have added tests to ensure my change is effective and works as intended.
  • New and existing tests are passing locally with my change.
  • I have performed self-review and corrected misspellings.

Additional for Feature type of change

  • Enhancement / new feature was discussed in a corresponding GitHub issue and Acceptance Criteria were created.

@github-actions
Copy link

github-actions bot commented Apr 20, 2023

Test Results

   983 files  +1     983 suites  +1   1h 13m 24s ⏱️ - 8m 41s
6 179 tests +1  6 140 ✔️ +1  39 💤 ±0  0 ±0 
6 430 runs  +4  6 384 ✔️ +2  46 💤 +2  0 ±0 

Results for commit 631fdf1. ± Comparison against base commit e6686c0.

♻️ This comment has been updated with latest results.

@mshabarov mshabarov added the Contribution PRs coming from the community or external to the team label Apr 21, 2023
mstahv added 2 commits April 21, 2023 11:46
Safari sometimes causes exception that is reported to the log, although behavior is not critical.
@mstahv mstahv marked this pull request as ready for review April 21, 2023 11:44
@mstahv
Copy link
Member Author

mstahv commented Apr 21, 2023

Included IT only runs in Chrome 🤔 Might be good to get it run also on Chrome and Safari + permutation with Push on, but some team member can probably configure that about 10k time faster than me 👼

@mstahv
Copy link
Member Author

mstahv commented Apr 21, 2023

Looks like Push is on by default for these tests, I think that is enough as the xhr mode has much less moving parts. Also heard that in "platform tests" these tests are run on other browsers, so all should be covered.

addin some git ignores might help 🤓
@mstahv mstahv force-pushed the feature/eager-ui-cleanup-with-beacon-api branch from a0920c8 to 3781c28 Compare April 21, 2023 12:09
@vaadin-bot vaadin-bot added +1.0.0 and removed +0.0.1 labels Apr 21, 2023
@vaadin-bot vaadin-bot added +0.0.1 and removed +1.0.0 labels Apr 21, 2023
@mstahv
Copy link
Member Author

mstahv commented Apr 24, 2023

Gave another look to failing preserveonrefresh tests in spring-test modules. Looks like my separate test project didn't have its client side updated and it was sending its beacon request in a different event that I used in early prototypes. Or something else weird that actually made preserveonrefresh work.

Now disabled the check for those views in 3361b18

An option would be to put those views into some lazy close queue, where they would be cleaned after it is clear that it was a not a reload. I don't it is very relevant though. Maybe it would even be undesired (can't come back to the previous state with back button e.g. after x minutes like now). I don't have an opinion on that feature because I never used it 🤷‍♂️

@mcollovati mcollovati requested review from czp13 and mcollovati April 24, 2023 11:12
Copy link
Collaborator

@mcollovati mcollovati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some typo and nits.
I would also like @heruan to have a brief look, to be sure this change may not break beacon handling in Collaboration Kit

…/AtmospherePushConnection.java

Co-authored-by: Marco Collovati <marco@vaadin.com>
mstahv and others added 2 commits April 27, 2023 10:05
…/ServerRpcHandler.java

Co-authored-by: Marco Collovati <marco@vaadin.com>
@mstahv
Copy link
Member Author

mstahv commented Apr 27, 2023

I briefly looked at what @heruan et co have done in collaboration engine with beacon api, and my hunch is that no issues with that. Currently you seem to be hooking on unload event, which is kind of deprecated but works most often. Depending on how you use it, you might in some cases now (after this change) use normal detach listeners, but I'd expect that you should at least in upcoming versions also detect visibility changes as well (e.g. to gray out a user who has switched to another tab) 🤷‍♂️

mcollovati
mcollovati previously approved these changes Apr 27, 2023
Copy link
Collaborator

@mcollovati mcollovati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (unless there are troubles with Collaboration KIT)

…ion.java

Co-authored-by: Peter Czuczor <61667986+czp13@users.noreply.github.com>
…ion.java

Co-authored-by: Peter Czuczor <61667986+czp13@users.noreply.github.com>
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 4 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@mstahv mstahv changed the title More eager cleanup for UIs using Beacon API feat: More eager cleanup for UIs using Beacon API Apr 27, 2023
Copy link
Contributor

@czp13 czp13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@mcollovati mcollovati merged commit d08549a into main Apr 27, 2023
@mcollovati mcollovati deleted the feature/eager-ui-cleanup-with-beacon-api branch April 27, 2023 11:44
mcollovati added a commit to vaadin/patient-portal-demo-flow that referenced this pull request May 11, 2023
Since Flow 24.1.0.alpha4, the UIs are closed eagerly when navigating away from
the page. To test memory used by multiple UIs, they should be opened in
separated tabs.

See vaadin/flow#16657
caalador pushed a commit to vaadin/patient-portal-demo-flow that referenced this pull request May 11, 2023
Since Flow 24.1.0.alpha4, the UIs are closed eagerly when navigating away from
the page. To test memory used by multiple UIs, they should be opened in
separated tabs.

See vaadin/flow#16657
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 24.1.0.

tltv pushed a commit that referenced this pull request 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 pull request 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 pull request 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 pull request 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Contribution PRs coming from the community or external to the team Released with Vaadin 24.1.0 +0.0.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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