Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Skyrocket your performance with background tasks

Skyrocket your performance with background tasks

My talk at Flutter Day India 2020 - Isolates - Background Tasks with Workmanager

Myracle

June 27, 2020
Tweet

Other Decks in Programming

Transcript

  1. About Me u Founder of FlutterExplained u Software Engineer u

    Consultant u Trainer u Public Speaker @flutter_exp FlutterExplained
  2. Intro into Background Tasks u Long Running Tasks besides of

    Flutter u Your app is currently not active but performs tasks u Two different “background” states u Background State u “Destroyed” State
  3. Isolates u Isolate is a contained instance of Dart u

    It has its own uEvent Loop uMemory
  4. Helper: compute Function u Compute is a helper function u

    Creates an Isolate and runs in background u Less boilerplate u Returns a value u Limited Functionality
  5. Isolates work fine… For apps that are in background Performs

    heavy calculation tasks Allow Multi thread in Dart Speed up your applications! but… Stops when FlutterActivity is destroyed
  6. App suspended, what now? u Plugins to the rescue u

    Native Device Code starts up Flutter Engine u Runs our Dart Code u Downsides u Super code heavy u Native Code u No / Few Documentation
  7. Background Behavior Android u AlarmManager u JobService u Firebase Job

    Dispatcher u WorkManager iOS u Minimum background fetch interval u iOS could decide never execute our code
  8. Workmanager Package u Facilitates the u Android WorkManager u iOS

    performFetchWithCompletionHandler u Reduces installation effort to a minimum u No Native Code in Kotlin or Swift
  9. Conclusion u Isolates u improve your apps performance u Careful

    with “overengineering” u Background Tasks u iOS and Android have different approaches u Both are not perfectly flexible u Recommendation to use a package