compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

Consider removing `Unconfined` dispatcher as default `CoroutineContext` for `ComposeScene` creation

Open JakeWharton opened this issue 1 year ago • 1 comments

I am standing up Compose UI on a new target, and was surprised to see Dispatchers.Unconfined as the default value for the CoroutineContext when setting up a Compose scene. This seems like a dangerous default. I did not initially supply this value and it caused deadlocks in my application.

JakeWharton avatar May 10 '24 16:05 JakeWharton

I agree that it's a bad default value, but changing it could break someone's code (after recompilation).

On the other hand, it is really a bad value because:

  1. It causes effects to be run immediately when they are launched, which changes the order relative to what happens normally.
  2. When resuming, it resumes on an unspecified thread.

So maybe it's worth changing even it breaks someone's code.

P.S. We should also change this in tests, as I mentioned here: https://youtrack.jetbrains.com/issue/COMPOSE-1290/LaunchedEffect-run-in-composition-phase-in-tests

@igordmn What do you think?

m-sasha avatar May 13 '24 09:05 m-sasha

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

okushnikov avatar Jul 14 '24 14:07 okushnikov