androidperformanceandroid-profiler

Improving UI performance


I checked my UI with Android studio profiler (Recorded system trace) and I got following result: enter image description here As you can see here it takes 28ms for a frame to load when I open my fragment. Also we can see that almost all time is taken by traversal and measure. I tried to refactor my xml and now it looks like:

<MotionLayout>
    <SwiperefreshLayout>
        <NestedScrollView>
            <LinearLayout>
                <include
                 layout="cardView1">
                <include
                 layout="cardView2">
                //..........
                <include
                 layout="cardVie7">
            <LinearLayout>
        <NestedScrollView>
    <SwipeRefreshLayout>
<MotionLayout>

It's just complex UI with lots of nested cards which can have recycleview ot other content inside. After my refactoring there still some problems with the frame time as you can see. Is there a way improve my UI performance or maybe at least get more detailed info of what's wrong and why it takes so long to draw the UI?


Solution

  • After adding custom Trace events and profiling the app I found that the recyclerView items inflation takes almost all of the frame time. The problem was solved with using DiffUtil and RecyclerView Async Loading