<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rishi on Medium]]></title>
        <description><![CDATA[Stories by Rishi on Medium]]></description>
        <link>https://medium.com/@rishikamaljha?source=rss-7b4598eb126b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*YLpsTTpqVFoIhajt</url>
            <title>Stories by Rishi on Medium</title>
            <link>https://medium.com/@rishikamaljha?source=rss-7b4598eb126b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 01:51:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rishikamaljha/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Testing Android UI Performance- Part2]]></title>
            <link>https://engg.glance.com/testing-android-ui-performance-part2-46a3afa88a8a?source=rss-7b4598eb126b------2</link>
            <guid isPermaLink="false">https://medium.com/p/46a3afa88a8a</guid>
            <category><![CDATA[perfetto]]></category>
            <category><![CDATA[ui-performance]]></category>
            <category><![CDATA[android-performance]]></category>
            <category><![CDATA[systrace]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[Rishi]]></dc:creator>
            <pubDate>Thu, 13 Oct 2022 09:20:49 GMT</pubDate>
            <atom:updated>2022-10-13T09:20:49.208Z</atom:updated>
            <content:encoded><![CDATA[<p>This is Part 2 of the 3-part series on <em>Testing Android UI performance</em>. In the <a href="https://engg.glance.com/testing-android-ui-performance-e70645f2853d"><em>previous blog</em></a> we saw how Profile <em>HWUI rendering</em> and <em>dumpsys gfxinfo </em>is used to get the frame rate, the number of janky frames, missed vsync, and the time spent at various stages of the rendering pipeline. Once we know that there is lag/jank in the application then next is to find the place and event where the jank has occurred.</p><p>In this part, we will go deeper to find the cause of jank using various tools like systrace, perfetto and custom trace events.</p><h4><strong>Systrace</strong></h4><p><a href="https://developer.android.com/topic/performance/tracing">Systrace</a> is a legacy platform-provided command-line tool that records device activity. The systrace is broken up by processes and threads.</p><h4><strong>Capturing Systrace</strong></h4><p>System traces can be captured from the command line or in the device itself. Find out how to capture systrace from a command line <a href="https://developer.android.com/topic/performance/tracing/command-line">here</a> . From Android 9(API level 28), traces can be recorded directly from a test device itself, without needing to plug in the device and connect to it over ADB, details for that can be found <a href="https://developer.android.com/topic/performance/tracing/on-device">here</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dFi-M79sUpsOxQvE6CTU0g.png" /><figcaption>Figure 1: Systrace</figcaption></figure><p>Look for your app’s process in Systrace. Systrace shows when each frame is drawn and color codes each frame to highlight slow render times.</p><p>Few Tips</p><p>1. Select the frame (red color) which takes longer time to render and press M to get timeline ruler, navigate up and down to see work done by the system. zoom in by pressing W, continue zooming in until you start to see the trace events in the UI thread and RenderThread.</p><p>2. Look for alerts in Alert panel.</p><p>3. scroll to see the Kernel section, which shows CPU information. If you can see <em>HeapTaskDaemon f</em>or your app process,<em> </em>that means GC was happening<strong>.</strong></p><p>To get detailed information on how to navigate systrace, refer to this <a href="https://developer.android.com/topic/performance/tracing/navigate-report">document</a></p><h4><strong>Custom events</strong></h4><p>If systrace does not give enough information on which part of code is taking longer time on UI thread then we can add trace events in code and those trace events shows up as slices on timeline of systrace under your app section</p><p>Add <em>Trace.beginSection(“text which u want to see in trace”) </em>at the start and<em> Trace.endSection() </em>at the end .</p><p>Note: When you call beginSection() multiple times, calling endSection() ends only the most-recently-called beginSection() method</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f908f2a177278bded62f9ae82c31bf6/href">https://medium.com/media/1f908f2a177278bded62f9ae82c31bf6/href</a></iframe><p>Make these changes in the code and take systrace again to see the custom events in trace. To see your app method in trace use –<em>a </em>option while tracing.</p><p>Example : python systrace.py -a “*” -o customEventTrace.html</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pHulKjQcHs4wQj8wZDRV9w.png" /></figure><p>Clicking on the custom event slice you can see time taken for that view to be created. You can add these custom events in all methods where you suspect the issue.</p><p>Above trace shows that inflate is taking longer time, which means the app is spending time on inflating the layout. When you zoom into one of the inflate events, you can find out exactly how long each UI component is taking. This helps to zero in the component which takes longer time.</p><h4><strong>Perfetto</strong></h4><p>On a device running Android 10 (API level 29) or later, trace files are saved in <strong>Perfetto </strong>format. Perfetto is a platform-wide tracing tool introduced in Android 10. It offers a superset of data sources compared to Systrace and allows you to record arbitrarily long traces. You can open these traces in the <a href="https://ui.perfetto.dev/#!/">Perfetto UI</a> . Perfetto is recommended for devices running Android 10 and higher.</p><p>You can refer Perfetto docs to know different options to trace by perfetto from <a href="https://perfetto.dev/docs/quickstart/android-tracing">here</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qaIpHD6Md6kK6eGrn8aXsA.png" /></figure><p>You can search for the custom event text from the search box or you can zoom in and see those events. select that portion of the timeline to inspect more details.</p><p>Perfetto supports Trace Processor by which you can query the trace contents through SQL. Below is the query to search all occurrences of a particular custom event (“MyVideoFragment”)</p><pre>SELECT ts, dur, name FROM slice WHERE name LIKE &quot;%MyVideoFragment%&quot;;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GagRwzEATYoq8ezK0-8XeQ.png" /></figure><p>All the occurrences of queried events are listed above.</p><p>This whole process can be automated and can be part of a continuous testing cycle. Whenever a developer commits code, UI tests will be executed for that feature and Perfetto logs will be captured. Custom events can be queried from the Perfetto traces, if the duration of these events is above the benchmark, then same trace logs can be used for further analysis.</p><p>If you found the View/Fragment/Activity resulting in jank or bad UI performance and still need more information then CPU profiler can be used. We will cover that in our next blog.</p><h4><strong>References</strong></h4><ul><li><a href="https://developer.android.com/topic/performance/tracing">https://developer.android.com/topic/performance/tracing</a></li><li><a href="https://developer.android.com/topic/performance/vitals/render">https://developer.android.com/topic/performance/vitals/render</a></li><li><a href="https://developer.android.com/topic/performance/tracing/navigate-report">https://developer.android.com/topic/performance/tracing/navigate-report</a></li><li><a href="https://developer.android.com/topic/performance/tracing/custom-events">https://developer.android.com/topic/performance/tracing/custom-events</a></li><li><a href="https://perfetto.dev/docs/quickstart/android-tracing">https://perfetto.dev/docs/quickstart/android-tracing</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46a3afa88a8a" width="1" height="1" alt=""><hr><p><a href="https://engg.glance.com/testing-android-ui-performance-part2-46a3afa88a8a">Testing Android UI Performance- Part2</a> was originally published in <a href="https://engg.glance.com/">Glance</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing Android UI Performance]]></title>
            <link>https://engg.glance.com/testing-android-ui-performance-e70645f2853d?source=rss-7b4598eb126b------2</link>
            <guid isPermaLink="false">https://medium.com/p/e70645f2853d</guid>
            <category><![CDATA[ui-performance]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[android-performance]]></category>
            <dc:creator><![CDATA[Rishi]]></dc:creator>
            <pubDate>Tue, 14 Dec 2021 13:18:51 GMT</pubDate>
            <atom:updated>2022-01-13T05:59:11.536Z</atom:updated>
            <content:encoded><![CDATA[<p>Performance is the cornerstone of any mobile application. It is more so for applications such as Glance where visual experience is key. As an application evolves and scales, it is imperative that we consistently measure performance on incremental changes and give faster feedback to developers on the performance impact.</p><p>This article is going to discuss testing the UI Performance of Android applications.</p><h4><strong>Quantifying UI Performance</strong></h4><p>UI performance is measured in <strong>frames rendered per second(fps)</strong>. The benchmark for UI performance is <strong>60 fps</strong> (anything above this is not discernible to the human eye). To ensure smooth performance, we must consistently render frames at 60 fps. If the app suffers from slow UI rendering, then the system is forced to skip frames and the user will perceive stuttering/jank in the app.</p><p>Before we move into identifying janks, it is important that we become familiar with a few terminologies.</p><ul><li><strong>Frame rate</strong> or frames per second denotes the number of frames rendered in one second</li></ul><p>• <strong>Refresh rate</strong> is the number of times a device’s display can update in a second. It is measured in Hertz. 60 Hertz display can update 60 times per second</p><p>• <strong>Vsync stands for Vertical Synchronization</strong> Vsync signal synchronizes the display pipeline. Vsync is a way to ensure that the GPU’s frame rate is in sync with the display’s refresh rate.</p><p>If the frame rate is faster than the refresh rate, Vsync buffers the frame and renders it. There won’t be any negative impact except for Gaming Apps. When the frame rate is slower than the refresh rate, the user sees stutter/jank.</p><p><strong>Measuring UI Performance</strong></p><p>To fix the UI janks, it is important that we identify what causes the jank in the first place. UI performance can be measured in various levels of granularity. We start with the top view and with every level, we zoom in to the problematic area in the app.</p><p><strong><em>1000 feet view</em></strong></p><p>The first step is to measure the frame rate of the app. There are 2 ways in which we can achieve this — (a) Profile HWUI rendering (b) gfxinfo. Using these methods we get the frame rate, the number of janky frames, missed vsync, and the time spent at <a href="https://developer.android.com/topic/performance/rendering/inspect-gpu-rendering#gpu_rendering_output">various stages of the rendering pipeline</a> . Basis the results, we make decisions on the further steps.</p><p><strong><em>100 ft view</em></strong></p><p>The profiler output and dumpsys give information on a high level on whether there is a drop in the UI performance. To zero in on the cause of the performance drop, we need details at a more granular level as in the activity/fragment/method that is causing the drop. To achieve that, we can use a suite of other tools — Trace events, Systrace, Perfetto.</p><p><strong><em>10 ft view</em></strong></p><p>If Systrace does not show details on why UI thread work takes a long time, then we use Android CPU Profiler to record either a sampled or instrumented method trace which can locate the view or the xml which is causing the drop in performance</p><p><strong>Measuring at High Level — Profile HWUI rendering (1000 ft view)</strong></p><p>The Profile HWUI Rendering tool displays as a scrolling histogram, a visual representation of the time it takes to render the frames of a UI window. This relative to a benchmark of 16ms per frame.</p><p>We can perform the key user journeys and check where the bars are with respect to the benchmark. This helps to identify in which screens and flows the rendering crosses the benchmark.</p><p>To enable Profile GPU rendering, go to Developer Options and enable the Profile HWUI Rendering under the Monitoring section.</p><figure><img alt="HWUI rendering profiler for Glance app" src="https://cdn-images-1.medium.com/max/650/1*ieUgstbYQReC5QNfeHXyxA.png" /><figcaption>HWUI rendering profiler for Glance app</figcaption></figure><ul><li>Each vertical bar along the horizontal axis represents a frame, and the height of each vertical bar represents the amount of time the frame took to render (in milliseconds).</li><li>The horizontal green line represents 16 milliseconds.</li><li>Each bar has colored components that map to a stage in the rendering pipeline. Each color in vertical bars represents a rendering stage which gives us details to debug further.</li></ul><p><strong><em>Gfxinfo</em></strong></p><ul><li>For analysis and comparison of the performance across builds, what we view in the profiling tool should be quantified. Gfxinfo of dumpsys tool dumps the graphics information of the app under test. It provides information on the janky frames, time taken for frames to render, and time steps at various stages of the rendering pipeline.</li><li>The command below is used to capture graphics information.</li></ul><p><strong><em>adb shell dumpsys gfxinfo &lt;PACKAGE_NAME&gt;</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*hNkqISBkq31hjcMUe2b35A.png" /><figcaption>dumpsys gfxinfo output.</figcaption></figure><p>In the above image, the 99th percentile denotes that 99% of frames were rendered within 24 milliseconds. This means that FPS for the 99th percentile is 1000/24 = 41.6</p><p><strong>Steps to perform the test</strong></p><p>To measure the gfxinfo of any app, perform the following steps:</p><p>Reset the previous dumpsys data by running the command</p><ol><li><em>adb shell dumpsys gfxinfo &lt;PACKAGE_NAME&gt; reset</em></li><li><em>Perform the flows that needs to be tested</em> in the App under test.</li><li><em>Dump the gfxinfo by using the command below. </em>The dump will have the frame rate and the other information.</li></ol><p><em>adb shell dumpsys gfxinfo &lt;PACKAGE_NAME&gt;</em></p><p><strong>Faster and Reliable Feedback</strong></p><p>One approach to UI Performance testing is to simply have a test engineer perform this test manually. But this could be time-consuming, tedious, and error prone.</p><p>A more efficient approach is to automate this complete flow. Wiring these automated tests to PR merge gives immediate feedback to developers on the performance of their code</p><p>We can see how to measure performance and detect issues at a finer granular level in the subsequent parts of the article.</p><p>In the <strong>2nd part</strong>, we will talk about the 100 ft view where we will talk about how to add trace events and query the same using <strong>Perfetto</strong>, what to look for in the <strong>systrace</strong>. Here, we will spot which Activity/Fragment has issues.</p><p>In the <strong>3rd part</strong>, we will talk about the 10 ft view. Here, we will talk about how to spot the problematic views within a fragment.</p><p><strong>References:</strong></p><p><a href="https://developer.android.com/training/testing/performance">https://developer.android.com/training/testing/performance</a></p><p><a href="https://developer.android.com/topic/performance/rendering/inspect-gpu-rendering">https://developer.android.com/topic/performance/rendering/inspect-gpu-rendering</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e70645f2853d" width="1" height="1" alt=""><hr><p><a href="https://engg.glance.com/testing-android-ui-performance-e70645f2853d">Testing Android UI Performance</a> was originally published in <a href="https://engg.glance.com/">Glance</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>