Commit 94ee78c
Hitting breakpoint in Kotlin sometimes doesn't work (KT-22205)
Fix KT-22205 and https://issuetracker.google.com/issues/71556313
Hitting breakpoints in Kotlin JUnit test with an Android Gradle
project sometimes(*) does not work in Android Studio 3.1 beta.
(*) The issue is related to various threads running concurrently
with "dumb" mode background code, so the issue reproduces only
on certain configurations.
In a nutshell, the issue is as follows
* On one hand, gradle build finishes, fires an event ("buildFinished")
that is processed "later" and that causes the IDE to enter "dumb" mode
for a shot amount of time (about 300-500 msec on a somewhat up to date
multi-core computer).
* On the other hand, once the JVM of the debuggee is started, breakpoints
need to be resolved (on the debugger thread, through a call to
com.intellij.debugger.engine.CompoundPositionManager.createPrepareRequests.
This code calls into the "KotlinPositionManager.createPrepareRequests",
which in turns calls into "PerFileAnalysisCache.analyze". That method
returns "AnalysisResult.EMPTY" is the project is in dumb mode.
This return value prevents callers from successfully resolving
the source location into a breakpoint.
Given that the 2 code paths above execute on separate threads without
explicit synchronization, the "failed to resolve breakpoint" issue
occurs sporadically, to the point it happens 100% of the time on
certain configuration.
The fix is so wrap the kotlin breakpoint resolution code inside
a "runReadActionInSmartMode" so that the debugger thread "waits"
for "dumb" mode to terminates before trying to resolve breakpoint
locations.
#KT-22205 Fixed1 parent b1bcadd commit 94ee78c
File tree
1 file changed
+11
-7
lines changed- idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger
1 file changed
+11
-7
lines changedLines changed: 11 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| |||
342 | 344 | | |
343 | 345 | | |
344 | 346 | | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
352 | 356 | | |
353 | 357 | | |
354 | 358 | | |
| |||
0 commit comments