Deadlock in Compose Runtime when shutting down the `launchMolecule` coroutine
JetBrains AI Assistant for IntelliJ-based IDEs uses Compose Runtime + Molecule for maintaining the plugin activation state.
Recently, there's been a report of a deadlock between BroadcastFrameClock.lock and Recomposer.stateLock. Apparently, it reproduces while shutting the IDE down when it starts cancelling the coroutine scopes of its services, including the one hosting the launchMolecule coroutine. Unfortunately, I don't have a narrowed down sample reproducing the issue.
Either way, the issue seems to be in the Compose Runtime itself, not Molecule, so this report is partly for transparency's sake and in case someone else encounters this issue too. Here's the upstream bug report that includes the technical details and the full stack trace of the deadlock: https://issuetracker.google.com/issues/407027032
Conceptually, this issue seems to be similar to what was observed in #396, and it involves locking the very same two locks in the opposite order, just from slightly different places.
Versions
- Compose Multiplatform version*: 1.7.3
- Kotlin version*: 2.1.20-RC2
- Molecule: 2.0.0
Thanks for the heads up! I'll follow along on the Google ticket.