BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Flutter 2.8 and Dart 2.15 Focus on Performance Improvement

Flutter 2.8 and Dart 2.15 Focus on Performance Improvement

This item in japanese

Flutter 2.8 focuses on improving app startup time, reducing memory footprint, and making it easier for developers to profile performance issues. Along with it, Google has announced a new Dart version, Dart 2.15, improving worker isolates, introducing constructor tear-off, and extending enums.

To reduce app startup latency, Flutter 2.8 addresses a few shortcomings in the Dart VM garbage collector, reduces serialization while creating platform views, and enables concurrent initialization of the font manager. These changes may bring a significant performance improvements especially on low-end devices, says the Flutter team.

All together these improvements have resulted in reduction in startup latency for Google Pay of 50% when running on a low-end Android device, and a 10% improvement on high-end devices.

Another area where Flutter apps were struggling with on low-end devices was memory. To reduce memory consumption, the Dart VM's service isolate has now its own bundle, which makes it possible to postpone its loading and reduce the initial memory footprint. An additional 10% reduction in memory occupation is achieved by more accurately informing the OS about which pages in memory can be reclaimed.

To make it easier for developers to inspect the performance of their apps, Flutter 2.8 now sends tracing events to Android systrace, which means they can be visualized along with the rest of Android native tracing events. Likewise, the new DevTools coming with Flutter 2.8 include a new Enhance tracing feature to extend the set of traced events when building widgets, laying out objects, and painting them.

Moving to Dart, its latest release improves isolates, which are concurrency units, roughly similar to message-passing threads. Isolates can now be created in groups so they share some internal structures. This makes adding a new isolate to an existing group faster and cheaper in terms of memory occupation. Furthermore, isolates within the same group can share objects instead of passing them along using messages. Besides this, message passing is now up to 8 times faster for small to medium sized messages and supports passing function types, closures, and stacktraces.

A new language-level feature in Dart 2.15 is constructor tear-offs, that is, pointers to constructors which can be referred by appending .new to the corresponding class name, e.g. Text.new. Previously, Dart only supported function tear-offs, thus preventing, for example, to pass the constructor for a UI object to a function.

As a last note about new Dart feature, it is worth mentioning the enum APIs from dart:core have been extended to get the String value of a given enum, look-up an enum value by name, and get a map of all name-value pairs in an enum:

enum MyEnum {
  one, two, three
}
void main() {
  print(MyEnum.one.name);  // Prints "one".
  print(MyEnum.values.byName('two') == MyEnum.two);  // Prints "true".
  final map = MyEnum.values.asNameMap(); 
  print(map['three'] == MyEnum.three);  // Prints "true".
}

Both Flutter 2.8 and Dart 2.15 include much more than can be covered here, so make sure you do not miss the official announcement for the full details.

Rate this Article

Adoption
Style

BT