brainpm / bpm-webplayer

display interactive content bundled by brainpm (bpm) in a web browser
0 stars 0 forks source link

garbage-collect old episodes #39

Open regular opened 9 years ago

regular commented 9 years ago

The prevent browsers from becoming unresponsive when there is a large number of episodes in the dom that display complex, interactive content, we need to be able to temporarily replacecurrently unseen episodes with a placeholder.

If an episode's bottom border is far enough from the top border of the viewport, we can assume that it will not come into view for some time. We then replace it with a placeholder of the same dimensions (to prevent the content below from jumping).

The placeholder contains a spinner.

When it comes into view, we simply re-load the episode and it will de-serialize it's state just like during app startup.

On app startup, instead of loading episodes, we put their placeholders into the dom. This will prevent old episodes from being loaded at all. This requires to maintain a database of episode heights. Note: the dimensions are not constant, an episode can grow and shrink in size. It is probably save to assume that the size only changes in response to a change in state of the respective episode, thus we can update the heightdb whenever the episode serializes it's state.