Flutter Engine

Cards (12)

  • Flutter's engine takes core technologies, Skia, a 2D graphics rendering library, and Dart, a VM for a garbage-collected object-oriented language, and hosts them in a shell.
  • Flutter Embedders are components that integrate the Flutter engine into a host platform.
  • The Dart VM implements the normal Dart core libraries, plus an additional library called dart:ui to provide low-level access to Skia features and the shell.
  • The Flutter engine does not create or manage its own threads. Instead, it is the responsibility of the embedder.
  • The Dart VM also has its own thread pool. Neither the Flutter engine or the embedder have any access to it.
  • The Flutter engine requires the embedder to give it references to 4 task runners.
    • Platform Task Runner
    • UI Task Runner
    • Raster Task Runner
    • IO Task Runner
  • Platform Task Runner is the task runner for the thread the embedder considers as its main thread. If plugins manage their own worker threads, it is their responsibility to queue responses back onto the platform thread before they can be submitted back to the engine for processing by Dart code.
  • The UI task runner is where the engine executes all Dart code for the root isolate.
  • The Raster Task Runner is a dedicated thread responsible for the critical task of preparing graphics commands for rendering on the screen.
  • The main function of the IO task runner is reading compressed images from an asset store and making sure these images are ready for rendering on the raster task runner.
  • Flutter’s engine runtime and your application’s compiled Dart code are both bundled as shared libraries on Android and iOS.
    The first step of loading Flutter is to find those resources in your .apk/.ipa/.app etc.
    After it’s found, the engine’s shared libraries are memory loaded once per process.
  • When you run your Flutter app, the platform (e.g., Android, iOS) creates a FlutterEngine instance. This involves setting up memorythreads, and resources needed for running the app.
    Your main function is executed within the newly created UI thread. This function typically calls runApp with your app's Widget root, the starting point of your UI tree.