Tatu Lund:
…Have you checked what happens if you add @PreserveOnRefresh, which is a new feature in Vaadin 14.
Yes, I did try @PreserveOnRefresh
.
I added the annotation to both my MainView
and my OtherView
.
@PWA disabled
With @PWA
disabled I get the following after simply having loaded localhost:8080
(did not click the Click Me button, did not navigate to other view).
BASIL - new UI instantiated. UI id # 0 2019-08-24T05:05:31.215158Z
BASIL - new UI instantiated. UI id # 0 2019-08-24T05:05:31.215159Z
BASIL - new UI instantiated. UI id # 0 2019-08-24T05:05:31.215159Z
BASIL - new MainView instantiated. 2019-08-24T05:05:31.228399Z
BASIL - new UI instantiated. UI id # 1 2019-08-24T05:05:32.005648Z
[qtp1639962586-26]
WARN com.vaadin.flow.server.communication.UidlRequestHandler - Invalid security key received from 0:0:0:0:0:0:0:1
BASIL - new UI instantiated. UI id # 2 2019-08-24T05:05:32.337352Z
BASIL - new MainView instantiated. 2019-08-24T05:05:32.337951Z
BASIL - new UI instantiated. UI id # 3 2019-08-24T05:05:32.499706Z
BASIL - new UI instantiated. UI id # 4 2019-08-24T05:05:33.346649Z
Notice the mysterious WARN
. I’ve seen only one other time today during all my testing. I assume that number in the message is IPv6 address. I am usig macOS Mojave, so IPv6 is enabled by default.
@PWA enabled
After re-enabling the @PWA
(and doing a Maven clean
& install
, as I do on every one of these tests) I get the following when loading localhost:8080
.
BASIL - new UI instantiated. UI id # 0 2019-08-24T05:11:01.775761Z
BASIL - new MainView instantiated. 2019-08-24T05:11:01.788959Z
That was good.
Clicking the “Click Me” button produces no more console output. Good.
Hitting the browser Reload icon produces no more console output. Good.
Problem solved? No. Routing is wonky.
Typing “/other” onto the end of the URL results in several more lines of console output. Bad.
BASIL - new UI instantiated. UI id # 1 2019-08-24T05:12:52.122436Z
BASIL - new UI instantiated. UI id # 2 2019-08-24T05:13:23.816226Z
BASIL - new MainView instantiated. 2019-08-24T05:13:24.214334Z
BASIL - new UI instantiated. UI id # 3 2019-08-24T05:13:24.704560Z
BASIL - new OtherView instantiated. 2019-08-24T05:13:24.705400Z
BASIL - new UI instantiated. UI id # 4 2019-08-24T05:13:25.242077Z
BASIL - new OtherView instantiated. 2019-08-24T05:13:25.630358Z
Besides the multiple UI
instances, another problem is how the MainView
that we are leaving gets reinstantiated while routing to /other
(OtherView
).