Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Behavior of nested async in Kotlin Coroutines
Search
yurihondo
December 18, 2018
Programming
1.3k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Behavior of nested async in Kotlin Coroutines
yurihondo
December 18, 2018
Transcript
20 slides
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
More Decks by yurihondo
See All by yurihondo
Road to Single Activity Uncovered
yurihondo
0
240
Road to Single Activity
yurihondo
2
900
YouTubeへのライブ配信機能をリリースするまで
yurihondo
0
3.2k
Shibuya.apk_41_DeepDiveintoRememberSaveable.pdf
yurihondo
0
510
Composeでシステムオーバーレイ / System overlay in Compose
yurihondo
0
410
Service由来のViewでViewModelを使えるようにしてみた
yurihondo
2
840
瀕死のシステムが強くなって復活する話
yurihondo
1
550
New UI Design & Debugging Tools In Android Studio
yurihondo
0
770
外部デバイスと密に連携するAndroidアプリに最適なアーキテクチャとは?
yurihondo
0
14k
Other Decks in Programming
See All in Programming
Kotlin Fest 2026: Kotlin コンパイラに Contribute してみよう! - Kotlin/Wasm で深い再帰を書けるようにした話
ternbusty
1
430
Going Full Circle with Virtual Graphs and Relational Databases
michaelsimons
1
120
Compiling Your Language to WasmGC & Friends
tanishiking
0
910
高橋メソッドでCVE解説シリーズ 〜CVE-2026-112816〜
hakkadaikon
0
280
手の動かし方がわからなかった私が個人開発者になるまで
usagi0920_pochi
0
350
LambdaなのにVM?Lambda MicroVMsを調べてみた / About Lambda Micro VMs
ak2ie
2
110
Spec-driven Development with AI
simas
PRO
0
2.3k
protojson における文字化けの扱い
kazuki1023
0
470
Stage 3でも仕様は変わる。アプリケーション開発者のためのTC39プロセスの読み方
bicstone
1
1.2k
あなたはMCPの機能を、まだ知らない。
4geru
1
750
Rails初心者がパスキーを実装してみて大変だったこと
ktombow
0
250
ローカルLLMの基本と近況 2611 / Local LLM basics and recent situation 2611
kishida
3
680
Featured
See All Featured
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
690
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
320
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.3k
Tell your own story through comics
letsgokoyo
1
1.1k
ラッコキーワード サービス紹介資料
rakko
5
6.1M
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.5k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
480
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Crafting Experiences
bethany
1
460
A better future with KSS
kneath
240
18k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
370