Open hl662 opened 1 month ago
Long term we should still look into switching over to the visibility APIs for cleanup:
beforeunload
- depending on what is done in the handler we might lose user/app state https://www.igvita.com/2015/11/20/dont-lose-user-and-app-state-use-page-visibility/
When the window.location.href of the viewer tab is modified, but the link is not a valid one, we still see the viewport context disappear, because IModelApp.shutdown() is called
beforeunload
(i.e regardless of whether a user is redirected, or a tab is closed, or not). Changed the event listener to be aunload
event, but this is not intended to be the long-term solution, because it is deprecatedI explored using the
visibilitychanged
event, but the problem with that is IModelApp will be shutdown when a user switches to a different tab. Checking thewindow.visiblityState
and whether it isvisible
orhidden
is the way to do it, but browsers aren't able to differentiate whether ahidden
visibilityState is from the browser closing/refreshing a tab or because it is switched. So in conclusion, there is no good long term solution right now...