SyntaxColoring / log-viewer

View systemd-journald logs in the browser. A very messy work in progress.

Home Page:https://log-viewer.pages.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Investigate whether janky scrolling can be avoided with elements that resize

SyntaxColoring opened this issue · comments

We're currently eagerly buffering all entries into memory so that, when they come into view, we can render them immediately without an await I/O call. This is all to avoid janky behavior with our virtualized scrolling library.

log-viewer/src/LogView.tsx

Lines 118 to 122 in 59915ef

// Ideally, this call to get entry data would be async, and we would initially show a loading
// placeholder. That would let logIndex avoid having to buffer all the data in memory up-front.
// Unfortunately, React Virtuoso has a lot of trouble with elements changing height as you
// scroll upward. So this needs to be instant to avoid things jumping around.
const rowData = logIndex.getEntry(index);

This is really unfortunate because it consumes a lot of memory.

Open questions:

  • Is there a way to tune our current library (React Virtuoso) to handle this case better?
  • Is there another library that handles this case better?

If the answers to these questions are both "no," we still have other options. Like:

  • Mitigate memory consumption by buffering only the messages, not the timestamp or other metadata.
  • Add a "low-memory mode" where line wrapping is disabled. Then, we would precompute the height of each entry by counting the number of \n characters in the message.