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
Rewind & Replay: Kotlin 2.2が変えるCoroutine デバッグ最前線
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Masayuki Suda
October 31, 2025
3k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rewind & Replay: Kotlin 2.2が変えるCoroutine デバッグ最前線
Kotlin Fest2025の登壇資料です。
Masayuki Suda
October 31, 2025
More Decks by Masayuki Suda
See All by Masayuki Suda
Android端末で実現するオンデバイスLLM 2025 続き
masayukisuda
0
40
Android端末で実現するオンデバイスLLM 2025
masayukisuda
2
680
Kotlin 2.0が与えるAndroid開発の進化
masayukisuda
2
3.9k
Kotlin Collection関数をマスター
masayukisuda
1
6.4k
Jetpack Macrobenchmarkを試してみた
masayukisuda
1
400
MediaCodecで動画編集をしてみよう
masayukisuda
3
4.7k
Androidで動画編集アプリの技術選択
masayukisuda
1
1.4k
Featured
See All Featured
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
160
A Soul's Torment
seathinner
6
2.9k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1.1k
Music & Morning Musume
bryan
47
7.2k
Automating Front-end Workflow
addyosmani
1370
210k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
320
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
190
Amusing Abliteration
ianozsvald
1
200
Design in an AI World
tapps
1
240
Measuring & Analyzing Core Web Vitals
bluesmoon
9
860
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.1k
Transcript
©2024 Theoria technologies All Rights Reserved. Rewind & Replay: Kotlin
2.2 ͕ม͑ΔCoroutine σόοά࠷લઢ 2025 11/01
©2024 Theoria technologies All Rights Reserved. 2 ✓ Coroutineσόοά৽ػೳΛཧղ͢Δ ✓
Before/AfterͰ՝ղܾΛମײ͢Δ ✓ ໌͔Β͑Δ࣮ફతͳݟ ࠓͷΰʔϧ Section 1
©2024 Theoria technologies All Rights Reserved. 3 1. ΠϯτϩμΫγϣϯ 2.
Coroutineσόοάͷʮҋʯ 3. ͳͥɺCoroutineDebug͕ࠔͳͷ͔ 4. Coroutineσόοάͷ5େվળ ࣍ Section 1
©2024 Theoria technologies All Rights Reserved. 4 ࣗݾհ Section 1
ςΦϦΞɾςΫϊϩδʔζגࣜձࣾ ɹɹMasayukiSuda ɹɹdaasuu
©2024 Theoria technologies All Rights Reserved. 5 ೝͱͷ͖߹͍ํΛɺ ςΫϊϩδʔͰม͍͑ͯ͘ɻ Our
Mission ྫ͑ɺϦεΫʹૣظʹؾ͖ͮɺରԠͰ͖ΔΈΛͭ͘Δɻ ͨͱ͑ൃͯͦ͠ͷਓΒ͍͠Β͠Λࢧ͑ΔαʔϏεΛಧ͚Δɻ ͲͷΑ͏ͳεςʔδͰɺ͝ຊਓ͝ՈɺؔΘΔͯ͢ͷਓɺ ͻͱΓͻͱΓ͕ࣗʹ߹ͬͨํ๏Ͱೝͱ͖߹͏͜ͱ͕Ͱ͖ΔΑ͏ʹɻ ͦͯ͠ɺ ਓੜͷ࠷ޙͷॠؒ·Ͱɺ ࣗΒ͘͠"ੜ͖͖Δ"͜ͱ͕Ͱ͖ΔࣾձΛɺ ࣮ݱ͢ΔͨΊʹɻ
©2024 Theoria technologies All Rights Reserved. 6 ೝϓϥοτϑΥʔϜͷίϯηϓτϝΠΩϯά͔ΒιϦϡʔγϣϯ։ൃɺ σϦόϦʔͷ֦େΛਪਐ͢Δɻ ITػೳձࣾͰͳ͘ɺࣄۀձࣾͱͯ͠ΤʔβΠͱڞ͢Δɻ
Co-Creating with Eisai ҙࢥܾఆ ࣄۀਪਐ ࣗࣾ։ൃ ҩྍ࿈ܞ ઓུࡦఆ ࣗࣾ։ൃϓϩμΫτʹΑΔՁఏڙ ࢿ ࣄۀͷࢿ ࣏ݧɾίϗʔτσʔλͷΞΫηε ωοτϫʔΫɾਓࡒఏڙ
©2024 Theoria technologies All Rights Reserved. 7 Coroutineσόοάͷʮҋʯ Section 2
©2024 Theoria technologies All Rights Reserved. 8 ͋ͳͨܦݧͨͣ͠ Section 2
ʮͳͥ͜ͷCoroutine͕ࢭ·ͬͯΔʁʯ ʮͲ͜Ͱsuspendͨ͠ʁʯ ʮStack Trace్͕ΕͯΔ…ʯ ʮมͷ͕ݟ͑ͳ͍…ʯ
©2024 Theoria technologies All Rights Reserved. 9 ैདྷͷCoroutineσόοάͷ՝ Section 2
❌ Stack Traceͷஅ ❌ ϩʔΧϧมͷফࣦ ❌ εςοϓ࣮ߦͷෆ҆ఆ͞ ❌ ଟͷCoroutineͷঢ়ଶݕࠪͷࠔ͞
©2024 Theoria technologies All Rights Reserved. 10 ՝1: Stack Traceͷஅ
Section 2
©2024 Theoria technologies All Rights Reserved. 11 ՝1: Stack Traceͷஅ
Section 2
©2024 Theoria technologies All Rights Reserved. 12 ՝1: Stack Traceͷஅ
Section 2
©2024 Theoria technologies All Rights Reserved. 13 ՝1: Stack Traceͷஅ
Section 2
©2024 Theoria technologies All Rights Reserved. 14 ՝1: Stack Traceͷஅ
Section 2 Stack Trace͕b()Ͱ్ΕΔʂ
©2024 Theoria technologies All Rights Reserved. 15 ࣮ࡍͷStack Traceʢैདྷʣ Section
2 b() Ҏ߱ͷใ͕ࣦΘΕΔ
©2024 Theoria technologies All Rights Reserved. 16 ՝2: Debug࣮ߦ࣌ʹϩʔΧϧมͷফࣦ Section
2
©2024 Theoria technologies All Rights Reserved. 17 ՝2: Debug࣮ߦ࣌ʹϩʔΧϧมͷফࣦ Section
2
©2024 Theoria technologies All Rights Reserved. 18 ՝2: Debug࣮ߦ࣌ʹϩʔΧϧมͷফࣦ Section
2
©2024 Theoria technologies All Rights Reserved. 19 ՝3: εςοϓ࣮ߦͷෆ҆ఆ͞ Section
2 ϒϨʔΫϙΠϯτΛઃఆ Step Over/Into Λ࣮ߦ 👉 ҙਤͤͣผͷCoroutineʹॲཧ͕ඈͿ 👉 Ͳ͜Λ࣮ߦ͍ͯ͠Δ͔͔Βͳ͘ͳΔ
©2024 Theoria technologies All Rights Reserved. 20 ՝3: εςοϓ࣮ߦͷෆ҆ఆ͞ Section
2
©2024 Theoria technologies All Rights Reserved. 21 ՝3: εςοϓ࣮ߦͷෆ҆ఆ͞ Section
2
©2024 Theoria technologies All Rights Reserved. 22 ՝3: εςοϓ࣮ߦͷෆ҆ఆ͞ Section
2
©2024 Theoria technologies All Rights Reserved. 23 ՝4: ଟͷCoroutineͷঢ়ଶݕࠪͷࠔ͞ Section
2 CoroutineܰྔͳͨΊଟੜ͞Ε͕ͪ ͔͠͠ 👉 ଟ͘ͷCoroutineঢ়ଶݕ͕ࠪࠔ 👉 ͦΕͧΕͷCoroutineͷׂͷѲ͕ࠔ
©2024 Theoria technologies All Rights Reserved. 24 ՝4: ଟͷCoroutineͷঢ়ଶݕࠪͷࠔ͞ Section
2
©2024 Theoria technologies All Rights Reserved. 25 σόοάͷݱ࣮ Section 2
݁Ռ: • printlnσόοάʹཔΔ • ϩάΛେྔʹࠐΉ • ࠶ݱʹ͕͔͔࣌ؒΔ • ຊ൪ڥͰͷτϥϒϧγϡʔτࠔ
©2024 Theoria technologies All Rights Reserved. 26 Section 3 ͳͥɺCoroutineDebug͕ࠔͳͷ͔
©2024 Theoria technologies All Rights Reserved. 27 suspend function Section
3 suspend functionී௨ͷؔͰͳ͍
©2024 Theoria technologies All Rights Reserved. 28 ίϯύΠϥͷ෦ॲཧ Section 3
- suspend “ෳճεϦʔϓ/ΣΠΫΞοϓՄೳ”Ͱ͋Δ͜ͱΛίϯύΠϥʹ͑Δम০ࢠ - ͯ͢ͷ suspend ؔʹίϯύΠϥ͕Ӆ͠Ҿ `Continuation` Λ༩ - Continuation தஅͷ“ଓ͖”Λදݱ͠ɼresume() Ͱ࣮ߦΛ࠶։ - Continuation “ϩʔΧϧมͷอଘྖҬ”ͱͯ͠ΘΕΔ
©2024 Theoria technologies All Rights Reserved. 29 ContinuationͱԿ͔ Section 3
- தஅ͞Ε࣮ͨߦϑϩʔͷ“εφοϓγϣοτ” - resume() ݺͼग़͠Ͱͦͷଓ͖͔Β࠶։ - νΣʔϯԽ͞Εɺݺͼग़ؔ͠ͷ෮ݩʹؔ༩ - ϩʔΧϧมͷΛอ࣋͢ΔͨΊͷετϨʔδ
©2024 Theoria technologies All Rights Reserved. 30 ؔεςʔτϚγϯʹม͞ΕΔ Section 3
- suspend ؔ“Կى͖Δ”Մೳੑ͕͋ΔͨΊɺίϯύΠϥ͕εςʔτϚγϯม - ؔͷ։࢝/֤αεϖϯγϣϯϙΠϯτޙʹϥϕϧʢstateʣΛ༩ - ϥϕϧʹԠͯ͡ॲཧϒϩοΫΛସ͑Δ࣮มܗ
©2024 Theoria technologies All Rights Reserved. 31 Code sample Section
3 suspend fun describe(identifier: String): String { val description = fetchDescription(identifier) val enhancedDescription = enhanceDescription(description) return enhancedDescription } suspend fun fetchDescription(identifier: String): String {} suspend fun enhanceDescription(description: String): String {}
©2024 Theoria technologies All Rights Reserved. 32 Code sample Section
3 suspend fun describe(identifier: String, continuation: Continuation): String { }
©2024 Theoria technologies All Rights Reserved. 33 Code sample Section
3 suspend fun describe(identifier: String, continuation: Continuation): String { val description = fetchDescription(identifier) val enhancedDescription = enhanceDescription(description) return enhancedDescription }
©2024 Theoria technologies All Rights Reserved. 34 Code sample Section
3 suspend fun describe(identifier: String, continuation: Continuation): String { // label 0 -> first execution val description = fetchDescription(identifier) val enhancedDescription = enhanceDescription(description) return enhancedDescription }
©2024 Theoria technologies All Rights Reserved. 35 Code sample Section
3 suspend fun describe(identifier: String, continuation: Continuation): String { // label 0 -> first execution val description = fetchDescription(identifier) // label 1 -> resuming val enhancedDescription = enhanceDescription(description) return enhancedDescription }
©2024 Theoria technologies All Rights Reserved. 36 Code sample Section
3 suspend fun describe(identifier: String, continuation: Continuation): String { // label 0 -> first execution val description = fetchDescription(identifier) // label 1 -> resuming val enhancedDescription = enhanceDescription(description) // label 2 -> resuming and terminating return enhancedDescription }
©2024 Theoria technologies All Rights Reserved. 37 Code sample Section
3 suspend fun describe(identifier: String, continuation: Continuation): String { when (stateMachine.label) { 0 -> { // label 0 -> first execution val description = fetchDescription(identifier) return } 1 -> { // label 1 -> resuming val enhancedDescription = enhanceDescription(description) return } 2 -> { // label 2 -> resuming and terminating return enhancedDescription } } }
©2024 Theoria technologies All Rights Reserved. 38 Code sample Section
3 suspend fun describe(identifier: String, continuation: Continuation): String { when (stateMachine.label) { 0 -> { // label 0 -> first execution val description = fetchDescription(identifier) stateMachine.label = 1 return } 1 -> { // label 1 -> resuming val enhancedDescription = enhanceDescription(description) stateMachine.label = 2 return } 2 -> { // label 2 -> resuming and terminating return enhancedDescription } } }
©2024 Theoria technologies All Rights Reserved. 39 Code sample Section
3 suspend fun describe(identifier: String, continuation: Continuation): String { when (stateMachine.label) { 0 -> { // label 0 -> first execution val description = fetchDescription(identifier) stateMachine.label = 1 return } 1 -> { // label 1 -> resuming val enhancedDescription = enhanceDescription(description) stateMachine.label = 2 return } 2 -> { // label 2 -> resuming and terminating return enhancedDescription } } }
©2024 Theoria technologies All Rights Reserved. 40 Code sample Section
3 suspend fun describe(identifier: String, continuation: Continuation): String { when (stateMachine.label) { 0 -> { // label 0 -> first execution val description = fetchDescription(identifier) continuation.description = description continuation.identifier = null stateMachine.label = 1 return } 1 -> { // label 1 -> resuming val enhancedDescription = enhanceDescription(description) continuation.enhancedDescription = enhancedDescription continuation.description = null stateMachine.label = 2 return } 2 -> { // label 2 -> resuming and terminating return continuation.enhancedDescription } } }
©2024 Theoria technologies All Rights Reserved. 41 Code sample Section
3 suspend fun describe(identifier: String, continuation: Continuation): String { when (stateMachine.label) { 0 -> { // label 0 -> first execution val description = fetchDescription(identifier) continuation.description = description continuation.identifier = null stateMachine.label = 1 return } 1 -> { // label 1 -> resuming val enhancedDescription = enhanceDescription(description) continuation.enhancedDescription = enhancedDescription continuation.description = null stateMachine.label = 2 return } 2 -> { // label 2 -> resuming and terminating return continuation.enhancedDescription } } }
©2024 Theoria technologies All Rights Reserved. 42 ͳͥϩʔΧϧม͕ফ͑Δͷ͔ʢLiveness Analysisʣ Section
3 ίϯύΠϥ࠷దԽ -JWFOFTT"OBMZTJTʢੜଘੑੳʣͰlޙͷϒϩοΫͰΘΕͳ͍zมΛݕग़ Θͳ͍ม$POUJOVBUJPO͔ΒψϧԽഉআʢσόοΨʹݟ͑ͳ͍ʣ ཧ༝ ϝϞϦϦʔΫࢭʢ࣌ؒεϦʔϓதʹڊେΦϒδΣΫτΛอ࣋͠ͳ͍ʣ ྫ5#ͷσʔλΛอ࣋ͨ͠ม͕εϦʔϓ͠ଓ͚ΔࣄଶΛආ͚Δ
©2024 Theoria technologies All Rights Reserved. 43 ࠷దԽΛ͙؆қࡦ: println Section
3 ϙΠϯτ มΛQSJOUMO ʹ͢ͱl༻͞ΕΔzͨΊɺ࠷దԽͷର͔Β֎Ε͍͢ σϝϦοτϩά͕૽͕͍͠ຊ൪ʹࠞೖ͍͢͠ύϑΥʔϚϯεӨڹ
©2024 Theoria technologies All Rights Reserved. 44 ݱࡏ Section 3
Kotlin 2.2 IntelliJ IDEA 2025.1
©2024 Theoria technologies All Rights Reserved. 45 Section 4 Coroutineσόοάͷ5େվળ
©2024 Theoria technologies All Rights Reserved. 46 5େվળ Section 3
✅ ϩʔΧϧมอ࣋ ✅ Stack TraceҰ෦෮ݩ ✅ εςοϓ࣮ߦ ✅ Async Stack Trace ✅ Coroutine View ※Kotlin 2.2ɺIDEA 2025.1ͷΈ߹ΘͤͰ࣮ݱ
©2024 Theoria technologies All Rights Reserved. 47 վળ1: ϩʔΧϧมอ࣋ Section
4
©2024 Theoria technologies All Rights Reserved. 48 վળ2: Stack TraceҰ෦෮ݩ
Section 4 Coroutine ScopeΛඈͼӽ͑ͨ߹ 👉 Ͳ͔͜ΒݺΕ͔ͨՄೳ
©2024 Theoria technologies All Rights Reserved. 49 վળ2: Stack TraceҰ෦෮ݩ
Section 4
©2024 Theoria technologies All Rights Reserved. 50 վળ2: Stack TraceҰ෦෮ݩ
Section 4
©2024 Theoria technologies All Rights Reserved. 51 վળ2: Stack TraceҰ෦෮ݩ
Section 4
©2024 Theoria technologies All Rights Reserved. 52 վળ2: Stack TraceҰ෦෮ݩ
Section 4
©2024 Theoria technologies All Rights Reserved. 53 վળ1: Stack TraceҰ෦෮ݩ
Section 4 b() Ҏ߱ͷใ෮ݩ͞ΕͯΔ
©2024 Theoria technologies All Rights Reserved. 54 վળ2: Stack TraceҰ෦෮ݩ
Section 4 Coroutine ScopeΛ͑ͳͯ͘෮ݩ͢Δํ๏ͳ͍ʁ
©2024 Theoria technologies All Rights Reserved. 55 վળ2: Stack Traceશ෮ݩ
Section 4 ͋Γ·͢
©2024 Theoria technologies All Rights Reserved. 56 վળ2: Stack Trace෮ݩ
Section 4 Stack trace decoroutinator An open source library https://github.com/Anamorphosee/stacktrace-decoroutinator
©2024 Theoria technologies All Rights Reserved. 57 վળ2: Stack trace
decoroutinator Section 4 - Coroutineͷ“Wake upʢ࠶։ʣ”࣮Λ Java AgentͰஔ - ࣮ߦ࣌ʹCoroutineͷݺͼग़͠νΣʔϯʹରԠ͢Δϝιου܈Λੜ - ૬ޓݺͼग़͠Ͱ“࣮ελοΫ”෩ͷ࿈ͳΓΛܗͯ͠ྫ֎ʹࠞࡏ
©2024 Theoria technologies All Rights Reserved. 58 վળ2: Stack trace
decoroutinator Section 4 - Coroutine࠶։ͷλΠϛϯάͰ“decoroutination”༻ͷϑϨʔϜΛೖ - ੜϝιου“funA → funB → funC → ...”ͷΑ͏ʹ࿈ - ྫ֎ൃੜ࣌ɺ௨ৗͷframeͱฒΜͰ“෮ݩ͞Εͨݺͼग़͠ݩ”͕stackʹදΕΔ
©2024 Theoria technologies All Rights Reserved. 59 վળ2: Stack trace
decoroutinator Section 4
©2024 Theoria technologies All Rights Reserved. 60 վળ2: Stack trace
decoroutinator Section 4
©2024 Theoria technologies All Rights Reserved. 61 վળ2: Stack trace
decoroutinator Section 4
©2024 Theoria technologies All Rights Reserved. 62 վળ2: Stack trace
decoroutinator Section 4
©2024 Theoria technologies All Rights Reserved. 63 վળ2: Stack trace
decoroutinator Section 4
©2024 Theoria technologies All Rights Reserved. 64 վળ2: Stack trace
decoroutinator Section 4
©2024 Theoria technologies All Rights Reserved. 65 վળ2: Stack trace
decoroutinator Section 4 dependencies { implementation(“dev.reformator.stacktracedecoroutinator:stacktrace-decoroutinator-jvm:2.5.7") }
©2024 Theoria technologies All Rights Reserved. 66 վળ2: Stack trace
decoroutinator Section 4
©2024 Theoria technologies All Rights Reserved. 67 վળ2: Stack trace
decoroutinator Section 4
©2024 Theoria technologies All Rights Reserved. 68 վળ2: Stack trace
decoroutinator Section 4 ҙ: - ࣮ߦ࣌ͷΦʔόʔϔουখ͘͞ͳ͍ - ຊ൪ӡ༻Ͱඇਪɺσόοά༻్ʹݶఆ - ࠶ݱݪҼͷ“࠷ޙͷΓࡳ”ͱͯ͠׆༻
©2024 Theoria technologies All Rights Reserved. 69 վળ3: Coroutine୯ҐͰͷεςοϓ࣮ߦ੍ޚ Section
3 ಛఆͷCoroutineͰσόοάΛܧଓ 👉 ผͷCoroutineʹඈͳ͍ 👉 suspendؔεςοϓΦʔόʔՄೳ"
©2024 Theoria technologies All Rights Reserved. 70 վળ3: εςοϓ࣮ߦ Section
4
©2024 Theoria technologies All Rights Reserved. 71 վળ3: ରԠ͢Δσόοάૢ࡞ Section
4 ͜ͷػೳ͕࣮͞Ε͍ͯΔૢ࡞: • Step Over • Step Out • Smart Step Into • Run-to-Cursor
©2024 Theoria technologies All Rights Reserved. 72 վળ4: Async Stack
Trace Section 4 - IntelliJ IDEAʹࡌͷσόοΨػೳ - CoroutineΛؚΉ“ඇಉظλεΫ”ͷىݯʙݱࡏΛؔ࿈͚ͯදࣔ
©2024 Theoria technologies All Rights Reserved. 73 Async Stack Trace
Section 4
©2024 Theoria technologies All Rights Reserved. 74 վળ5: Coroutine View
Section 4 IntelliJ IDEA 2025.1ͷ৽͍͠πʔϧΟϯυ • શCoroutineͷঢ়ଶΛදࣔ • Suspend/Resumeཤྺ • ࢠؔͷՄࢹԽ
©2024 Theoria technologies All Rights Reserved. 75 Coroutine ViewͷεΫϦʔϯγϣοτ Section
4 σόοΨʔπʔϧΟϯυΡͷCoroutinesʹνΣοΫΛೖΕΔ
©2024 Theoria technologies All Rights Reserved. 76 վળ5: Coroutine View
Section 4
©2024 Theoria technologies All Rights Reserved. 77 վળ5: Coroutine View
Section 4
©2024 Theoria technologies All Rights Reserved. 78 վળ5: Coroutine View
Section 4
©2024 Theoria technologies All Rights Reserved. 79 վળ5: Coroutine View
Section 4
©2024 Theoria technologies All Rights Reserved. 80 Section 3
©2024 Theoria technologies All Rights Reserved. 81 վળ5: Coroutine View
Section 4
©2024 Theoria technologies All Rights Reserved. 82
©2024 Theoria technologies All Rights Reserved. 83 Android ։ൃͷํ Android
StudioͰ😣😣😣 • Coroutine View • εςοϓ࣮ߦ • Async Stack Trace
©2024 Theoria technologies All Rights Reserved. 84 Android ։ൃͷํ Stack
trace decoroutinator Android API 14 or higher
©2024 Theoria technologies All Rights Reserved. 85 Special Thanks Debug
Kotlin coroutines https://www.jetbrains.com/help/idea/debug-kotlin-coroutines.html Coroutine Debugging in IntelliJ IDEA | Alexey Merkulov https://www.youtube.com/watch?v=3vaAVtnrzAM Kotlin Coroutines - Debugging Tools Overview https://www.youtube.com/watch?v=InN1NzDNJrA Debugging the Future: Exploring Coroutine Debugger Tools | Nikita Nazarov https://www.youtube.com/watch?v=QomoVqZSXP0
©2024 Theoria technologies All Rights Reserved. 86 We are hiring
! ͋ͳͨͷٕज़ͰೝʹؔΘΔਓʑͷະདྷΛม͑·͠ΐ͏
©2024 Theoria technologies All Rights Reserved. 87 End Of doc.