Skip to content

Benchmark findings

Current observations:

  • around ~2k objects: smooth
  • around 100k visible rectangles: not smooth

Likely bottlenecks:

  • drawing every rect every frame
  • per-rect transform math every frame
  • per-rect Rect allocation every frame
  • repainting more UI than just the canvas subtree

Best likely wins for the later performance pass:

  1. add viewport culling
  2. switch to canvas-level translate/scale
  3. precompute world-space Rects after load
  4. keep repaint scope small
  5. disable antialiasing for plain axis-aligned rects

What to measure after each change:

  • static frame time
  • pan smoothness
  • zoom smoothness
  • behavior when fully zoomed out
  • visible object count

Important note:

At 100k visible rects, immediate-mode drawing may still struggle depending on platform and zoom level. The main performance goal is to reduce draw count, per-frame CPU math, and per-frame allocations.

Tip

lib/features/benchmark/benchmark_painter.dart:22 Even with BenchRenderObject.rect precomputed, paint() still allocates a new Rect for every object on every frame (and repeats per-object transform math). If the goal of introducing render data is to reduce per-frame CPU/allocations, consider applying canvas.translate(pan.dx, pan.dy) + canvas.scale(zoom) once and then drawing the precomputed world-space rects directly

Comparison

3a289fd

img.png

Raster max 14.1ms/frame, avg 8.2 ms/frame UI max 47.4ms/frame, avg 22.4ms/frame