title: Flutter performance plotting one pixel on a canvas over a camera feed
body: <p>I've got a live camera preview and a canvas on top, using Stack, the canvas is so I can paint something.</p>
  <p>Something like..</p>
  <pre><code>guesture detector
    custom painter
      foreground painter: the HUD canvas widget
         fitted box
            camera preview runnung
  </code></pre>
  <p>When I stop the code at the canvas painting function, the stack is 80 levels deep.</p>
  <pre><code>MetaHud.paint ** my function to paint one pixel is here **
  RenderCustomPaint._paintWithPainter (/Users/justin/flutter/packages/flutter/lib/src/rendering/custom_paint.dart:563)
  RenderCustomPaint.paint (/Users/justin/flutter/packages/flutter/lib/src/rendering/custom_paint.dart:610)
  RenderObject._paintWithContext (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:2409)
  PaintingContext.paintChild (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:189)
  RenderProxyBoxMixin.paint (/Users/justin/flutter/packages/flutter/lib/src/rendering/proxy_box.dart:140)
  RenderObject._paintWithContext (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:2409)
  PaintingContext.paintChild (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:189)
  RenderProxyBoxMixin.paint (/Users/justin/flutter/packages/flutter/lib/src/rendering/proxy_box.dart:140)
  RenderObject._paintWithContext (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:2409)
  PaintingContext.paintChild (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:189)
  RenderProxyBoxMixin.paint (/Users/justin/flutter/packages/flutter/lib/src/rendering/proxy_box.dart:140)
  RenderObject._paintWithContext (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:2409)
  PaintingContext.paintChild (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:189)
  RenderShiftedBox.paint (/Users/justin/flutter/packages/flutter/lib/src/rendering/shifted_box.dart:79)
  RenderObject._paintWithContext (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:2409)
  PaintingContext.paintChild (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:189)
  RenderBoxContainerDefaultsMixin.defaultPaint (/Users/justin/flutter/packages/flutter/lib/src/rendering/box.dart:2794)
  RenderFlex.paint (/Users/justin/flutter/packages/flutter/lib/src/rendering/flex.dart:1078)
  RenderObject._paintWithContext (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:2409)
  PaintingContext.paintChild (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:189)
  RenderBoxContainerDefaultsMixin.defaultPaint (/Users/justin/flutter/packages/flutter/lib/src/rendering/box.dart:2794)
  RenderStack.paintStack (/Users/justin/flutter/packages/flutter/lib/src/rendering/stack.dart:629)
  RenderStack.paint (/Users/justin/flutter/packages/flutter/lib/src/rendering/stack.dart:645)
  RenderObject._paintWithContext (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:2409)
  PaintingContext.paintChild (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:189)
  RenderShiftedBox.paint (/Users/justin/flutter/packages/flutter/lib/src/rendering/shifted_box.dart:79)
  RenderObject._paintWithContext (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:2409)
  PaintingContext.paintChild (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:189)
  RenderShiftedBox.paint (/Users/justin/flutter/packages/flutter/lib/src/rendering/shifted_box.dart:79)
  RenderObject._paintWithContext (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:2409)
  PaintingContext.paintChild (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:189)
  RenderBoxContainerDefaultsMixin.defaultPaint (/Users/justin/flutter/packages/flutter/lib/src/rendering/box.dart:2794)
  RenderCustomMultiChildLayoutBox.paint (/Users/justin/flutter/packages/flutter/lib/src/rendering/custom_layout.dart:409)
  RenderObject._paintWithContext (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:2409)
  PaintingContext.paintChild (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:189)
  RenderProxyBoxMixin.paint (/Users/justin/flutter/packages/flutter/lib/src/rendering/proxy_box.dart:140)
  _RenderInkFeatures.paint (/Users/justin/flutter/packages/flutter/lib/src/material/material.dart:553)
  RenderObject._paintWithContext (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:2409)
  PaintingContext.paintChild (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:189)
  RenderProxyBoxMixin.paint (/Users/justin/flutter/packages/flutter/lib/src/rendering/proxy_box.dart:140)
  PaintingContext.pushLayer (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:398)
  RenderPhysicalModel.paint (/Users/justin/flutter/packages/flutter/lib/src/rendering/proxy_box.dart:1941)
  RenderObject._paintWithContext (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:2409)
  PaintingContext.paintChild (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:189)
  RenderProxyBoxMixin.paint (/Users/justin/flutter/packages/flutter/lib/src/rendering/proxy_box.dart:140)
  RenderObject._paintWithContext (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:2409)
  PaintingContext._repaintCompositedChild (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:141)
  PaintingContext.repaintCompositedChild (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:100)
  PipelineOwner.flushPaint (/Users/justin/flutter/packages/flutter/lib/src/rendering/object.dart:979)
  RendererBinding.drawFrame (/Users/justin/flutter/packages/flutter/lib/src/rendering/binding.dart:455)
  WidgetsBinding.drawFrame (/Users/justin/flutter/packages/flutter/lib/src/widgets/binding.dart:883)
  RendererBinding._handlePersistentFrameCallback (/Users/justin/flutter/packages/flutter/lib/src/rendering/binding.dart:319)
  SchedulerBinding._invokeFrameCallback (/Users/justin/flutter/packages/flutter/lib/src/scheduler/binding.dart:1143)
  SchedulerBinding.handleDrawFrame (/Users/justin/flutter/packages/flutter/lib/src/scheduler/binding.dart:1080)
  SchedulerBinding._handleDrawFrame (/Users/justin/flutter/packages/flutter/lib/src/scheduler/binding.dart:996)
  _rootRun (dart:async/zone.dart:1428)
  _CustomZone.run (dart:async/zone.dart:1328)
  _CustomZone.runGuarded (dart:async/zone.dart:1236)
  _invoke (dart:ui/hooks.dart:166)
  PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:270)
  _drawFrame (dart:ui/hooks.dart:129)
  </code></pre>
  <p>This means flutter takes 50% of one whole phone cpu to really do nothing except getting to the bottom to find my painting function 60 times a second.</p>
  <p>Is there a more efficient way to do this? Can I insert a callback, then mark up and blit a canvas over the camera feed?</p>