Flash of contents
faassen opened this issue · 0 comments
When a webxdc instance is opened on a port, there is sometimes a flash of contents. This happens to clear the local state (localstorage
, etc) of the previous instance so we start with a fresh slate, and then the application is reloaded. After this, the setUpdateListener
is registered for serial 0 and the state is loaded anew.
How to avoid this flash of content? The trouble is that we don't know whether clear
is going to come in. A normal reload shouldn't wipe local state, only the initial opening does.
I considered turning off the UI (by setting document.style.display = 'none'
) in the window.load
event but:
-
this may already be too late to prevent a flash of content
-
we want to reenable the display sometime, and when to do that? We can't wait for an update or clear, as it may not arrive.
I considered loading a custom index.html
initially when you open a tab, and then clearing contents if a clear event comes from the server, and buffering any other updates somehow, and then reloading to the real index.html
and piping in all the buffered updates. But this seems very tricky to get right.
Perhaps the simplest approach would be some kind of setTimeout, but again the reload makes things difficult...