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
Behavior of nested async in Kotlin Coroutines
Search
yurihondo
December 18, 2018
Programming
1.2k
2
Share
Behavior of nested async in Kotlin Coroutines
yurihondo
December 18, 2018
More Decks by yurihondo
See All by yurihondo
Road to Single Activity Uncovered
yurihondo
0
210
Road to Single Activity
yurihondo
2
830
YouTubeへのライブ配信機能をリリースするまで
yurihondo
0
3k
Shibuya.apk_41_DeepDiveintoRememberSaveable.pdf
yurihondo
0
490
Composeでシステムオーバーレイ / System overlay in Compose
yurihondo
0
370
Service由来のViewでViewModelを使えるようにしてみた
yurihondo
2
800
瀕死のシステムが強くなって復活する話
yurihondo
1
540
New UI Design & Debugging Tools In Android Studio
yurihondo
0
730
外部デバイスと密に連携するAndroidアプリに最適なアーキテクチャとは?
yurihondo
0
14k
Other Decks in Programming
See All in Programming
PHPで TLSのプロトコルを実装してみる
higaki_program
0
740
PHP で mp3 プレイヤーを実装しよう
m3m0r7
PRO
0
180
存在論的プログラミング: 時間と存在を記述する
koriym
5
840
飯MCP
yusukebe
0
490
それはエンジニアリングの糧である:AI開発のためにAIのOSSを開発する現場より / It serves as fuel for engineering: insights from the field of developing open-source AI for AI development.
nrslib
1
830
The Monolith Strikes Back: Why AI Agents ❤️ Rails Monoliths
serradura
0
270
LM Linkで(非力な!)ノートPCでローカルLLM
seosoft
0
420
我々はなぜ「層」を分けるのか〜「関心の分離」と「抽象化」で手に入れる変更に強いシンプルな設計〜 #phperkaigi / PHPerKaigi 2026
shogogg
2
840
年間50登壇、単著出版、雑誌寄稿、Podcast出演、YouTube、CM、カンファレンス主催……全部やってみたので面白さ等を比較してみよう / I’ve tried them all, so let’s compare how interesting they are.
nrslib
4
720
テレメトリーシグナルが導くパフォーマンス最適化 / Performance Optimization Driven by Telemetry Signals
seike460
PRO
2
220
夢の無限スパゲッティ製造機 -実装篇- #phpstudy
o0h
PRO
0
200
Go_College_最終発表資料__外部公開用_.pdf
xe_pc23
0
140
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Practical Orchestrator
shlominoach
191
11k
Utilizing Notion as your number one productivity tool
mfonobong
4
290
Building Applications with DynamoDB
mza
96
7k
Producing Creativity
orderedlist
PRO
348
40k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
The Limits of Empathy - UXLibs8
cassininazir
1
290
Git: the NoSQL Database
bkeepers
PRO
432
67k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.2k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
260
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.7k
Transcript
Behavior of nested async in Kotlin Coroutines
About me Androidアプリ開発@DeNA 趣味は、ストリートダンス 今年、長男が爆誕 2 URI 本戸 裕理 (ホンド
ユウリ)
Introduction 今更ですが! Kotlin 1.3より、Coroutineの安定版が 利用できるようになりました 3
Introduction 私が携わるプロジェクトでもCoroutineの アップデートが 行われました 4
Introduction 結果、 アップデート起因のバグを埋め込み、 修正をする事になりました 5
Introduction そう、 あるあるです 6
Introduction (流出はしていません) 一応、最近センシティブだからね 7
Introduction 今日は、バグ対応から学んだ ◦ ネストしたasyncの振舞いと対応方法 について簡単にお話させて頂きます 8
ネストしたasyncの振舞いと対応方法 9
ver. 0.30.0より、ネストしたasyncのキャンセルが、 親のcoroutineにも伝播するようになったため、 今までエラーハンドリングを意識していなかった 箇所で例外が発生した 該当のFeature <https://github.com/Kotlin/kotlinx.coroutines/releases/tag/0.30.0> Overview for Bug
10
例えば、 以下のようなケースで例外が発生するようになった Example 11
例外が親のlaunchにも伝播する Example 12 Exception
Solution 1 withContextを利用 13
Solution 2 スコープを切り替える 14
今回の例であれば、launchにCoroutineExceptionHandler を渡して ネストされたのCoroutineのエラーをまとめてしまう Solution 3 例外の集約 15
※以下は、supervisorScopeの例 Solution 4 Supervisionを導入 16
まとめ 17 これからネスト状態でasyncを扱うときは... 1. withContextを使う 2. Suspend関数に切り出す 3. 例外の集約 4.
Supervisionの導入 辺りを検討できると良いかも...そして...
まとめ 18 Release Note は、しっかり読みましょう!!! (自戒)
Reference 今回の発表の不明点は、以下でほぼ解消されます 19 ◦ Kotlin Coroutines 0.30.2のExceptionが伝わる仕組み <https://qiita.com/takahirom/items/2846caa1d51e868ef88b> ◦ Kotlin
Coroutine 1.0.0までに夏から変わったところ <http://sys1yagi.hatenablog.com/entry/2018/12/08/181232>
THANKS! You can find me at: Twitter : URI -
@yuyuyuyuyuri Pokemon GO : 05URI28 - 0188 7196 1789 20