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
SwiftUI Performance 不要なViewの再描画と更新を抑える
Search
Hiroshi Hosoda
April 01, 2024
Programming
1
340
SwiftUI Performance 不要なViewの再描画と更新を抑える
Hiroshi Hosoda
April 01, 2024
Tweet
Share
Other Decks in Programming
See All in Programming
AWS初心者ってどうやってAWSを学ぶ?〜アプリエンジニアがやってよかったアーキテクチャ学習方法〜
yamanashi_ren01
0
190
Trial
cairolibrary720
1
130
Architectures with Lightweight Stores: New Rules and Options
manfredsteyer
PRO
0
100
OpenAI/Gemini APIを使って EPUBを翻訳するCLIツールをつくってみた
tomiyan
0
790
ピグパーティにおけるMongoDB CommunityバージョンからAtlasへの移行事例
10969hotaka
0
130
Play Billing Library 7.0.0 変更点まとめ@potatotips#88
kako351
0
160
社内 LT 会を発足し、アウトプット文化を醸成させるために考えたこと・やったこと / Starting internal LT meetings and fostering an output culture
mackey0225
3
120
Webエディタライブラリ 「CodeMirror」から学ぶ Webアプリ開発のテクニック
ryosukeigarashi
0
250
最古の関数型言語「Lisp」ことはじめ / lisp_in_kamiyama
uhooi
1
190
Composing an API the *right* way (Droidcon Berlin 2024)
zsmb
1
450
[After Kotlin Fest 2024 LT Night @ Sansan] もっともっとKotlinを好きになる!K2 Compiler Pluginで遊んでみよう!
kitakkun
2
260
Folding Cheat Sheet #7
philipschwarz
PRO
0
150
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
423
64k
It's Worth the Effort
3n
181
27k
Music & Morning Musume
bryan
43
5.9k
Happy Clients
brianwarren
94
6.5k
A better future with KSS
kneath
231
17k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
26
1.8k
Visualization
eitanlees
139
14k
10 Git Anti Patterns You Should be Aware of
lemiorhan
652
58k
Raft: Consensus for Rubyists
vanstee
134
6.5k
Thoughts on Productivity
jonyablonski
64
4.1k
How STYLIGHT went responsive
nonsquared
93
5k
VelocityConf: Rendering Performance Case Studies
addyosmani
321
23k
Transcript
© DMM © DMM CONFIDENTIAL SwiftUI Performance 不要なViewの再描画と更新を抑える
© DMM 自己紹介 • 細田大志 • 2019年 中途入社 • 動画配信開発部
• DMMTVの開発 2
© DMM 3 • Viewの再描画と更新の仕組み • Identity • Property •
Equatable • Viewの再描画と更新を抑える方法 • デバッグとInstruments アジェンダ
© DMM 4 • 再描画 • Viewを0から生成し直し表示する • ViewのIdentityが変化した場合 •
更新 • 必要なViewを更新して表示する • Viewのプロパティが変化した場合 Viewの再描画と更新
© DMM Identity SwiftUIはアプリの更新において同じか異なる要素かをIdentityによって認識 します。 SwiftUIには2種類のIdentityがあります。 • Explicit Identity •
Structural Identity 5
© DMM Explicit Identity 明示的な値によって管理されるIdentity。 6
© DMM Structural Identity View構造と型によって管理される 7
© DMM Property • @State • @StateObject • @ObservedObject •
@Binding • let • など 8
© DMM Equatable Viewが同値かによって更新するかを判定 9
© DMM 可能な限り分岐を統合する 可能な限りModifierを活用する 10
© DMM Viewには必要最低限な値を渡す プロパティが変更されると、View全体が更新される 11
© DMM Observation オブジェクトのプロパティをSwiftUIのViewが監視できるようになる。 12
© DMM Viewを分割する 複数のPropertyを持つViewのBodyを分割する 13
© DMM Viewを比較可能にする 14
© DMM ForEach ステーブルなidを使う 15
© DMM Debug • Self._printChanges • Viewが再描画または更新されるタイミングと要因を確認することができる • print(type(of: self.body))
• bodyの型情報を確認することができる 16
© DMM Instruments • Time Profiler • 実行された関数にかかった時間 • Hangs
• 応答していないメインスレッドを検 出し、対応するインターバルをハ ングの可能性があるものとしてラ ベル付けされる • View Body • 作成されたビューの数と作成にか かった時間 17
© DMM ご静聴ありがとうございました