CefriumBrowserPool

A bounded LRU pool of CefriumViewState for screens that show many different pages over time -- e.g. a list of lessons/articles, each rendered in a CefriumView.

Why this exists: a Cefrium browser is HEAVY (a full Chromium renderer process, tens-to-hundreds of MB -- far more than a WebView). Keeping one alive per item you ever opened grows memory without bound. This pool keeps at most maxAlive browsers alive and CLOSES the least-recently-used one when you open another, so memory stays bounded while the most recent N keep their state (scroll, video position) for instant return.

For the simplest case -- showing one page at a time -- you do NOT need a pool: reuse a single CefriumView and swap content with navigator.loadUrl(...) / loadHtmlWithBaseUrl(...). Use a pool only when you want the last few pages to stay warm.

val pool = rememberCefriumBrowserPool(maxAlive = 2)
val state = pool.stateFor(lesson.id, lesson.url) // reuses or creates
CefriumView(state = state, navigator = navigator)
// Opening a 3rd lesson closes the least-recently-used browser automatically.

The pool owns its states: when it leaves composition every pooled browser is closed. Do NOT also wrap a pooled state in rememberCefriumViewState (that would double-own it).

Properties

Link copied to clipboard
val size: Int

Number of states currently held alive by the pool.

Functions

Link copied to clipboard
fun evict(key: String)

Closes and evicts the state for key (no-op if not pooled).

Link copied to clipboard
open override fun onAbandoned()
Link copied to clipboard
open override fun onForgotten()
Link copied to clipboard
open override fun onRemembered()
Link copied to clipboard

Returns the pooled state for key, creating one that loads url on first use. Touching a key makes it most-recently-used; opening a new key beyond maxAlive closes and evicts the least-recently-used state. url is used only when the state is first created for key.