Skip to content

perf(erd): hover rebuilds and repaints the whole canvas; no viewport culling; first layout on the UI thread #1169

Description

@ZhuchkaTriplesix

Problem

  • Hover rebuilds the whole canvas. onHover calls setState on ErdView: every _TableCard (≈ 3 000 text rows for 200 tables × 15 columns) is rebuilt and every edge repainted; roundedPath is rebuilt for each route on every paint.
  • _isFocused scans all relations for each card: O(tables × relations) per build.
  • One RepaintBoundary around the whole canvas: any change repaints all cards and edges.
  • No viewport culling: InteractiveViewer(constrained: false) builds and lays out every card, also the ones off screen.
  • First layout and routing run on the UI thread inside _load (ErdLayout.compute + ErdRouter.route), a hitch when the Diagram tab opens on a large schema.

Scope

  • Hover / drag / selection state in ValueNotifiers; cards listen only to whether they are highlighted.
  • RepaintBoundary per card; edges in two painters (base layer, highlighted layer); Paths cached when routes change.
  • Adjacency map computed once per schema.
  • Build only cards intersecting the viewport (+ margin) via InteractiveViewer.builder.
  • ErdLayout.compute + first route() in Isolate.run (schema and offsets are plain data), spinner until done.
  • ERD scenario in benchmark/app_perf_bench.dart: open / hover / drag on a generated 200-table schema.

Acceptance

  • Hover over a card rebuilds only the affected cards (widget test counting builds).
  • Benchmark: hover and drag frames within the 120 Hz budget on 200 tables; opening the diagram has no frame over 16 ms on the UI thread.

Activity

  1. added
    frontendTheme parser epic label: frontend
    performanceTheme parser epic label: performance
    P2Medium priority / Parity & Refactoring
    on Oct 8, 2026
  2. added a commit that references this issue on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority / Parity & RefactoringfrontendTheme parser epic label: frontendperformanceTheme parser epic label: performance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions