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

PreserveOnRefresh - Regression? - since Vaadin 14.3.2 #8822

Closed
silvan-lincan opened this issue Aug 5, 2020 · 14 comments
Closed

PreserveOnRefresh - Regression? - since Vaadin 14.3.2 #8822

silvan-lincan opened this issue Aug 5, 2020 · 14 comments

Comments

@silvan-lincan
Copy link

Since Vaadin Version 14.3.2, it seems that each time you navigate to a different Route, a new UI is created when @PreserveOnRefresh is enabled.
This does not happen with lower versions of Vaadin, for example 14.3.1 / 14.3.0

To reproduce this, I just downloaded latest version of the starter: Simple App (https://vaadin.com/start/v14)
and I registered a UI init listener so that I can add a logging line.

The result: each time you try to navigate to a different Route, at least one new UI is created:

`Aug 05, 2020 3:11:30 PM com.prsrefresh.bookstore.CustomUIInitListener uiInit
INFO: CustomUIInitListener#uiInit: initializing new UI: 3
Aug 05, 2020 3:11:33 PM com.prsrefresh.bookstore.CustomUIInitListener uiInit
INFO: CustomUIInitListener#uiInit: initializing new UI: 4
Aug 05, 2020 3:21:52 PM com.prsrefresh.bookstore.CustomUIInitListener uiInit
INFO: CustomUIInitListener#uiInit: initializing new UI: 5
Aug 05, 2020 3:21:54 PM com.prsrefresh.bookstore.CustomUIInitListener uiInit
INFO: CustomUIInitListener#uiInit: initializing new UI: 6
Aug 05, 2020 3:21:56 PM com.prsrefresh.bookstore.CustomUIInitListener uiInit
INFO: CustomUIInitListener#uiInit: initializing new UI: 7
Aug 05, 2020 3:21:59 PM com.prsrefresh.bookstore.CustomUIInitListener uiInit
INFO: CustomUIInitListener#uiInit: initializing new UI: 8
Aug 05, 2020 3:22:00 PM com.prsrefresh.bookstore.CustomUIInitListener uiInit
INFO: CustomUIInitListener#uiInit: initializing new UI: 9

`

Please find as attachment, the Simple App starter with the small modifications:
preserve-on-refresh.zip

Versions:
- Vaadin / Flow version: 14.3.2
- Java version: 8
- OS version: Fedora 32
- Browser version (if applicable): Chrome / Firefox
- Application Server (if applicable): Jetty - 9.4.24.v20191120
- IDE (if applicable):

Thank you.

@denis-anisimov
Copy link
Contributor

I guess you are using dev mode with live reload Vaadin enabled.
There was a fix for live reload which creates an additional UI to be able to reload the main UI correctly.
There is a listener for browser location which updates the URL used inside Live reload component which creates a new UI.

Please try without Preserve on refresh: navigation between routes has no relation to Preserve on refresh functionality so it should behave the same.

Anyway: this is not related to preserve on refresh but related to Live reload. This doesn't happen in production mode, only in dev mode.
You may disable Live reload to avoid UI creation.

@silvan-lincan
Copy link
Author

silvan-lincan commented Aug 6, 2020

So I have the following:
First Test:

  • DevMode
  • PreserveOnRefresh: enabled
  • Live Reload: enabled

=> New UI is created on each Route change.

Second Test:

  • DevMode
  • PreserveOnRefresh: disabled
  • Live Reload: enabled

=> Everything fine, no new UI.

Third Test:

  • DevMode
  • PreserveOnRefresh: enabled
  • Live Reload: disabled

=> New UI is created on each Route change.

Should I open a new ticket with all this new Info?
Thank you.

@silvan-lincan
Copy link
Author

silvan-lincan commented Aug 6, 2020

This is important, as I wanted to upgrade to 14.3.2, because of some Dialog issues fixed, but I am not able to do this, because of this issue and I am stuck with 14.3.1
Thank you.

@denis-anisimov
Copy link
Contributor

OK, thanks for investigation.
If you say that there is no new UI created when preserve on refresh is disabled then it looks like this is related to Preserve on refresh even though as I said there was no any changes .
I'm pretty sure it's not related to preserve in refresh and I'm still pretty sure it's live reload.

I would recommend to check how it works in production because production doesn't use live reload for sure and only production is critical for extra UI : it doesn't matter in dev mode, right ?

I reopen the ticket because apparently it requires investigation but again: I'm pretty sure there is a mistake in checks and this is Live reload issue.

@silvan-lincan
Copy link
Author

Thank you very much.
Indeed, you are right, in Production Mode is not happening, no new UI is created.
But then, could you please tell me how should I deal with this in dev-mode?

@silvan-lincan
Copy link
Author

For me dev-mode also matters, as I am using the so called "session on tabs" and having a new UI on each click, it messes the functionality.

@denis-anisimov
Copy link
Contributor

The absence of new UI instance created in production is the exact indicator that this is Live reload issue.

So : please double/triple check that live reload is disabled. I'm pretty sure that this is Live reload issue.
I have no time currently to check that and I'm pretty sure that I will just confirm this fact.

Live reload creates one extra UI instance. IT create a new UI instance on route change.
This is exactly the symptom.
If you don't want this extra UI just disable Live reload .
I will be able to return back to this to confirm that this is Live reload after a day (probably tomorrow).
You have a chance to confirm this immediately if it's so important to you.

@silvan-lincan
Copy link
Author

Thank you very much, I will focus on that.

@denis-anisimov
Copy link
Contributor

Please report/close the ticket if you confirm that this is Live reload.

@silvan-lincan
Copy link
Author

Absolutely.

@silvan-lincan
Copy link
Author

silvan-lincan commented Aug 6, 2020

Hi Denis,
following your advice, I managed to disable the "Live Reload".
It took some time as I had some issues on my side setting this property from command line, but now it works from both as servlet init parameter and also as system property.
That is why in my previous tests, the "Live Reload" was not really disabled - sorry for that.

Having this, indeed, no new UI is created on Route change.

But I noticed something else, which was not happening with previous versions, for example (14.3.1 or 14.3.0): every 5 minutes, a new UI is created. Can this be related with the heart-beat?

Now, for my understanding, is this the way to go, in dev-mode, by disabling the "live reload" mechanism?

Sorry for insisting with this, but for me it is important to understand how things are working and if I am on the correct path.
Thank you.

@denis-anisimov
Copy link
Contributor

denis-anisimov commented Aug 6, 2020

I'm not aware about 5 minutes UI creation.
Are you sure that this is a new issue ?
2.3.2 Flow (14.2.3 Platform) has very minor changes comparing to 2.3.1 , so this can't be a new issue.

Anyway, this ticket is about Live reload as I suggested from the very beginning.
If you see another issue with extra UI instance then this is another ticket which requires exact steps to reproduce.
Heartbreat should not create a new UI instance.
sw.js (PWA) may create a new UI (even though it has been enabled in other project because of the same domain).
We have this issue already. But I doubt it happens every 5 minutes.

Anyway, I'm closing this ticket. Please create another one with the exact steps to reproduce if you have another issue.

OLD Vaadin Flow bugs & maintenance (Vaadin 10+) automation moved this from New P2 to Closed Aug 6, 2020
@silvan-lincan
Copy link
Author

Thank you very much.

@silvan-lincan
Copy link
Author

Perfect, so my comment about a new UI every 5 minutes was indeed PWA related, as I worked with the starter Simple App which is PWA enabled.

I knew about the issue, but I forgot completely.
I cleaned the browser cache and now everything is back to normal.
Thank you.

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

No branches or pull requests

2 participants