Skip to content

Deadlock in Compose Runtime when shutting down the launchMolecule coroutine #604

@abusalimov

Description

@abusalimov

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions