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
2
1.2k
Behavior of nested async in Kotlin Coroutines
yurihondo
December 18, 2018
Tweet
Share
More Decks by yurihondo
See All by yurihondo
Road to Single Activity Uncovered
yurihondo
0
210
Road to Single Activity
yurihondo
2
820
YouTubeへのライブ配信機能をリリースするまで
yurihondo
0
2.9k
Shibuya.apk_41_DeepDiveintoRememberSaveable.pdf
yurihondo
0
480
Composeでシステムオーバーレイ / System overlay in Compose
yurihondo
0
360
Service由来のViewでViewModelを使えるようにしてみた
yurihondo
2
790
瀕死のシステムが強くなって復活する話
yurihondo
1
530
New UI Design & Debugging Tools In Android Studio
yurihondo
0
720
外部デバイスと密に連携するAndroidアプリに最適なアーキテクチャとは?
yurihondo
0
14k
Other Decks in Programming
See All in Programming
AI時代のソフトウェア開発でも「人が仕様を書く」から始めよう-医療IT現場での実践とこれから
koukimiura
0
130
AHC061解説
shun_pi
0
320
オブザーバビリティ駆動開発って実際どうなの?
yohfee
3
690
API Platformを活用したPHPによる本格的なWeb API開発 / api-platform-book-intro
ttskch
1
120
Ruby x Terminal
a_matsuda
7
580
Windows on Ryzen and I
seosoft
0
120
Rails Girls Tokyo 18th GMO Pepabo Sponsor Talk
yutokyokutyo
0
200
2026年は Rust 置き換えが流行る! / 20260220-niigata-5min-tech
girigiribauer
0
220
CSC307 Lecture 14
javiergs
PRO
0
450
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
380
Unity6.3 AudioUpdate
cova8bitdots
0
110
守る「だけ」の優しいEMを抜けて、 事業とチームを両方見る視点を身につけた話
maroon8021
3
290
Featured
See All Featured
Evolving SEO for Evolving Search Engines
ryanjones
0
150
Bash Introduction
62gerente
615
210k
HDC tutorial
michielstock
1
500
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
140
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
190
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
660
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
330
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
400
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