Skip to content

Default delay behavior on Android creates additional threads when using external dispatchers #2972

Open
@adamp

Description

@adamp

When delay is called using an externally-defined dispatcher that does not implement the internal Delay interface, it uses a default fallback implementation that can cause an additional thread to be created. Some Android apps strictly audit threads created by their library dependencies and have raised this as an issue when using Jetpack Compose, which defines its own UI dispatcher and both promotes using the delay API and uses it internally.

On Android, apps always have a main thread running an event loop that could be used in place of creating an additional thread to time the delay, which could make Dispatchers.Main a suitable choice for performing the default delay on Android when a compatible/known dispatcher is not found.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions