Flutter performance updates in the first half of 2020
By Yuqian Li and Shams Zakhour
Being fast is a key pillar to Flutter. This article highlights performance improvements from the first half of 2020 implemented by folks from the Flutter community.
If you’ve helped out with performance after June 2020, we will cover that in a future post. We hope that sharing this with you, the Flutter community, inspires you to help us with this effort!
Quantified improvements
[app size] 18.5% reduction in Flutter Gallery app size
contributors: alexmarkov, sstrickl, mkustermann, askeksa-google, rmacnak-google, mraleph, crelier
- Commit f56b0f, a2bb73, d77f49, e2faac, 8e7ffa, 76c628, 4ab9c7, 1c2d37, 27e64c, 6a7e4e, 054929
- 18.5% reduction (9.6MB to 8.1MB) the Flutter Gallery sample for Android
[app size] 100KB size reduction for Gallery app by font subsetting
contributors: dnfield, jonahwilliams, zanderso, jmagman, blasten
- PR #14828, #49737, #49842, #50224, #51808
- 100kb size reduction in Flutter Gallery app
- Fixed “Tree shake material icons #16311”, “Build hb-subset as part of engine builds and upload to cloud storage #43642”, “Consume font-subset in flutter_tools and treeshake icon fonts #43644”, “Wire up font subsetting for all platforms #49730”
[speed, memory] 9x speedup and 99+% memory reduction on dart2js tools
contributors: rmacnak-google, a-siva
- Commit 5b8c4e
- 9x speedup (46 to 5s) and 99+% memory reduction (537 to 1.5MB) on dart2js self compile, 1.5GB heap, 400MB heap snapshot
[speed] Up to 50% speedup for iOS average render speed by moving from OpenGL to Metal
contributors: chinmaygarde, dnfield, jason-simmons, cbracken, amirh, liyuqian
- PR #8936, #9383, #11070, #13056, #13367, #17080, #17162, #17154, #17431
- 50% speedup (6ms to 4ms) for flutter_gallery_ios__transition_perf average_frame_rasterizer_time_millis
- Fixed “Flutter should use Metal instead of OpenGL on iOS #18208”
[speed] 2–5x speedup for the worst frame raster time caused by shader compilations
contributors: liyuqian, jonahwilliams, chinmaygarde, iskakaushik, zanderso, sfshaza2, filiph, acoutts
- PR #17300, #53859, #17601, #17861, #58743, #56638, #4430, #12142
- 2.25x speedup (90ms to 40ms) for Android flutter_gallery__transition_perf worst_frame_rasterizer_time_millis
- 5x speedup (300ms to 60ms) for iOS flutter_gallery_ios32__transition_perf worst_frame_rasterizer_time_millis
- 3.75x speedup (229ms to 61ms) for some real apps.
- Fixed “SkSL-based shader warmup #53607”, “cubic bezier regression #35142”, and “saved” some customers.
[speed] 15.8x speedup for mouse hit testing
contributors: dkwingsmt, yjbanov, goderbauer, gspencergoog
- PR #59803 #59883
- 15.8x (79ms to 5ms) speedup for bench_mouse_region_grid_scroll frame duration (web).
- Fixed “Poor performance when subscribing to MouseRegion events #41194”
[speed] 13.9x speedup for platform message response handling
contributors: zljj0818, jason-simmons, liyuqian
- PR #18838, #18945, both of which are inspired by #18808
- Fixed “Image.asset will block UI thread when load large image #58572”
- 13.9x (9164us to 660us) speedup in PlatformMessageResponseDartComplete
[speed] 20%-37% speedup for frame build time with opaque routes
contributors: goderbauer, dnfield
- PR #48900
- 20% (7.38ms to 6.13ms) speedup in flutter_gallery_ios32__transition_perf average_frame_build_time_millis
- 37% (50.45ms to 36.63ms) speedup in flutter_gallery_ios32__transition_perf 99th_percentile_frame_build_time_millis
- Fixed “Optimize unneeded rebuild when pushing overlay/navigator opaque content #45797”
[speed] 4.8x speedup for blur using ImageFiltered instead of BackdropFilter
contributors: flar, hixie, yjbanov, liyuqian
- PR #14491, #47489, #58277,
- 4.8x speedup (29ms/frame to 6ms/frame) for a demo app on Moto G4.
- Fixed “ImageFilter widget #13489”
[speed] Up to 14x speedup when scrolling large static content with Flutter web
contributors: yjbanov, ferhatb
- PR #17621
- 14.01x speedup (463.74ms to 33.10ms) for text_canvas_cached_layout.html.layout.average
- Fixed “Jank when scrolling large static content with Flutter Web #42987” and “Drawing text outside canvas’ bounds is expensive on the Web #48516”
[speed] 6.8x speedup for Flutter engine shell initialization
contributors: scutlight, jason-simmons, gaaclarke, liyuqian
- PR #18225
- 6.8x speedup (18.3ms to 2.7ms) for BM_ShellInitialization
[speed] 5x speedup by skipping calling builder when constraints are the same
- PR #55414
- 5x speedup (~10FPS to ~50FPS) on scrolling the contacts list with the Flokk customer app.
- Fixed “LayoutBuilder should cache constraints and not rebuild if unchanged #6469”
[speed] 2x speedup for shadows and animation on web
contributors: ferhatb, mdebbar, yjbanov
- PR #17864, #17866, #17867
- 2x speedup (30fps to 60fps) for a sample web app.
- Fixes “Web: Poor performance when using Shadows + Animation #54507”
[speed] 3X speedup in web Flutter Gallery start-up
contributors: ferhatb, clocksmith, rami-a
- PR #109, #183
- 3X speedup (6077ms to 2039ms) in web Flutter Gallery start-up
[speed] 2.8x speedup for average frame rasterizer time by enabling raster cache in Fuchsia
contributors: dreveman, liyuqian, chinmaygarde, arbreng
- PR #17753
- 2.8x speedup (~10ms to ~3.5ms) for frame_rasterizer_times_avg
- Fixed “Poor performance on Fuchsia due to raster cache being disabled #54950”
[speed] 1.85x speedup in 90th percentile frame build time by excluding invisible animated images
contributors: dnfield, liyuqian, tvolkert, digiter
- PR #50851, #50842
- 1.85x speedup (3.148 ms to 1.699 ms) for animated_placeholder_perf 90th percentile frame build time
- Fixed “flutter gives low frame rates when long lists with list builder inside cards giving(avg 20–35fps) #35592”
[speed] 2x speedup for Google smart displays P10 FPS
contributors: chinmaygarde, dnicoara, cbracken, jason-simmons, asakhart, rdaum
- PR #15980
- 2x speedup (30fps to 60fps) by giving embedders a way to tune thread priority.
- Fixed issue 49551
[speed] 2.45x speedup for ImageFilterLayer by enhancing its child cache
- PR #17175, #54903, #58277
- 2.45x speedup (18.41 ms to 7.53 ms) for ImageFiltered Transform average_frame_rasterizer_time_millis
- Also fixed “Transition performance regressed slightly due to OpacityLayer raster cache miss #52864”
[speed] 15% speedup for very large dart2js compilation
contributors: rmacnak-google, a-siva
- Commit d67fbe
- 1.15x speedup (545 to 472 seconds) very large dart2js compile, 9% reduction (13.057 to 11.861 GB) in very large dart2js compile max heap capacity.
- Fixed “Growth policy misinformed by concurrent sweep #21364”
[speed] 1.8x speedup in AOT compilation time of a large app
contributors: alexmarkov, mraleph, sigurdm, cskau-g
- Commit 467c98
- 1.8x speedup (274s to 152s) in AOT compilation time of a large app ( — from-dill)
[speed] 5x-13x speedup on Dart RegExp matching in AOT mode
contributors: mraleph, rmacnak-google
- Commit 2c922b
- 5x speedup improvement on benchmark from issue 42366
- 13x speedup (17863744.009 us to 1301678.797 us) of RegExp(RunTime) benchmark on a Linux workstation
- Fixed “RegExp is very slow in AOT mode #42366”
[speed] Up to 5x speedup in Dart UTF8 decoding
contributors: askeksa-google, mkustermann, rakudrama
- Commit cf6f89, e35ca3, 78df4a, fa2fd4
- 5.02x speedup in X64JIT TwoByteString benchmark
- Fixed “Fast path Uint8List to _OneByteString conversion #41703”, “Write UTF-8 result directly to strings #41704”
[speed] 35–65% speedup in async/sync* functions
contributors: cskau-g, mkustermann, mraleph
- Commit e29407, fdca1f, 7ed169, ca94ad
- 35–65% speedup in Calls.IterableManualIterablePolymorphicManyYields across {dart,dart-aot}-{ia32,x64,armv7hf,armv8}
- Fixed “improve performance of sync* code on VM #37753”, “Evaluate use of IndirectGoto when generating sync-yield function in VM #37754”
[speed] Up to 31.82% reduction in time with unboxed parameters and fields
contributors: mkustermann, mkustermann
- Commit 9eb531, b95149, e076e7, 9eb531
- Up to 31.82% reduction in matrix_utils_transform_rect_affine iteration time.
- Fixed “Real unboxed fields in the Dart VM #40004”
[speed] 20–25% speedup on Dart Pointer<Int8,Int64,etc> loads/stores in AOT
contributors: dcharkes, mkustermann
- Commit 408123
- Speeds up Pointer<Int8,Int64,etc> loads/stores by 20–25% in AOT on x64.
- Helped “stores and loads should support unboxed indices (in AOT) #39432”
Other improvements
[app size, energy, memory, speed] Add A/B test mode to local devicelab runner
contributors: yjbanov, flar, ferhatb, christopherfujino, liyuqian
[app size] Fixed “iOS App Size in FAQ incorrect”
contributors: jmagman, xster, dnfield, sfshaza2
[app size] Enable the usage of — delete-tostring-package-uri in the flutter too
contributors: jonahwilliams, dnfield
[energy, memory] Timeline summary now includes CPU/GPU/memory for iOS
contributors: iskakaushik, gaaclarke, albertwang0116, liyuqian, chinmaygarde, gw280
[memory] ImageCache flushes itself when told about memory pressure
contributors: dnfield, goderbauer, chunhtai
[memory] Fixed “Skia PathMask cache leaks memory”
contributors: bsalomon
[memory] Fixed firebase_ml_vision memory leak on iOS
contributors: rishabnayak, bparrishmines
[memory] Added DevTools based max memory test
contributors: liyuqian, dnfield, digiter
[memory] Defer image decoding when scrolling fast
contributors: dnfield, hixie, goderbauer
[memory] If an image is available in the tree currently, it should be resolvable by key without reloading even if it didn’t fit into the image cache
contributors: dnfield, hixie, goderbauer, jonahwilliams, ignatz, gaaclarke
- Issue #48731, #49456, #45406, PR #50242, #50297, #50316, #50318
- https://flutter.dev/go/widget-tree-image-cache
[speed] Rewrite DevTools frame chart with parallel UI and raster thread times
contributors: kenzieschmoll, terrylucas
- PR #1999
[speed] Added new Gallery mobile benchmarks
contributors: guidezpl, liyuqian, clocksmith, rami-a, flar
[speed] Add new Gallery web benchmarks
contributors: pennzht, yjbanov, guidezpl, willlarche, clocksmith, josealba
[speed] Community added a new package to unlock 90 fps for some devices
contributors: ajinasokan
[speed] Renamed GPU thread to raster thread
contributors: filiph, liyuqian, kenzieschmoll, chinmaygarde, cbracken, goderbauer, zanderso, devoncarew, sfshaza2
[speed] Added benchmark for platform views
contributors: blasten, cyanglaz
[speed] Avoid unnecessary thread clock clock calls while tracing, resulting in less (kernel) trace buffer space usage, and slightly lower tracing overhead.
contributors: nathanrogersgoogle, a-siva, fmeawad, johngro
[speed] Fix RefreshIndicator performance issue
contributors: dnfield, goderbauer
[speed] Enable lazy async stack traces via tool feature
contributors: jonahwilliams, zanderso
[speed] [flutter_tools] initialize frontend server with build
contributors: jonahwilliams, zanderso
[speed] Colored box and container optimization
contributors: dnfield, hansmuller, piinks, redbrogdon, goderbauer, liyuqian
Conclusion
Due to the lowered productivity as a result of COVID-19, we expected to have fewer performance improvements. Surprisingly, we found more quantified improvements in Q1-Q2 2020 than Q3-Q4 2019 (25 vs. 20) thanks to our growing community! Overall, we see 49 improvements from 78 contributors in Q1-Q2 2020.
Despite our best effort, some performance contributions in Q1-Q2 2020 may be missed in this update. Please don’t hesitate to let us know of any missing contributions, and we’ll put them in the next update.