Status Update
Comments
ra...@google.com <ra...@google.com> #2
From the thread dump (thank you!):
"DefaultDispatcher-worker-11" #42 daemon prio=5 os_prio=31 cpu=58.51ms elapsed=1151.37s tid=0x000000012fb8e000 nid=0xb103 waiting on condition [0x000000017e064000]
java.lang.Thread.State: TIMED_WAITING (parking)
at jdk.internal.misc.Unsafe.park(java.base@17.0.11/Native Method)
- parking to wait for <0x0000000711200018> (a kotlinx.coroutines.BlockingCoroutine)
at java.util.concurrent.locks.LockSupport.parkNanos(java.base@17.0.11/Unknown Source)
at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:88)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
at com.android.tools.idea.uibuilder.editor.multirepresentation.sourcecode.SourceCodeEditorProvider.createEditorAsync(SourceCodeEditorProvider.kt:116)
at com.intellij.openapi.fileEditor.AsyncFileEditorProvider$createEditorBuilder$2.invoke(AsyncFileEditorProvider.kt:25)
at com.intellij.openapi.fileEditor.AsyncFileEditorProvider$createEditorBuilder$2.invoke(AsyncFileEditorProvider.kt:25)
at com.intellij.openapi.application.rw.InternalReadAction.insideReadAction(InternalReadAction.kt:108)
... maybe related to ag/28131575 ?
PS. Note that in 2024.2, PsiAwareTextEditorProvider
is further changed in response to
gh...@google.com <gh...@google.com> #3
Incidentally, the call to PsiAwareTextEditorProvider().createEditorBuilder()
does not compile with IntelliJ 2024.2, so this code will need to be reworked anyway (I'm not sure how yet).
di...@google.com <di...@google.com> #4
It looks like the runBlocking
call can create a deadlock since the method is holding the read lock. In this thread dump it looks like ScriptClassRootsUpdater
is trying to obtain the write lock and the holding of the readlock by SourceCodeEditorProvider
.
There is no need to call createEditorBuilder
in a read action. We can get it out of the read action by moving our implementation to the experimental createEditorBuilder
instead.
"AWT-EventQueue-0" #87 prio=6 os_prio=31 cpu=11959.88ms elapsed=1151.14s tid=0x0000000151836a00 nid=0x1d003 runnable [0x00000003824cc000]
java.lang.Thread.State: TIMED_WAITING (parking)
at jdk.internal.misc.Unsafe.park(java.base@17.0.11/Native Method)
- parking to wait for <0x000000070783c0d0> (a com.intellij.openapi.application.impl.ReadMostlyRWLock)
at java.util.concurrent.locks.LockSupport.parkNanos(java.base@17.0.11/Unknown Source)
at com.intellij.openapi.application.impl.ReadMostlyRWLock.writeLock(ReadMostlyRWLock.java:266)
at com.intellij.openapi.application.impl.RwLockHolder.startWrite(RwLockHolder.kt:532)
at com.intellij.openapi.application.impl.RwLockHolder.runWriteAction(RwLockHolder.kt:352)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:888)
at com.intellij.openapi.application.ActionsKt.runWriteAction(actions.kt:16)
at org.jetbrains.kotlin.idea.core.script.ucache.ScriptClassRootsUpdater$applyDiffToModel$1.invoke(ScriptClassRootsUpdater.kt:302)
at org.jetbrains.kotlin.idea.core.script.ucache.ScriptClassRootsUpdater$applyDiffToModel$1.invoke(ScriptClassRootsUpdater.kt:301)
at com.intellij.openapi.application.ActionsKt.invokeLater$lambda$5(actions.kt:66)
at com.intellij.openapi.application.ActionsKt$$Lambda$1420/0x0000000800f80be8.run(Unknown Source)
at com.intellij.util.concurrency.ContextRunnable.run(ContextRunnable.java:27)
at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:209)
at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:22)
at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:191)
at com.intellij.openapi.application.impl.RwLockHolder.runIntendedWriteActionOnCurrentThread(RwLockHolder.kt:204)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:830)
...
di...@google.com <di...@google.com> #5
Forgot to mention, the reason for the PsiAwareTextEditorProvider().createEditorBuilder()
to block is that is waiting for the highlighter to be ready. I suspect that with AWT blocked, that never happens, hence causing the deadlock.
ra...@google.com <ra...@google.com> #6
di...@google.com <di...@google.com> #7
The fix for this will be available in the next Koala Beta.
an...@google.com <an...@google.com> #8
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Koala Feature Drop | 2024.1.2 RC 1
- Android Gradle Plugin 8.6.0-rc01
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
Description