Module profile
Expand description
Lightweight instrumentation for the WebView pipeline. Off by default;
enabled by setting TILO_WEBVIEW_PROFILE in the environment.
What it measures, from the engine thread and the widget:
- frame throughput — inter-frame intervals → frames/sec,
- input→next-frame interval — time from an interactive command being sent to the next observed engine frame. This is uncorrelated: the frame may belong to another tab or unrelated animation, and arrival does not prove that the window displayed it,
- SHM swizzle cost — the per-frame BGRA→RGBA copy time,
- geometry — each frame’s pixel size and each draw’s rect, so a size/rect mismatch (a stretched or mispositioned frame) is visible.
A summary prints to stderr every SUMMARY_EVERY frames and once
more when the process exits. With TILO_WEBVIEW_PROFILE=trace the
first TRACE_FRAMES frames and draws are logged individually — the
fast path to diagnosing a visual glitch.
All timing uses crate::time::Instant; the whole module is a no-op
(one relaxed atomic load) when disabled.
Functions§
- enabled
- Read the env once and latch the on/off + trace flags. Called from every hook; the first call resolves it, the rest are a relaxed load.
- record_
draw frame_dimsisNonefor a placeholder (no frame yet). A rect whose aspect ratio diverges from the frame’s, or a placeholder appearing after real frames, points at a layout/caching glitch.- record_
frame - Record a frame the engine just produced: its pixel dimensions and the time spent converting it (SHM BGRA → RGBA).
- record_
input kindis a short static label ("scroll","mouse","key"). Only the first input after a paint opens a latency window, so a burst reports the leading edge’s latency to its first repaint.- record_
resize - Record physical resize commands so startup traces can distinguish a stale frame from a missing or downgraded device-scale request.