lit / lit/lit

[labs/virtualizer] Add permanent, toggleable lifecycle logging

Open
#5,282 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
21.8k
Forks
1.1k
Avg merge
18h 25m
Merged PRs (30d)
2

Description

### Description

Add permanent diagnostic logging to the virtualizer's key lifecycle points, controlled by a runtime or build-time toggle. The logging should cover the full update pipeline and be filterable by subsystem.

### Motivation

During debugging of #4693 and #5006, lifecycle logging at specific points in the virtualizer pipeline was essential for understanding scroll behavior, position estimation, freeze/unfreeze cycles, and DOM update timing. Currently this logging must be manually added and removed each session.

### Logging points

The following lifecycle points should be instrumented:

**Virtualizer.ts:**
- `_updateDOM` — range, child positions, scroll error, scrollTop
- `_finishDOMUpdate` — positions flushed to DOM with first/last item positions
- `_handleScrollEvent` — freeze detection (delta, threshold)
- `_unfreezeScroll` — freeze release with scrollTop

**FlowLayout (flow.ts):**
- `_updateLayout` — cross-axis dimension changes, cache clearing
- `_updateVirtualizerSize` — scroll correction firing (size ratio, scroll position scaling)

### Requirements

- Zero cost in production builds (depends on #5281)
- Togglable at runtime for development builds
- Compact, single-line format with `[virt:xxx]` prefix for console filtering
- Key metrics (range, positions, scrollTop, scrollError) in every relevant log

### Depends on

- #5281 (build support for dev-only code blocks)

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the dev-only build support in #5281, then inspect the lifecycle methods listed in Virtualizer.ts and flow.ts. Trace the update pipeline and identify how runtime toggling and subsystem filtering should work. Done means development builds provide compact [virt:xxx] logs at all specified points while production builds incur zero cost.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.