Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Profiling Flutter Apps - GDD China 2018
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
xster
September 20, 2018
Programming
800
3
Share
Profiling Flutter Apps - GDD China 2018
Talk from GDD in Shanghai
xster
September 20, 2018
More Decks by xster
See All by xster
SV Flutter iOS Meetup - 18/08/20
xster
0
130
Flutter GMTC
xster
0
110
Other Decks in Programming
See All in Programming
開発体験を左右するライブラリの API 設計 - GraphQL スキーマ構築ライブラリから考える #tskaigi
izumin5210
1
110
GitHubCopilotCLIをはじめよう.pdf
htkym
0
330
エラー処理の温故知新 / history of error handling technic
ryotanakaya
7
1.9k
Firefoxにコントリビューションして得られた学び
ken7253
2
160
Cloudflare で始める Data Platform
ta93abe
0
170
How We Practice Exploratory Testing in Iterative Development( #scrumniigata ) / 反復開発の中で、探索的テストをどう実施しているか
teyamagu
PRO
3
840
Agentic Elixir
whatyouhide
0
450
AgentCore Optimizationを始めよう!
licux
3
240
書き換えて学ぶTemporal #fukts
pirosikick
2
380
cloudnative conference 2026 flyle
azihsoyn
0
180
決定論 vs 確率論:Gemini 3 FlashとTF-IDFを組み合わせた「法規判定エンジン」の構築
shukob
0
160
Oxlintはいかにしてtsgolintのlint ruleを呼び出しているのか
syumai
0
160
Featured
See All Featured
Speed Design
sergeychernyshev
33
1.7k
Optimising Largest Contentful Paint
csswizardry
37
3.7k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
310
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.7k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.5k
Building Applications with DynamoDB
mza
96
7k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
550
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
200
How GitHub (no longer) Works
holman
316
150k
The agentic SEO stack - context over prompts
schlessera
0
780
Transcript
Flutter Performance Profiling and Theory Flutter的性能测试与理论 Xiao Yu 于潇
听众收益 • 时间都去哪了? • 理念投入使用 • 使用工具调试 Talk Goals
前言 • 不是入门题材 • 同场5:30请关注Flutter图像系统性能论坛 Preface
什么是应用性能 What is Rendering Performance
什么是应用性能 What is Rendering Performance VSync Animation Measure Layout Draw
Display list -> GPU VSync Animation Constraint Layout Display Display list -> GPU
什么是应用性能 What is Rendering Performance VSync Animation Measure Layout Draw
Display list -> GPU VSync Animation Constraint Layout Display Display list -> GPU Declarative -> Imperative
什么是应用性能 What is Rendering Performance VSync Animation Measure Layout Draw
Display list -> GPU VSync Animation Constraint Layout Display Display list -> GPU Declarative -> Imperative
Flutter的渲染阶段 Flutter’s Rendering Pipeline VSync Animation Build Layout Paint Display
list -> GPU
检测Flutter的渲染 Instrumenting Flutter’s Rendering
Profile模式 Profile Mode
检测Flutter的渲染 Instrumenting Flutter’s Rendering DEMO
渲染责任部件 Rendering Actors android.view.View - construct/inflate/update - onMeasure(int, int) -
onLayout(boolean, int, int, int, int) - onDraw(Canvas)
渲染责任部件 Rendering Actors android.view.View - construct/inflate/update - onMeasure(int, int) -
onLayout(boolean, int, int, int, int) - onDraw(Canvas) VSync Animation Measure Layout Draw Display list -> GPU
渲染责任部件 Rendering Actors UIView - init/update - updateConstraints - layoutSubviews
- drawRect:(CGRect)
渲染责任部件 Rendering Actors UIView - init/update - updateConstraints - layoutSubviews
- drawRect:(CGRect) VSync Animation Constraint Layout Display Display list -> GPU
Flutter的渲染责任部件 Flutter’s Rendering Actors RenderObject - createRenderObject/updateRenderObject - performLayout() -
paint(PaintingContext context, Offset offset)
Flutter的渲染责任部件 Flutter’s Rendering Actors RenderObject - createRenderObject/updateRenderObject - performLayout() -
paint(PaintingContext context, Offset offset) VSync Animation Build Layout Paint Display list -> GPU
Flutter的渲染责任部件 Flutter’s Rendering Actors RenderObject - createRenderObject/updateRenderObject - performLayout() -
paint(PaintingContext context, Offset offset) VSync Animation Build Layout Paint Display list -> GPU
Flutter的声明式UI Flutter’s Declarative UI VSync Animation Measure Layout Draw Display
list -> GPU VSync Animation Constraint Layout Display Display list -> GPU Declarative -> Imperative
Flutter的树与渲染阶段 Flutter’s Trees and Rendering Phases Layout Paint Display list
-> GPU Build
Flutter的树与渲染阶段 Flutter’s Trees and Rendering Phases Layout Paint Display list
-> GPU Build Widget Element RenderObject Layer
Flutter的树与渲染阶段 Flutter’s Trees and Rendering Phases Layout Paint Display list
-> GPU Build Widget Element RenderObject Layer Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘A’), ], ), ) Image RawImage Container DecoratedBox Row Text RichText
Flutter的树与渲染阶段 Flutter’s Trees and Rendering Phases Layout Paint Display list
-> GPU Build Widget Element RenderObject Layer ComponentElement RenderObjectElement RenderObjectElement RenderObjectElement ComponentElement Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘A’), ], ), )
Flutter的树与渲染阶段 Flutter’s Trees and Rendering Phases Layout Paint Display list
-> GPU Build Widget Element RenderObject Layer StatelessElement Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘A’), ], ), ) RenderObjectElement RenderObjectElement RenderObjectElement StatelessElement StatefulElement RenderObjectElement
Flutter的树与渲染阶段 Flutter’s Trees and Rendering Phases Layout Paint Display list
-> GPU Build Widget Element RenderObject Layer Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘A’), ], ), ) StatefulWidget RenderObjectWidget StatelessWidget RenderObjectWidget RenderObjectWidget StatelessWidget RenderObjectWidget
Flutter的树与渲染阶段 Flutter’s Trees and Rendering Phases Layout Paint Display list
-> GPU Build Widget Element RenderObject Layer StatelessElement SingleChildRenderObjectElement MultiChildRenderObjectElement Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘A’), ], ), ) LeafRenderObjectElement StatelessElement StatefulElement LeafRenderObjectElement
Flutter的树与渲染阶段 Flutter’s Trees and Rendering Phases Layout Paint Display list
-> GPU Build Widget Element RenderObject Layer RenderDecoratedBox RenderFlex RenderImage RenderParagraph Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘A’), ], ), )
Flutter的树与渲染阶段 Flutter’s Trees and Rendering Phases Layout Paint Display list
-> GPU Build Widget Element RenderObject Layer PictureLayer Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘A’), ], ), )
树工程 Tree Operations Layout Paint Display list -> GPU Build
Widget Element RenderObject Layer Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘A’), ], ), )
了解build阶段 Understanding the Build Phase
同类型更新 Same Type Update Layout Paint Display list -> GPU
Build Widget Element RenderObject Layer Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘B’), ], ), ) Text(‘B’),
Layout Paint Display list -> GPU Build Widget Element RenderObject
Layer Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘B’), ], ), ) Text(‘B’), 同类型更新 Same Type Update
Layout Paint Display list -> GPU Build Widget Element RenderObject
Layer Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘B’), ], ), ) Text(‘B’), Same Type Update 同类型更新
Layout Paint Display list -> GPU Build Widget Element RenderObject
Layer Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘B’), ], ), ) Text(‘B’), Same Type Update ? ? ? ? ? ? 同类型更新
Layout Paint Display list -> GPU Build Widget Element RenderObject
Layer Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘B’), ], ), ) Text(‘B’), Element.updateChild() Same Type Update ? ? ? ? ? ? 同类型更新
Layout Paint Display list -> GPU Build Widget Element RenderObject
Layer Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘B’), ], ), ) Text(‘B’), ComponentElement.update() Same Type Update ? ? ? ? ? ? 同类型更新
Layout Paint Display list -> GPU Build Widget Element RenderObject
Layer Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘B’), ], ), ) Text(‘B’), Same Type Update ComponentElement.update() ? ? ? ? ? ? 同类型更新
Layout Paint Display list -> GPU Build Widget Element RenderObject
Layer Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘B’), ], ), ) Text(‘B’), Same Type Update Element.updateChild() ? ? ? ? ? ? 同类型更新
Layout Paint Display list -> GPU Build Widget Element RenderObject
Layer Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘B’), ], ), ) Text(‘B’), RenderObjectElement.update() Same Type Update ? ? ? ? ? 同类型更新
Layout Paint Display list -> GPU Build Widget Element RenderObject
Layer Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘B’), ], ), ) Text(‘B’), Same Type Update ? ? ? ? ? 同类型更新
Layout Paint Display list -> GPU Build Widget Element RenderObject
Layer Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘B’), ], ), ) Text(‘B’), @override void updateRenderObject(BuildContext context, RenderDecoratedBox renderObject) { renderObject ..decoration = decoration ..configuration = createLocalImageConfiguration(context) ..position = position; } Same Type Update 同类型更新
Layout Paint Display list -> GPU Build Widget Element RenderObject
Layer Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘B’), ], ), ) Text(‘B’), ? Same Type Update ? ? ? ? ? 同类型更新
Layout Paint Display list -> GPU Build Widget Element RenderObject
Layer Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘B’), ], ), ) ? ? ? ? ? Text(‘B’), ? set decoration(Decoration value) { assert(value != null); if (value == _decoration) return; _painter?.dispose(); _painter = null; _decoration = value; markNeedsPaint(); } Same Type Update 同类型更新
Layout Paint Display list -> GPU Build Widget Element RenderObject
Layer Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘B’), ], ), ) Text(‘B’), ? ? ? ? ? set decoration(Decoration value) { assert(value != null); if (value == _decoration) return; _painter?.dispose(); _painter = null; _decoration = value; markNeedsPaint(); } ? set decoration(Decoration value) { assert(value != null); if (value == _decoration) return; _painter?.dispose(); _painter = null; _decoration = value; markNeedsPaint(); } Same Type Update 同类型更新
Layout Paint Display list -> GPU Build Widget Element RenderObject
Layer Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘B’), ], ), ) Text(‘B’), Same Type Update ? ? ? ? 同类型更新 ...
Layout Paint Display list -> GPU Build Widget Element RenderObject
Layer Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘B’), ], ), ) Text(‘B’), Same Type Update 同类型更新
如何提高build效率 How to Improve Build Efficiency
调试工具 • debugPrintBeginFrameBanner/debugPrintEndFrameBanner ◦ 每帧开始/结束 • debugPrintScheduleBuildForStacks ◦ 为什么被构建 •
debugPrintRebuildDirtyWidgets ◦ 什么组件被重新构建了 • debugProfileBuildsEnabled ◦ 在观测台里显示构建树 Performance Debugging Tools
调试工具 • debugPrintBeginFrameBanner/debugPrintEndFrameBanner ◦ 每帧开始/结束 • debugPrintScheduleBuildForStacks ◦ 为什么被构建 •
debugPrintRebuildDirtyWidgets ◦ 什么组件被重构建了 • debugProfileBuildsEnabled ◦ 在观测台里显示构建树 Performance Debugging Tools
调试工具 • debugPrintBeginFrameBanner/debugPrintEndFrameBanner ◦ 每帧开始/结束 • debugPrintScheduleBuildForStacks ◦ 为什么被构建 •
debugPrintRebuildDirtyWidgets ◦ 什么组件被重构建了 • debugProfileBuildsEnabled ◦ 在观测台里显示构建树 Performance Debugging Tools DEMO
Layout Paint Display list -> GPU Build Widget Element RenderObject
Layer 如何提高build效率 How to Improve Build Efficiency Container( color: Colors.blue, child: Row( children: <Widget>[ Image.network( ‘.../1.png’ ), Text(‘B’), ], ), ) ? ? ? ? ? ?
如何提高build效率 How to Improve Build Efficiency 降低遍历的出发点 ? ? ?
?
如何提高build效率 How to Improve Build Efficiency 停止树的遍历 降低遍历的出发点
如何提高build效率 How to Improve Build Efficiency 降低遍历的出发点 1. setState 2.
InheritedWidget 3. 热重载 ? ? ? ?
? ? ? ? 如何提高build效率 How to Improve Build Efficiency
降低遍历的出发点 1. setState 2. InheritedWidget 3. 热重载 DEMO
如何提高build效率 How to Improve Build Efficiency 停止树的遍历 降低遍历的出发点 1. 重用同一子组件实例
如何提高build效率 How to Improve Build Efficiency
如何提高build效率 How to Improve Build Efficiency
如何提高build效率 How to Improve Build Efficiency SlideTransition( ... child: Row(...)
)
了解layout阶段 Understanding the Layout Phase
布局阶段 Layout Phase Layout Paint Display list -> GPU Build
Widget Element RenderObject Layer 约 束 大 小
布局阶段 Layout Phase 最小宽度 最大宽度 最 小 高 度 最
大 高 度
了解paint阶段 Understanding the Paint Phase
绘制阶段 Paint Phase Layout Paint Display list -> GPU Build
Widget Element RenderObject Layer
Layout Paint Display list -> GPU Build Widget Element RenderObject
Layer 位置 Layer 绘制阶段 Paint Phase
Layer种类 Layer Types ContainerLayer ContainerLayer PictureLayer ContainerLayer PictureLayer ContainerLayer TextureLayer
Layer种类 Layer Types TransformLayer OffsetLayer PictureLayer OffsetLayer PictureLayer OffsetLayer TextureLayer
如何提高paint效率 How to Improve Paint Efficiency
Layout Paint Display list -> GPU Build Widget Element RenderObject
Layer How to Improve Paint Efficiency ? ? ? 如何提高paint效率
Layout Paint Display list -> GPU Build Widget Element RenderObject
Layer RepaintBoundary RepaintBoundary How to Improve Paint Efficiency 如何提高paint效率
调试工具 • debugDumpLayerTree ◦ 查看layer树 • debugPaintLayerBordersEnabled ◦ 查看layer界限 •
debugRepaintRainbowEnabled ◦ 被重新绘制的RenderObject • debugProfilePaintsEnabled ◦ 在观测台里显示绘制树 Performance Debugging Tools
调试工具 • debugDumpLayerTree ◦ 查看layer树 • debugPaintLayerBordersEnabled ◦ 查看layer界限 •
debugRepaintRainbowEnabled ◦ 被重新绘制的RenderObject • debugProfilePaintsEnabled ◦ 在了望台里显示绘制树 Performance Debugging Tools DEMO
Layout Paint Display list -> GPU Build Widget Element RenderObject
Layer
[email protected]
@xster