Skip to content

DataBinding with state flow performance issue #3332

Open
@shamtay

Description

@shamtay

Hello!

We are observing the performance issues in the recyclerView when at least one view of the recycler view item layout is bound with
MutableStateFlow. To bind the first row of the recyler view it takes up to 150 ms and following items some times up to 10 ms and more vs 4 ms expected. We do not observe the issue when view is bound e.g. to MutableLiveData or String, binding takes about 2ms only in that cases

We added more details (including flame chart screenshot, logcat screenshot, etc.) to the sample app: https://github.com/shamtay/StateFlowIssue

Accoriding to profiler It looks like the problem is related to job cancelling, but it is not clear why it takes significant time.

It seems likes the cancelling happens in the Main.immediate dispatcher which blocks the UI thread, so probably pushing this to the end of thread's queue might be more reasonable.

issue in the android tracker https://issuetracker.google.com/issues/236524521

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