New UI instance is created when browsing history on Chrome

In my application I have an UI annotated with
@PreserveOnRefresh
. I also use a
Navigator
class to navigate to different views of the application. As the navigator listens for the URI fragment change events, I’m able to write an address of a page directly in the address bar and hit and the desired page is being displayed.

Let’s say that I have been for a while on a Website (with Chrome) and have the following URLs in my browser history:

When I now type a http://localhost/app/#! in the address bar, Chrome displays the rest of the pages, I have visited (home, contact, page). When I hit the down arrow, Chrome automatically loads preview of the page I have pointed. This is the moment, when the URI fragments stop working. I can move between pages with buttons, pages change but the URI fragment stays untact. Also, when I change the URI fragment in address bar, nothing happens.

I investigate this problem for a while and I managed to find, that during the “from Chrome history preview request” the method
com.vaadin.server.AbstractCommunicationManager#getBrowserDetailsUI()
does not recognise the request as known UI that should be retained and calls the UI provider to create a new one. Therefore, application gets a fresh instance of an UI, but the previously registered URI Fragment Change listeners refers to another instance. I compared in the page attribute of navigator’s listener with a
UI.getCurrent().getPage()
and indeed - after this strange Chrome request they are different.

This may happen due to the missing
v-wn
parameter in this request from Chrome. I don’t want to create a new ticket for this until some Vaadin-expert looks into that.

I am still having the same issue too using Vaadin 7.6.8