[Feature Request]: Improve the rendering files speed, on web interface and application for AFFiNE
Description
When editing large documents in AFFiNE, the typing experience becomes very slow. Even adding or deleting a single character causes visible lag: sometimes several seconds making it very difficult to type or edit smoothly.
What counts as a “large” file
Files that include:
- More than 2,000 characters (for example: long notes, articles, or documentation)
- Multiple code blocks, images, or mixed block types
- Heavy layout structures with nested blocks
Such files are particularly slow to open, scroll, and most importantly edit.
Current Behavior
-
When typing a single character, the entire document is re-rendered instead of only the modified block.
-
This triggers:
- Typing delay / input lag
- High CPU/GPU usage
- UI freezes (especially on the web interface)
-
The issue is reproducible both online and offline, and worsens with document size.
Example symptom:
=> Typing in a long note (with code blocks and images) introduces ~1–2 seconds of delay after each keystroke.
This makes AFFiNE nearly unusable for writing or editing technical content.
https://github.com/user-attachments/assets/19ca3a9c-cb1d-475e-9e78-ecc6d7d6cffe
Proposed Solution
Implement incremental or viewport-based rendering, so only relevant or visible parts of the document are updated.
Possible improvements:
Biggest improvement effect :
- Incremental re-rendering - update only the affected nodes when editing.
- Viewport-based rendering - render only blocks visible in the user’s viewport (lazy-load the rest). (Explain here #13616 )
Some interesting improvement (for future) 3. Memoization and caching - logic to skip unnecessary DOM updates. 5. Block-level change detection - isolate text editing operations from full layout recalculations.
Use case
A user opens a long Markdown or note document containing:
- Several paragraphs (2K+ characters)
- A few embedded code blocks and screenshots
When typing a single letter:
- The full document re-renders
- CPU spikes for ~2 seconds
- Input lags and the cursor freezes momentarily
This destroys typing flow and productivity, especially for users writing long technical content.
Expected Outcome
- Small typing latency, even for long and complex documents
- Smooth scrolling and editing in all modes (web & desktop)
- No UI freeze when inserting or modifying text
- Faster overall document load time
Anything else?
No response
Are you willing to submit a PR?
- [ ] Yes I'd like to help by submitting a PR!
Issue Status: 🆕 *Untriaged
*🆕 Untriaged
The team has not yet reviewed the issue. We usually do it within one business day. Docs: https://github.com/toeverything/AFFiNE/blob/canary/docs/issue-triaging.md
This is an automatic reply by the bot.