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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Hiroshi Hosoda
April 01, 2024
Programming
1.4k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
SwiftUI Performance 不要なViewの再描画と更新を抑える
Hiroshi Hosoda
April 01, 2024
Other Decks in Programming
See All in Programming
Cloudflare is Agents
chimame
0
170
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
160
ここ半年くらいでAIに作らせたR用ツール
eitsupi
0
390
FastAPI の並行処理モデルを完全に理解する
hoto17296
1
660
Go 1.27 における memory allocation の高速化
andpad
0
280
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
350
メールのエイリアス機能を履き違えない
isshinfunada
0
250
How I Won Prize Money at a Hackathon Using Codex and Symphony Alpha
yasei_no_otoko
0
110
Webエンジニアなのにブラウザの仕組みがわからないので、Pythonで自作してみた
tatsuki12
4
830
運用ダッシュボードの設計を誰も教えてくれないのだけどみなさんどうしてるんですか? - チームに監視するという文化を根付かせるための第一歩を踏みたい -
satoshi256kbyte
1
140
170k Jobs a Day on GKE: Scaling Mercari's CI Platform - and What's Next for AI-Native Development
junyaokabe
0
120
楽しそうなつよつよエンジニアと目が死んでる僕/A brilliant engineer having a blast, and dead-eyed me.
3l4l5
2
210
Featured
See All Featured
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
410
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.3k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.5k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
210
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
470
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
How to make the Groovebox
asonas
2
2.3k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Documentation Writing (for coders)
carmenintech
77
5.5k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
390
Automating Front-end Workflow
addyosmani
1369
210k
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 ご静聴ありがとうございました