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
flutterで画面を固めないために
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
keitatomozawa
December 14, 2019
Programming
1
770
flutterで画面を固めないために
keitatomozawa
December 14, 2019
Tweet
Share
More Decks by keitatomozawa
See All by keitatomozawa
特定領域から複数領域へ、そのとき何を求められるのか?縦と横、2つの影響力:統合型を目指す大規模な開発組織での実践
keitatomozawa
3
500
マネージャー・メンバー双方の視点からみる目標設定
keitatomozawa
0
13
大規模開発組織で「未完」の基盤を育てるために、 完璧ではないEMがいかにして価値を作るか
keitatomozawa
0
82
1人のプレイヤーだった私が"プレイング"をやめて学んだこと / What I Learned about Engineering Management When I Stopped Being a Player
keitatomozawa
0
160
"統合ERP"とアプリケーションアーキテクチャ
keitatomozawa
0
11k
freee技術の日 freee販売開発秘話 BizDev一体で挑む新規プロダクト開発 / How was freee sales management developed
keitatomozawa
1
24k
Concurrency Bugsについての論文を読む
keitatomozawa
0
450
Other Decks in Programming
See All in Programming
存在論的プログラミング: 時間と存在を記述する
koriym
3
280
コードレビューをしない選択 #でぃーぷらすトウキョウ
kajitack
3
1k
ポーリング処理廃止によるイベント駆動アーキテクチャへの移行
seitarof
3
1.1k
Vuetify 3 → 4 何が変わった?差分と移行ポイント10分まとめ
koukimiura
0
170
new(1.26) ← これすき / kamakura.go #8
utgwkk
0
2.6k
AI時代のシステム設計:ドメインモデルで変更しやすさを守る設計戦略
masuda220
PRO
6
1.1k
GC言語のWasm化とComponent Modelサポートの実践と課題 - Scalaの場合
tanishiking
0
120
OTP を自動で入力する裏技
megabitsenmzq
0
120
DevinとClaude Code、SREの現場で使い倒してみた件
karia
1
1.1k
Windows on Ryzen and I
seosoft
0
330
Linux Kernelの1文字のミスで 権限昇格ができた話
rqda
0
2k
20260315 AWSなんもわからん🥲
chiilog
2
170
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
320
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
230
How to make the Groovebox
asonas
2
2k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.4k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
199
73k
Code Reviewing Like a Champion
maltzj
528
40k
Building the Perfect Custom Keyboard
takai
2
720
Designing for Performance
lara
611
70k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
100
Information Architects: The Missing Link in Design Systems
soysaucechin
0
830
How to train your dragon (web standard)
notwaldorf
97
6.6k
Transcript
freee 株式会社 flutterで画面を固めない為に @GDG DevFest Kobe 2019.12.15
• twitter:tomoz6o9 • Webアプリケーションエンジニア ◦ RoR/React/Go • 大阪にも開発チームあります! Keita Tomozawa
友澤 啓太 Software Engineer 2
01 画面を固めうる CPUヘビーな処理の例 3 Section
素因数分解をする (普通やらない)
巨大なJSONのParse(とか)をする ギリある(ということにする)
02 どうすればいいか 6 Section
7 画面を固めてしまう例 `async/await`は書けばいい訳ではない • 中身がasyncになっていないので無意味 ◦ よく使う‘package:http’等の中身は非同期になる ように実装されているから安心
• 固まる目安 ◦ flutterは 通 常 60fps 出 るようになっているので 16ms以上かかるような処理ではフレーム落ちの 可能性がでてくる Source: https://flutter.dev/docs/perf/rendering/ui-performance
8 何が起こっているか • Dartはシングルスレッドで動作する • async/awaitはメイン処理上の ‘concurrency’ が表現されている ◦ not
‘parallelism’ Parallelism Concurrency
9 どうする:Use `compute` function ‘package:flutter/foundation.dart’ 内のcompute関数を使う • foundation.dartをimport
• 該当する処理をstaticな処理にする • compute関数に該当処理、計算したい引数を 渡してawait(または普通のFutureを扱うように) Source: https://api.flutter.dev/flutter/foundation/compute.html
10 何がおこっているか • DartにはIsolateというものがある ◦ JavaなどのThreadみたいなものだが、メモリを共有しない ◦ jsのwebworkerに近い ◦ 異なるisolateはparallelに動作する
• メイン処理は『Main Isolate』という場所で動いている • flutterから複数のIsolateを使うことができる • 重い処理は、別のIsolateに乗せてあげることでUIフリーズを防ぐ • このIsolateを簡単に使えるようにしてくれているのがcompute関数
11 注意点 • staticメソッドしか渡せない ◦ 2つのIsolateは互いにメモリを共有しないので • 処理に必要な情報は引数として渡す必要がある ◦ 同上
• スイッチングコストは考慮すべき ◦ Isolateはいわゆる軽量スレッドほど手軽ではない ◦ はっきり止まってしまう場合以外はそこまでうま味なし
12 demoをと思ったのですが、、、 • dart padでflutter webがいじれるようになったので ◦ https://dartpad.dartlang.org/d35da88b66b3144b3784c94118f033e1 ◦ https://gist.github.com/keitatomozawa/d35da88b66b3144b3784c94118f033e1
• まだ webでは `compute` 関数がサポートされていないので割愛
ありがとうございました
スモールビジネスを、 世界の主役に。