Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

getViewport() returns corrupted data when viewport spans multiple pages

Aperta
#139 2 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@ThomasK33 ci sta già lavorando.

Dal 26/6/2026.

  • #177 di @ThomasK33 — aperta

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

accepted bug triage:done
Description

renderStateGetViewport in the WASM build resolves the viewport top-left position independently for each row using pages.pin(.active). When the viewport spans multiple internal pages, this per-row resolution can produce inconsistent results, leading to corrupted viewport data.

Additionally, scrollbackLimit is passed as a line count but Terminal.init() interprets max_scrollback as bytes, causing the scrollback buffer to be much smaller than intended and making the page-spanning condition occur more frequently.

Symptoms
  • getScrollbackLength() drops unexpectedly (e.g., 498 → 269) after repeated writes
  • getViewport() returns rows with content from different terminal lines merged together
  • Both getViewport() and getLine() return the same wrong data
  • Corruption frequency depends on column width:
    • cols=80: OK
    • cols=120: CORRUPT
    • cols=130: CORRUPT
    • cols=140: OK
    • cols=160: scrollback drops but viewport may appear OK (merge lands on empty rows)
Root cause

The native Ghostty renderer reads cell data from cached row pins in RenderState.row_data (built during update()), which guarantees consistent page resolution across all viewport rows. The WASM renderStateGetViewport instead calls pages.pin(.active) per-row, which can resolve to different pages inconsistently when the viewport straddles a page boundary.

Reproduction
  1. Create a terminal at cols=130, rows=39, scrollback=10000
  2. Repeatedly write ~68 lines of escape-heavy output (SGR 256-color, truecolor, attributes)
  3. After ~8 repetitions, call getScrollbackLength() and getViewport()
  4. Scrollback length will drop and/or viewport rows will contain merged content
Expected behavior

getViewport() should return consistent, correct row data regardless of internal page layout. scrollbackLimit should be interpreted consistently between the JS config and WASM init.

Fix

Draft PR with fix and regression tests: #133

Lingua principale
TypeScript
Stelle
2.9k
Fork
182
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di coder/ghostty-web

Tutte le issue di coder/ghostty-web

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.