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
200
Road to Single Activity
yurihondo
2
800
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
520
New UI Design & Debugging Tools In Android Studio
yurihondo
0
720
外部デバイスと密に連携するAndroidアプリに最適なアーキテクチャとは?
yurihondo
0
14k
Other Decks in Programming
See All in Programming
例外処理とどう使い分ける?Result型を使ったエラー設計 #burikaigi
kajitack
16
6k
Grafana:建立系統全知視角的捷徑
blueswen
0
330
Smart Handoff/Pickup ガイド - Claude Code セッション管理
yukiigarashi
0
130
CSC307 Lecture 04
javiergs
PRO
0
660
CSC307 Lecture 09
javiergs
PRO
1
830
ThorVG Viewer In VS Code
nors
0
770
フルサイクルエンジニアリングをAI Agentで全自動化したい 〜構想と現在地〜
kamina_zzz
0
400
16年目のピクシブ百科事典を支える最新の技術基盤 / The Modern Tech Stack Powering Pixiv Encyclopedia in its 16th Year
ahuglajbclajep
5
1k
ぼくの開発環境2026
yuzneri
0
200
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
190
カスタマーサクセス業務を変革したヘルススコアの実現と学び
_hummer0724
0
690
Fluid Templating in TYPO3 14
s2b
0
130
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
54
8k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
240
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.2k
Building AI with AI
inesmontani
PRO
1
690
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
0
140
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.4k
How Software Deployment tools have changed in the past 20 years
geshan
0
32k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
0
1.1k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
64
First, design no harm
axbom
PRO
2
1.1k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
140
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