Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
flutterで画面を固めないために
Search
keitatomozawa
December 14, 2019
Programming
1
750
flutterで画面を固めないために
keitatomozawa
December 14, 2019
Tweet
Share
More Decks by keitatomozawa
See All by keitatomozawa
大規模開発組織で「未完」の基盤を育てるために、 完璧ではないEMがいかにして価値を作るか
keitatomozawa
0
64
1人のプレイヤーだった私が"プレイング"をやめて学んだこと / What I Learned about Engineering Management When I Stopped Being a Player
keitatomozawa
0
150
"統合ERP"とアプリケーションアーキテクチャ
keitatomozawa
0
9.2k
freee技術の日 freee販売開発秘話 BizDev一体で挑む新規プロダクト開発 / How was freee sales management developed
keitatomozawa
1
24k
Concurrency Bugsについての論文を読む
keitatomozawa
0
440
Other Decks in Programming
See All in Programming
堅牢なフロントエンドテスト基盤を構築するために行った取り組み
shogo4131
6
2k
AIコーディングエージェント(skywork)
kondai24
0
120
FluorTracer / RayTracingCamp11
kugimasa
0
200
【CA.ai #3】Google ADKを活用したAI Agent開発と運用知見
harappa80
0
270
React Native New Architecture 移行実践報告
taminif
1
130
ViewファーストなRailsアプリ開発のたのしさ
sugiwe
0
400
AIエンジニアリングのご紹介 / Introduction to AI Engineering
rkaga
3
1.1k
手軽に積ん読を増やすには?/読みたい本と付き合うには?
o0h
PRO
1
150
ハイパーメディア駆動アプリケーションとIslandアーキテクチャ: htmxによるWebアプリケーション開発と動的UIの局所的適用
nowaki28
0
340
CSC305 Lecture 15
javiergs
PRO
0
250
20 years of Symfony, what's next?
fabpot
2
310
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
5
1.4k
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.1k
Scaling GitHub
holman
464
140k
How to Ace a Technical Interview
jacobian
280
24k
Thoughts on Productivity
jonyablonski
73
5k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Building Applications with DynamoDB
mza
96
6.8k
Automating Front-end Workflow
addyosmani
1371
200k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.2k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
BBQ
matthewcrist
89
9.9k
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` 関数がサポートされていないので割愛
ありがとうございました
スモールビジネスを、 世界の主役に。