[Fractal-gh] Render off the main thread (Web Worker/progressive) to stop UI freezes

Aperta
#392 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript

Direzione di ricerca

Start with Mandlebrot/Fractal-gh/app/fractal.js:213-242 and Mandlebrot/Fractal-gh/app/app.js:246-279; the issue reports a synchronous pixel loop and timeout workarounds. First compare the current renderer's output and responsiveness against the supplied 2880x1800@1792 benchmark. Done means rendering stays responsive, rapid clicks cancel stale renders, and the default view remains pixel-identical; the proposed worker, progressive rendering, and optional WebGL paths make this substantial design work.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area: mandelbrot priority: P3 size: M type: performance

Summary

drawToImageData computes every pixel synchronously on the main thread. On a retina-size canvas the page freezes for seconds, which is why app.js needs several setTimeout "hack workarounds" to show the loading overlay and swallow clicks.

Location

  • Mandlebrot/Fractal-gh/app/fractal.js:213-242
  • Mandlebrot/Fractal-gh/app/app.js:246-279 (timeout workarounds)

Evidence

Headless Chromium, new Fractal(canvas).update({pxWidth:2880, pxHeight:1800, maxEscapeTime:m}):

"2880x1800@224":  "705 ms (main thread blocked)"
"2880x1800@1792": "3810 ms (main thread blocked)"

(Replacing the Math.sqrt escape test with x*x+y*y < 4 changed 3810 ms to 3756 ms, so the cost is the blocking loop, not sqrt.)

Expected

The UI stays responsive during rendering and a render can be cancelled when the user clicks again.

Proposed fix

  1. Move calcEscapeTime/rgbNum into a Web Worker that renders row bands into transferable ImageData buffers; split across navigator.hardwareConcurrency workers.
  2. Show progressive results (coarse pass, then refine) and cancel stale jobs on new input.
  3. Remove the setTimeout workarounds once rendering is asynchronous.
  4. Optional: a WebGL fragment-shader path for instant redraws at low iteration counts.

Acceptance criteria

  • Main thread never blocks for more than 50 ms during a 2880x1800@1792 render
  • Rapid successive clicks render only the final view
  • Output is pixel-identical to the current renderer for the default view

Repository audit, November 2026 · Phase 9 · New features · evidence: reproduced · ref fractals-equations-006


Generated by Claude Code

Lingua principale
C++
Stelle
2
Fork
1
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

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 ibra-kdbra/Math-Problems

Tutte le issue di ibra-kdbra/Math-Problems

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.