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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
220
Road to Single Activity
yurihondo
2
850
YouTubeへのライブ配信機能をリリースするまで
yurihondo
0
3k
Shibuya.apk_41_DeepDiveintoRememberSaveable.pdf
yurihondo
0
490
Composeでシステムオーバーレイ / System overlay in Compose
yurihondo
0
380
Service由来のViewでViewModelを使えるようにしてみた
yurihondo
2
810
瀕死のシステムが強くなって復活する話
yurihondo
1
540
New UI Design & Debugging Tools In Android Studio
yurihondo
0
740
外部デバイスと密に連携するAndroidアプリに最適なアーキテクチャとは?
yurihondo
0
14k
Other Decks in Programming
See All in Programming
ハーネスエンジニアリングとは?
kinopeee
13
7k
サーバーレスで作る、動画データ管理基盤
oyasumipants
0
150
GoogleCloudとterraform完全に理解した
terisuke
1
200
Back to the roots of date
jinroq
0
840
Agent Skills を社内で育てる仕組み作り
jackchuka
1
2k
実用!Hono RPC2026
yodaka
2
310
検索設計から 推論設計への重心移動と Recall-First Retrieval
po3rin
5
1.7k
cloudnative conference 2026 flyle
azihsoyn
0
180
Terraform言語の静的解析 / static analysis of Terraform language
wata727
1
150
AgentCore Optimizationを始めよう!
licux
3
240
Spec Driven Development | AI Summit Vilnius
danielsogl
PRO
1
160
Agentic AI & UI: Arcitecture, HITL, Emerging Standards
manfredsteyer
PRO
0
100
Featured
See All Featured
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
370
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.1k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
280
The Invisible Side of Design
smashingmag
302
52k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
70
39k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
180
Making Projects Easy
brettharned
120
6.6k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
140
RailsConf 2023
tenderlove
30
1.4k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
230
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
690
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