<?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[OkCredit - Medium]]></title>
        <description><![CDATA[Mobile Udhar Khata for small businesses in India - Medium]]></description>
        <link>https://medium.com/okcredit?source=rss----40ea5327aac7---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>OkCredit - Medium</title>
            <link>https://medium.com/okcredit?source=rss----40ea5327aac7---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 14:07:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/okcredit" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[OkLayoutInflater]]></title>
            <link>https://medium.com/okcredit/oklayoutinflater-3c5cd93c6ebc?source=rss----40ea5327aac7---4</link>
            <guid isPermaLink="false">https://medium.com/p/3c5cd93c6ebc</guid>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Anjal Saneen]]></dc:creator>
            <pubDate>Wed, 26 Oct 2022 01:27:02 GMT</pubDate>
            <atom:updated>2022-10-27T05:57:47.974Z</atom:updated>
            <content:encoded><![CDATA[<p>The loading of large XML layouts is one of the major performance bottlenecks in android. Loading XML layout into memory through IO operations and parsing views through reflection can be expensive. This is especially true when the XML file is too large or when initializing the layout view takes a while. We know that when the main thread performs some time-consuming operations, it may cause the page to freeze, and even more, serious ANR may occur. Androidx <a href="https://developer.android.com/reference/androidx/asynclayoutinflater/view/AsyncLayoutInflater">AsyncLayoutInflater</a> helps to load those layouts asynchronously. However, we found that it has some limitations. The goal of this blog post is to explain how <a href="https://github.com/okcredit/OkLayoutInflater">OkLayoutInflater</a> addresses these limitations.</p><h4><strong>Source code analysis of </strong>AndroidX <strong>AsyncLayoutInflater</strong></h4><p><a href="https://android.googlesource.com/platform/frameworks/support/+/89f7eba/v4/java/android/support/v4/view/AsyncLayoutInflater.java">https://android.googlesource.com/platform/frameworks/support/+/89f7eba/v4/java/android/support/v4/view/AsyncLayoutInflater.java</a></p><p>Source code is short and easy to understand with only a few lines of code. In the inflate method, it creates an InflateRequest object and stores variables such as resid, parent, callback, etc. Then it calls <a href="https://android.googlesource.com/platform/frameworks/support/+/89f7eba/v4/java/android/support/v4/view/AsyncLayoutInflater.java#91">enqueue</a> to add the request to the InflateThread queue. The main purpose of InflateThread is to add requests to the blocking queue and perform BasicInflater.inflate operations in order. Regardless of inflating success or failure, the request message will be sent to the main thread for processing.</p><p>The <a href="https://android.googlesource.com/platform/frameworks/support/+/89f7eba/v4/java/android/support/v4/view/AsyncLayoutInflater.java#121">BasicInflater</a> Inherited from LayoutInflater. In OnCreateView <a href="https://android.googlesource.com/platform/frameworks/support/+/89f7eba/v4/java/android/support/v4/view/AsyncLayoutInflater.java#122">these prefixes</a> are loaded on the layout. At last, mHandlerCallback implements <em>handleMessage</em> which executes the operation on main thread, and there is a fallback mechanism, that is when the child thread inflates fails. it will continue to inflate on the main thread, and finally, gives a callback to the main thread through the <a href="https://android.googlesource.com/platform/frameworks/support/+/89f7eba/v4/java/android/support/v4/view/AsyncLayoutInflater.java#110">OnInflateFinishedListener</a> interface.</p><h4>The limitations of AsyncLayoutInflater and how we improve it</h4><ul><li><strong>Single thread to do all the inflate work</strong><br><a href="https://developer.android.com/reference/androidx/asynclayoutinflater/view/AsyncLayoutInflater">AsyncLayoutInflater</a> has this major limitation. This was the main reason for creating a custom implementation. One of our recycler view items took a long time to inflate. The Androidx AsyncLayoutInflater offloads from the main thread but runs sequentially in the background thread. Therefore, it does not help us save time. The implementation was changed to coroutine with default dispatch, which has the maximum parallelism equal to the number of CPU cores. As a result, the recycler view will load and scroll faster. Here are the systrace images 3 implementations mentioned above.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wku4OqgcLDbojwrdmlSONw.png" /></figure><ul><li><strong>Inflatework is not </strong><a href="https://developer.android.com/topic/libraries/architecture/lifecycle"><strong>lifecycle aware.</strong></a><strong><br></strong>The inflate work cannot be controlled once it has been scheduled with andriodx inflate. Inflating callbacks can result in crashes if the user closes the page before the work is complete. Coroutines allow us to control the inflation of work jobs and cancel the context of lifecycle events. Thanks to <a href="https://github.com/ItzNotABug">ItzNotABug</a> for <a href="https://github.com/okcredit/OkLayoutInflater/pull/3">Auto Cancellation support</a>.</li><li><strong>Does not support </strong><a href="https://developer.android.com/reference/android/view/LayoutInflater.Factory2"><strong>LayoutInflater.Factory2.</strong></a><br>This inflater does not support setting a LayoutInflater.Factory nor LayoutInflater.Factory2. We are manually setting Factory2 with custom implementation</li><li><strong>The default size limit of the cache queue is 10. If it exceeds 10, it will cause the main thread to wait.<br></strong><a href="https://android.googlesource.com/platform/frameworks/support/+/89f7eba/v4/java/android/support/v4/view/AsyncLayoutInflater.java#166">here</a> you can see async inflate thread queue is using ArrayBlockingQueue with size is 10. If the job exceeds 10, the main thread will wait. It has been replaced by a coroutine.</li></ul><h4>OkLayoutInflater 🎉</h4><p>We’ve seen the limitations of AsyncLayoutInflater above. This is an enhanced version of AsyncLayoutInflater with a coroutine.</p><p><a href="https://github.com/okcredit/OkLayoutInflater">GitHub - okcredit/OkLayoutInflater: Improved version of Androidx AsyncLayoutInflater</a></p><h4><strong>How we use OkLayoutInflater in Fragments</strong></h4><pre>private val okLayoutInflater by lazy { OkLayoutInflater(this) }<br><br>override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {<br>    val loadingView = inflater.inflate(R.layout.loader_view, container, false)<br>    okLayoutInflater.inflate(contentLayoutId, container) { inflatedView -&gt;<br>        (loadingView as? ViewGroup)?.addView(inflatedView)<br>    }<br>    return loadingView<br>}</pre><p>Inflating layout asynchronously has the caveat that view access can only be granted after inflate is complete. Therefore, we should avoid view access in onResume, onViewCreated, etc. We use the MVI architecture. The data flow on MVI will be unidirectional, and all view access will occur via a single render function and view events for handling side effects. During the inflate process, all render methods are cached until the view is fully inflated. As a result, we were able to implement async inflate seamlessly on all the critical screens and reduce frozen frames by ~30% on some screens. It was a huge return on our investment. The following diagram illustrates how it works on MVI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QQTUwicCFsSObPqTrkIYhw.png" /></figure><h4><strong>How we use OkLayoutInflater in RecyclerView</strong></h4><pre>private val okLayoutInflater by lazy { OkLayoutInflater(this) }<br><br>override fun onAttachedToWindow() {<br>    super.onAttachedToWindow()<br>    okLayoutInflater.inflate(R.layout.transaction_view, this) { inflatedView -&gt;<br>        removeAllViews()<br>        addView(inflatedView, LayoutParams.MATCH_PARENT)<br>    }<br>}</pre><p>Again, the view access should be avoided until the async inflate is completed.</p><h4>Results</h4><p><strong>RecyclerView</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bJDptDQxneaymfu1wg1bNA.png" /><figcaption>How Recyclerview loads before optimisation (The duration is in 90 percentile)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b2_FWYBwH2zFaG_ndi5jSQ.png" /><figcaption>After OkLayoutInflater</figcaption></figure><p><strong>Fragments/Activity</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mt_P56kHyARtjJiMZR1h9w.png" /><figcaption>The opening of a fragment before optimisation (The duration is in 99 percentile)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xas2ka0wIef0pSzgD_qgGA.png" /><figcaption>After OkLayoutInflater</figcaption></figure><h4>Final Thoughts</h4><p>I hope you find our experience useful in helping to load the layout asynchronously and improve rendering performance. We are able to reduce our frozen frame metric by 23% by inflating the layout asynchronously. While using AndroidX, we faced numerous challenges, which we solved by implementing a custom implementation. We are open-sourcing the library for everyone. Feel free to open pull requests and issues. Inflating layout asynchronously comes with a caveat. view access can only be granted after inflate has been completed. Hence, there is a trade-off between performance, stability, and developer experience.</p><p>Layout inflate is not a concern with Jetpack compose. Layouts in compose are written in Kotlin and compiled just like the rest of your app. Our experience with Jetpack compose has been positive so far, so we would strongly recommend it. <a href="https://medium.com/okcredit/comparing-jetpack-compose-performance-with-xml-9462a1282c6b">Here is the blog post</a> about Comparing Jetpack compose performance with XML.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c5cd93c6ebc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/okcredit/oklayoutinflater-3c5cd93c6ebc">OkLayoutInflater</a> was originally published in <a href="https://medium.com/okcredit">OkCredit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Comparing Jetpack Compose performance with XML]]></title>
            <link>https://medium.com/okcredit/comparing-jetpack-compose-performance-with-xml-9462a1282c6b?source=rss----40ea5327aac7---4</link>
            <guid isPermaLink="false">https://medium.com/p/9462a1282c6b</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[Pratham Arora]]></dc:creator>
            <pubDate>Tue, 09 Aug 2022 05:41:24 GMT</pubDate>
            <atom:updated>2022-08-09T16:15:04.665Z</atom:updated>
            <content:encoded><![CDATA[<p>As Jetpack compose is progressing towards stability, our team decided to measure the performance differences between Compose and XML-based layouts to build the foundation for gradually moving towards Jetpack compose. The differences were measured in terms of <a href="https://developer.android.com/topic/performance/vitals/frozen">frozen frames</a>, <a href="https://developer.android.com/topic/performance/vitals/render">slow frames</a> and <a href="https://medium.com/okcredit/screen-response-time-a-critical-metric-for-user-experience-fc2be922859f">page load duration</a>. Additionally, we deep-dived into how Android Runtime (ART) optimises the performance by using Ahead-of-time (AOT) compilation.</p><p>Both the below-mentioned experiments were performed on <a href="https://medium.com/androiddevelopers/why-should-you-always-test-compose-performance-in-release-4168dd0f2c71">Production build with R8 enabled</a>. Compose version used throughout was <a href="https://developer.android.com/jetpack/androidx/releases/compose-ui#1.1.0">1.1.0</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iAXiRMTXIQoD5gwP1-Bxow.png" /></figure><p>Let’s get started…</p><h3>Experiment — 1</h3><p>To begin with, we decided to convert one of the existing screens from XML to compose. Then, using our internal A/B experimentation platform, we made 2 equal cohorts/groups of users. The first cohort would experience the old XML-based screen whereas the other cohort would experience the newly compose built screen.</p><p><strong>Aim — </strong>To understand the rendering performance of both the screens by comparing frozen frame rate, slow frame rate and page load duration.</p><p><strong>Screen — </strong>This screen shows all the transactions as well as their summary in an interval.</p><figure><img alt="Compose layout compared with XML layout" src="https://cdn-images-1.medium.com/max/1024/0*oRsghrqyddLeCQuh.png" /></figure><p><strong>Results -</strong></p><p><a href="https://developer.android.com/topic/performance/vitals/frozen">Frozen frame</a> percentage:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4amXSHjnDxenaRVik2HUUw.png" /></figure><p>For compose-based layout, the frozen frame rate came out to be 0.044% whereas it was 0.034% for XML-based layout. An alternate way to understand this can be, that if we open this XML-based activity, then nearly 3.4 frames out of 10,000 frames would fall under the frozen frame category. Similarly, for the compose-based activity, it would be 4.3 frames out of 10,000 frames.</p><p><a href="https://developer.android.com/topic/performance/vitals/render">Slow frame</a> percentage:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7we4GDZ1NHZ3O8mrNGwsXQ.png" /></figure><p>For compose-based layout, the slow frame rate came out to be 8.91% whereas it was 9.93% for XML-based layout. Like frozen frames, ~10 out of 100 frames would fall under the slow frame category for XML-based layout. Whereas it was ~9 out of 100 frames for compose-based activity.</p><p>Median <a href="https://medium.com/okcredit/screen-response-time-a-critical-metric-for-user-experience-fc2be922859f">Page Load Duration</a> (in milliseconds):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HhtVd-4C3o9xB01NlJ2kEQ.png" /></figure><p>Internally, we define page load duration as the time taken from launching an activity to drawing its first frame. Compose-based layout nearly took 2.5x the time than the XML-based layout.</p><h3>Understanding the reason behind these metrics</h3><p>In order to understand insights, we deep-dived into how Android Runtime (ART) works under the hood. Before jumping onto it, let’s get familiar with some basic terminologies:</p><p><strong>Just-in-time (JIT)</strong> — Each time when we run the app, the compiler interprets the code on the fly and converts the dex bytecode into machine code.</p><p><strong>Ahead-of-time (AOT)</strong> — During the app installation phase, the compiler statically translates the dex bytecode to machine code and stores it in the device’s storage to avoid overheads while the app is being used.</p><p>More details can be found <a href="https://developer.android.com/topic/performance/baselineprofiles">here</a>.</p><p><strong>Key understandings from the first experiment -</strong></p><p>Internally, ART uses a combination of JIT and AOT to interpret dex bytecode. Also, it is our intuition that most of the components used for XML-based layouts are compiled ahead-of-time by the compiler whereas compose components, just like our code, are compiled just-in-time. Since, the compose components are unbundled on the fly, it might be taking a significant amount of time to render the layout. In order to validate the idea, we moved toward the next experiment.</p><p>You can understand more about how ART works from <a href="https://www.youtube.com/watch?v=eDcGrY_AVlw&amp;t=4930s">here</a>. Let’s understand what we tried in the next experiment…</p><h3>Experiment — 2</h3><p>In order to measure the change in metrics, we converted the screen just previous to the above experiment’s screen to compose. So, the group of users, who experienced the compose-based layout under the first experiment, will again experience the compose-based layout for the previous screen. Similarly, the other group would experience XML-based layouts.</p><p><strong>Aim — </strong>To analyse the performance differences of the first experiment’s screen once some compose components are pre-compiled by the compiler.</p><p><strong>Screen — </strong>The screen, previous to the first experiment’s screen, gives a quick summary of customer and supplier balances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/0*zjJC_DhEq9rH3zyb.png" /></figure><p><strong>Results -</strong></p><p><em>Note: We measured frozen frame percentage, slow frame percentage and page load duration for the same screen which was under the first experiment’s observation.</em></p><p>Frozen frame percentage:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rAGDazEx5MLqOlN3T2j1Og.png" /></figure><p>Slow frame percentage:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S77wAquDxwaYkBU6nihABQ.png" /></figure><p>Median Page Load Duration (in milliseconds):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cCycZ1I5q06s4xX94ZLF9Q.png" /></figure><p><strong>Key Takeaways -</strong></p><p>On comparing the results with the previous experiment, we figured out a few really interesting insights. Let’s go over them one by one:</p><ol><li>The frozen frame rate of the screen, under observation, dropped drastically once its previous screen loaded compose components for it.</li><li>We saw an improvement from ~60% for the frozen frame rate. (Both are similar) Also, compose layout performed ~4% better in terms of slow rendering.</li><li>Page load duration improved by ~35% as the compiler had unbundled major compose components for rendering.</li></ol><p>Based on the results of this experiment, we can confidently say that our intuition at the end of the first experiment was in the right direction. Compose components are interpreted just-in-time during the initial rendering but internally, ART understands the function logs and pre-compiles the classes whenever we need them next.</p><h3>Final thoughts</h3><p>Let’s briefly go over the latest metrics to conclude our discussion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g9ubawqBl0ERLhpVZ2V2qA.png" /></figure><p>After preloading compose we saw a 70% reduction in frozen frames and a 35% reduction in median page load duration. Currently, we have rolled out the compose screens to all the users and we expect the metrics to improve further.</p><p>To conclude our discussion, we were able to prove our hypothesis of ART, which uses a combination of JIT and AOT, was able to efficiently load the screen, under observation, once the compose components are pre-compiled. Components used by XML layouts are always pre-compiled and hence, bound to perform well. But on the positive side, Jetpack compose has its own benefits of improving the performance as more and more components are interpreted ahead-of-time.</p><p>Not only focusing on the performance gains, but Jetpack compose has also improved the dev acceleration by providing modular and intuitive declarative APIs. With time, we got more familiar with compose and understood how it helps in effectively creating complex yet modular UI components. We, at OkCredit, definitely recommend you to use Jetpack Compose.</p><p>We hope that our experience will be valuable in helping you to understand the performance difference between XML and jetpack compose. If you have any further questions regarding the experiment, please do not hesitate to ask in the comment section. Thanks for reading.</p><h3>Bonus section</h3><p>We are measuring per-frame durations using the <a href="https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator">FrameMetricsAggregator</a> API, we measure each frame’s duration from OnStart to OnStop for each fragment, and count total frames, total frozen frames (700ms+), and total slow frames (16ms+).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb4b6e3ad2cc783b56e07f113b81ebec/href">https://medium.com/media/cb4b6e3ad2cc783b56e07f113b81ebec/href</a></iframe><p><strong>References -</strong></p><ol><li><a href="https://engineering.premise.com/measuring-render-performance-with-jetpack-compose-c0bf5814933">https://engineering.premise.com/measuring-render-performance-with-jetpack-compose-c0bf5814933</a></li><li><a href="https://medium.com/androiddevelopers/why-should-you-always-test-compose-performance-in-release-4168dd0f2c71">https://medium.com/androiddevelopers/why-should-you-always-test-compose-performance-in-release-4168dd0f2c71</a></li><li><a href="https://android-developers.googleblog.com/2022/01/improving-app-performance-with-baseline.html">https://android-developers.googleblog.com/2022/01/improving-app-performance-with-baseline.html</a></li><li><a href="https://developer.android.com/jetpack/compose/ergonomics">https://developer.android.com/jetpack/compose/ergonomics</a></li><li><a href="https://www.youtube.com/watch?v=eDcGrY_AVlw">Jetpack compose performance talk with Leland Richardson</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9462a1282c6b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/okcredit/comparing-jetpack-compose-performance-with-xml-9462a1282c6b">Comparing Jetpack Compose performance with XML</a> was originally published in <a href="https://medium.com/okcredit">OkCredit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How OkCredit android app improves UX writing by changing strings on the fly (and you can too!)]]></title>
            <link>https://medium.com/okcredit/how-okcredit-android-app-improves-ux-writing-by-changing-strings-on-the-fly-and-you-can-too-8f38da8e69b9?source=rss----40ea5327aac7---4</link>
            <guid isPermaLink="false">https://medium.com/p/8f38da8e69b9</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[ux-writing]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Rashanjyot Singh]]></dc:creator>
            <pubDate>Wed, 13 Jul 2022 06:31:23 GMT</pubDate>
            <atom:updated>2022-07-14T06:29:53.162Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>How OkCredit Android App improves UX writing by changing strings on the fly (and you can too!)</strong></h3><figure><img alt="Dynamic string updates on the fly, without any app releases" src="https://cdn-images-1.medium.com/max/700/1*lFU3Q4fY8VFjVOl6zTDzlg.gif" /></figure><h3>Foreword</h3><blockquote>⚠️ First things first! We don’t want to make any false claims, and to tell you straight off, you cannot update the strings stored as XML resources in your android app. However, we are here to tell you how we achieved that effect in <a href="https://play.google.com/store/apps/details?id=in.okcredit.merchant&amp;hl=en_IN&amp;gl=US">OkCredit android app</a> by using ‘<a href="https://github.com/JcMinarro/Philology">Philology</a>’, an open-source android library.</blockquote><p><a href="https://play.google.com/store/apps/details?id=in.okcredit.merchant&amp;hl=en_US&amp;gl=US">OkCredit</a> is a digital ledger app used by millions of small business owners and their customers daily to facilitate the recording of credit/payment transactions digitally all over India.</p><p>The app supports over 11 different languages and to cater to such a diverse userbase, one key aspect is to communicate effectively. A pain point often shared by our product managers and language localization teams was that each time we wanted to experiment with strings, change/update them or make changes to translations of specific languages, we had to release a new version of the app.</p><p>Hence, we wanted to have a setup that would enable us to <strong>experiment with strings faster and update them on the fly</strong> <strong>without releasing a new version of the app.</strong></p><h3>Let’s Get Started</h3><p>Like most apps, OkCredit app uses a lot of XML string resources, and an ideal implementation to set up string experimentation would be one that requires the bare minimum amount of changes in the way we conventionally fetch strings, which is using getString(...) method of the Resources class.</p><p>The android developer community is amazing and that’s what we realized yet again when we instantly found exactly what we needed. We figured out quite a few technical blogs and a couple of open-source libraries that explained the underlying mechanism well (hence, we won’t do that much herein and simply share the relevant links).</p><p>However, to build conviction that it could run flawlessly at scale, we needed to pilot the solution first-hand. <strong>After using it for numerous experiments to improve the experience for millions of our users, with this blog we wish to share:</strong></p><ol><li><strong>Primarily, a case study of one of the experiments at OkCredit and insights indicating the solution’s reliability.</strong></li><li><strong>A brief technical overview of our setup for string experimentation.</strong></li></ol><h4>a) Usecase</h4><p>OkCredit app has a ledger screen for customers and suppliers wherein a merchant can record credit/payment transactions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*xgM1x8Bgn0sNbOs5RV6nDQ.png" /></figure><p>The texts in the <strong>above image</strong> (‘<strong>Payment</strong>’ and ‘<strong>Credit</strong>’) are localized based on the user’s language preference. Based on specific insights, we wanted to experiment with different terms across different languages to understand their impact on ‘user activation’, which we’ll soon have a look at in the upcoming sections.</p><h4>b) Test variants for experiment</h4><p>Our language localization team designed multiple test variants for different languages. Here’s a glimpse:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*G0uy9kYK9Dfdx7CFvOyNHA.png" /></figure><p>For this case study, we will focus only on the cohort of users who selected ‘English’ as their preferred language.</p><h4>c) Cohort Selection &amp; Design:</h4><p>Based on metrics such as conversion rate, number of test variants, daily visitors etc., we aimed to experiment with a cohort size of ~60K users over a test duration of ~10 days to confirm if there was a significant impact.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m4jm0HfEwZZoX11_iI248w.jpeg" /></figure><h4>d) Success Metrics and Results:</h4><p><strong>‘User Activation’</strong> was the primary metric for this experiment, wherein a new user is deemed ‘activated’ given he/she completes the following steps in the app:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*XtuhPwz9oXOhQFWAmjVjZQ.png" /></figure><p>With an almost equal distribution of users amongst the variants, we found a significant <strong>1.7% increase in the user activation rate</strong> for the test variant over the control variant.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VfIjpBvRbGJpV_pX0ymyvg.png" /></figure><h3>Technical Overview</h3><p>To achieve this, we used an open-source library, ‘<a href="https://github.com/JcMinarro/Philology">Philology</a>’, which allowed us to define a custom implementation of a data source, which would be used to fetch the updated strings. <strong>Under the hood, this mechanism works by intercepting the view inflation process to get the updated string values</strong>. The library has excellent <a href="https://github.com/JcMinarro/Philology#readme">documentation of the steps</a> required to integrate this into a project, and hence we recommend you follow the instructions from the same.</p><p><a href="https://github.com/JcMinarro/Philology">GitHub - JcMinarro/Philology: An easy way to dynamically replace Strings of your Android App or provide new languages Over-the-air without needed to publish a new release on Google Play.</a></p><p><strong>a) Defining custom data source implementation</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*flKebkU_fgIQn-zqlRBjTQ.png" /></figure><p>At its core, the setup needs an implementation of PhilologyRepositoryFactory, which can map to multiple PhilologyRepositoryinstances based on locale(s).</p><p>Each implementation of PhilologyRepository provides the updated value for the string key to be used if present, else returns null if the original value from XML string resources is to be used.</p><p>Each implementation of PhilologyRepository requires you to define your <strong>custom logic that returns the value</strong> <strong>used for a given string key</strong>. You may choose to fetch it from database(s), shared preferences, API call(s) or any other source(s) of data as you may like. In case you wish to use the original value as defined in XML, you can simply return null.</p><p>Then, all you need to do is to <a href="https://github.com/JcMinarro/Philology#inject-into-context">inject this setup into the context</a>, and voila! you are all set to get the updated string values using the conventional Resources.getString(...) function 🥳.</p><p><strong>b) A/B testing setup for experimentation</strong></p><p>Moreover, our custom implementation of the data source leverages a custom in-house <a href="https://www.oracle.com/in/cx/marketing/what-is-ab-testing/">A/B testing</a> setup that allows us to run experiments by selectively rolling them out to our desired cohort of users, set up control and test variants, and manage the distribution fractions amongst each variant.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X-8zF6EwU4Hr7_36lTrnDg.png" /></figure><p><strong>c) Minor issues &amp; a word of caution</strong></p><p>We faced an issue while upgrading to androidx.appcompat:appcompat:1.2.0, wherein the resource interception failed. However, this was fixed via a comment addressed in the issues —</p><p><a href="https://github.com/JcMinarro/Philology/issues/35#issuecomment-718007918">Appcompat version 1.2.0 breaks resource interception · Issue #35 · JcMinarro/Philology</a></p><blockquote><em>⚠️ </em>This highlights the problem of the library not being very actively maintained and that it may cause issues sooner or later, which may require some time to fix.</blockquote><blockquote><em>🚨 </em>Additionally, ‘Philology’ internally uses ‘<a href="https://github.com/InflationX/ViewPump/">ViewPump</a>’, a library to intercept view inflation, which also seemingly isn’t actively maintained at the time of writing this.</blockquote><p><a href="https://github.com/InflationX/ViewPump">GitHub - InflationX/ViewPump: View Inflation you can intercept.</a></p><p>However, based on our experience, we have found the library to be fairly stable throughout our extensive use for the past two years.</p><p>On the other hand, we recently came across another open-source library named ‘<a href="https://github.com/B3nedikt/restring">Restring</a>’, which seems to be pretty actively maintained at the time of writing this. Also, the author of the same has been relatively maintaining an active repo of <a href="https://github.com/B3nedikt/ViewPump">‘ViewPump’</a>, which extends the repo mentioned earlier. <strong>However, we haven’t evaluated it yet, but recommend you to do it if you’re starting out with this.</strong></p><ul><li><a href="https://github.com/B3nedikt/restring">GitHub - B3nedikt/restring: Restring is a android library to replace string resources dynamically</a></li><li><a href="https://github.com/B3nedikt/ViewPump">GitHub - B3nedikt/ViewPump: View Inflation you can intercept.</a></li></ul><h3>Conclusion</h3><p>We strongly feel that the developers of these libraries and authors of several blogs online have already done a great job at explaining the nitty-gritty and to get started with implementation, we recommend you to go through the README.md file of these repositories.</p><p>We primarily wanted to share insights from an on-ground case study of ours, indicating the reliability of the solution. Now, if you are excited to run string experiments using this or in some other way, we’ve got our job done.</p><p><em>Thanks for making it till here and 👏 if this helped you.</em> <em>Feel free to reach out if you have any questions, suggestions or ideas.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f38da8e69b9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/okcredit/how-okcredit-android-app-improves-ux-writing-by-changing-strings-on-the-fly-and-you-can-too-8f38da8e69b9">How OkCredit android app improves UX writing by changing strings on the fly (and you can too!)</a> was originally published in <a href="https://medium.com/okcredit">OkCredit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How OkCredit Android App boosted Network Performance by 30%]]></title>
            <link>https://medium.com/okcredit/how-okcredit-android-app-boosted-network-performance-by-30-84109080c065?source=rss----40ea5327aac7---4</link>
            <guid isPermaLink="false">https://medium.com/p/84109080c065</guid>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[okcredit]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Shrey Garg]]></dc:creator>
            <pubDate>Thu, 07 Jul 2022 11:29:22 GMT</pubDate>
            <atom:updated>2022-07-07T11:29:22.754Z</atom:updated>
            <content:encoded><![CDATA[<p>Fast and reliable network communication is crucial for OkCredit mobile apps. Since the majority of our users belong to Tier-2/3 cities in India, flaky and unreliable network connection is one of the biggest challenges for us. In order to deliver a good user experience, our mobile apps need to have reliable and low-latency network connectivity.</p><p>While most resources we found describe how we can improve the overall time (start-end) of a network call, this article attempts to take a deep dive and talk about each step and how we can instrument and optimise each step of a network call in android apps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pk1d0x6_S-ykvmtyHHl8RA.png" /></figure><h3>Steps involved in a network call</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xWQLL5zVemhDe44VK5yHpQ.png" /><figcaption>Fig. Steps of a Network call. Ref — <a href="https://square.github.io/okhttp/features/events">https://square.github.io/okhttp/features/events</a></figcaption></figure><h4><strong>1. Call start</strong></h4><p>Called as soon as a call is enqueued or executed by a client. Ideally, this step should not consume any time unless there are any custom <a href="https://square.github.io/okhttp/features/interceptors/">Interceptors</a> added.</p><h4><strong>2. DNS</strong></h4><p>Involves the DNS Resolver translating the domain name into the corresponding identifier (the IP address).</p><h4><strong>3. Connection Start</strong></h4><p>Tries to acquire a secure connection (<a href="https://square.github.io/okhttp/4.x/okhttp/okhttp3/-handshake/">TLS handshake</a>) between the client and the server.</p><h4><strong>4. Connection End / Acquired</strong></h4><p>Invoked after a connection has been acquired for the call. After this, the communication of request and response payloads is started.</p><h4><strong>5. Request / Response / Headers</strong></h4><p>This is the step in which the actual communication of data happens. The <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods">HTTP method</a>, size of request / response payload, <strong>server latency / response time</strong>, etc. can greatly impact the time taken by this step.</p><h4><strong>6. Connection released</strong></h4><p>Invoked after a connection has been released for the call.</p><h4><strong>7. Call end</strong></h4><p>Invoked immediately after a call has completely ended.</p><h3>Pooled connection</h3><p><a href="https://square.github.io/okhttp/">OkHttp</a> has the capability to <a href="https://square.github.io/okhttp/3.x/okhttp/okhttp3/ConnectionPool.html">pool connections</a> with which it can skip various steps of a network call mentioned above, which in turn can greatly improve the application’s network performance, as existing connections can be reused.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q2w5wKNEvDIoxqGxmJTyCA.png" /><figcaption>Fig. Steps of a Network call with pooled connection</figcaption></figure><h3>Instrumentation of each step</h3><p>To determine the particular step(s) having a scope of improvement, we can instrument each step to know exactly how much time it is taking.</p><p>We can make use of the <a href="https://square.github.io/okhttp/3.x/okhttp/okhttp3/EventListener.html">EventListener</a> class for listening to metrics for each step. EventListener is an abstract class for metrics events. We can monitor the quantity, size and duration of HTTP calls. It is recommended that the metric callback methods should be <strong>lightweight</strong>, execute <strong>fast</strong> and perform any I/O operations <strong>asynchronously</strong>.</p><p>By overriding various callback methods, we can calculate the metrics for each step of a network call efficiently. Some of the important methods that can be overridden are :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ig7ETYu0ZTuBGe207q317g.png" /><figcaption>Some important callback methods to be overridden for metrics</figcaption></figure><p>Note — there are a few more callbacks that can be used for detailed metric analysis.</p><h4>Instrumenting on Production</h4><p>There can be various factors affecting network performance on production. Instrumenting in a controlled environment might not give the actual metrics, hence, rather than testing network performance using local tools, it might be a good idea to enable instrumentation on a <a href="https://en.wikipedia.org/wiki/Sampling_(statistics)">sampled</a> set of production users.</p><p>This can give metrics across various types of environments, such as :</p><ul><li>Network operators / Wifi</li><li>Geographical regions</li><li>Device manufacturers</li><li>Application state (Background/Foreground)</li><li>Android OS version, etc.</li></ul><h3>Calculation of network performance metrics</h3><p>Time taken by different events, eg. connection start -&gt; connection end, request body start -&gt; request body end, etc., can be calculated by checking the difference between the start and end callback of that event. All start, connect, and acquire events will eventually receive a matching end, release event, either successful or failed.</p><p>An example of the same is shown below :</p><pre>class NetworkCallEventListener : EventListener() {<br>    private var callStartMillis: Long<br><br>    private fun printEvent(eventName: String) {<br>        val currentTimestamp = System.currentTimeMillis()<br>        if (eventName == &quot;callStart&quot;) {<br>            callStartMillis = currentTimestamp<br>        }<br>        val elapsedMillis = currentTimestamp - callStartMillis<br>        <em>println</em>(&quot;$elapsedMillis ms : $eventName&quot;)<br>    }<br><br>    override fun callStart(call: Call) {<br>        printEvent(&quot;callStart&quot;);<br>    }<br><br>    override fun callEnd(call: Call) {<br>        printEvent(&quot;callEnd&quot;);<br>    }<br><br>}</pre><p>The gist mentioned below can be used for logging network performance metrics :</p><blockquote><a href="https://gist.github.com/okshrey/fbe6349b888eba4c36e73745f9c5d2e0"><strong>https://<em>gist.github.com</em>/okshrey/fbe6349b888eba4c36e73745f9c5d2e0</strong></a></blockquote><h4>Usage</h4><p>Create an instance of <a href="https://gist.github.com/okshrey/fbe6349b888eba4c36e73745f9c5d2e0"><em>NetworkCallEventListener.kt</em></a> in <a href="https://square.github.io/okhttp/4.x/okhttp/okhttp3/-ok-http-client/-builder/event-listener-factory/"><em>eventListenerFactory</em></a> inside OkHttpClient.Builder(), as shown below —</p><pre>OkHttpClient<br>    .Builder()<br>    .<em>apply </em><strong>{<br>        </strong>eventListenerFactory <strong>{ <br>            </strong>NetworkCallEventListener(analyticsProvider) <br>        <strong>}<br>        </strong>callTimeout(...)<br><strong>        </strong>...<br>     <strong>}</strong></pre><h3>Areas of improvement we identified</h3><h4>- Use a single instance of OkHttp throughout the app</h4><p>In a multi-module android application, a common mistake is to create multiple OkHttp instances for each module. Doing so can be detrimental to the network performance, since each OkHttp instance will have a separate connection pool, and will not be able to take advantage of a pooled connection present at another instance.</p><h4>- Fine-tune OkHttp Connection Pool</h4><pre>class ConnectionPool constructor(<br>    maxIdleConnections: Int,<br>    keepAliveDuration: Long,<br>    timeUnit: TimeUnit<br>)</pre><p>Optimal values for <em>keepAliveDuration</em> and <em>maxIdleConnections</em> can substantially improve network performance, as existing connections can be reused. The value for <em>keepAliveDuration</em> should ideally be the same at the client and server for optimal results. Use OkHttp Connection Pool with caution, having too high values for maxIdleConnections, keepAlive might end up in wastage of resources.</p><p>Since the connection step occurs at the client, its instrumentation cannot be done on the server. Hence, instrumenting and optimising it at the client is crucial.</p><h4>- Avoid I/O operations in Interceptors</h4><p>There are a lot of operations apps might want to perform in network interceptors. While having lightweight operations is fine, any kind of I/O operation should be avoided. A common practice that might lead to poor network performance, is attaching Authentication Tokens (retrieved using an I/O operation) to network requests.</p><h4>- Avoid having multiple API hosts</h4><p>When using microservice architecture, often different microservices can have different API host names, which will in turn require the app to call APIs at different hosts for each use case. Using multiple hosts in the app might result in the DNS step taking a longer time. To optimise this, it is recommended to have a single API host.</p><h4>- Auto-retry call on API failure</h4><p>To avoid non-idempotent API failures, such as timeout, server error, etc, a recommended trick is to add an Interceptor with automatic retries on API failures. This can be further improved by adding special handling for specific types of failures and adding appropriate delays in between retries.</p><h4>- Use QUIC</h4><p><a href="https://blog.cloudflare.com/the-road-to-quic/">QUIC</a> is a​ UDP-Based Multiplexed and Secure Transport. Using QUIC can optimise the connection acquisition step. Few apps like <a href="https://eng.uber.com/employing-quic-protocol/">Uber</a>, YouTube have been using QUIC and have seen improved network performance. Unfortunately, till the time of writing this article, <a href="https://github.com/square/okhttp/issues/907">OkHttp has not added support for QUIC</a>. An alternative that can be used is <a href="https://github.com/google/cronet-transport-for-okhttp/blob/master/README.md">Cronet</a>.</p><h4>- Adjusting DNS TTLs</h4><p>DNS TTL (Time To Live) is a setting that tells the DNS resolver how long to cache a query before requesting a new one. The information received is cached in the recursive or local resolver for the time specified in the TTL before it reaches out for new / updated details. Fine-tune this value so that the frequency for querying is minimised and updates are quickly propagated.</p><p>Other potential action items —</p><ul><li>Identify and fix <strong>high-latency</strong> APIs</li><li>Add <strong>Pagination</strong> to APIs</li><li>Use <a href="https://github.com/google/brotli"><strong>Brotli</strong></a> instead of Gzip compression</li><li>Test with <strong>hardcoded</strong> IP address</li><li><a href="https://square.github.io/okhttp//features/caching/">Response caching</a></li><li><a href="https://square.github.io/retrofit/2.x/retrofit/retrofit2/Converter.Factory.html">Converter Factory</a> — Use <strong>Moshi</strong> instead of Gson</li></ul><h3>Overall Impact</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B2k_mCAtRmALeWUrXiT0BA.png" /><figcaption>Before and after comparison of average time taken by network calls</figcaption></figure><p>After implementing some of the action items mentioned before, we were able to see an overall improvement of about <strong>30% </strong>in the average time taken by network calls, with a major improvement of <strong>70%</strong> in the Connection Start to Connection Acquired step.</p><p>Most engineers consider network performance as something that can only be optimised at the backend, however, there are plenty of optimisations that can be made at the client, that can critically impact the network performance.</p><blockquote>Credits to the entire Android team at OkCredit for making the OkCredit app better everyday — <a href="https://medium.com/u/6bd3bb208cdf">Nishant Shah</a>, <a href="https://medium.com/u/f16393a53557">Rashanjyot Singh</a>, <a href="https://medium.com/u/a444e64946c0">Mohitesh</a>, <a href="https://medium.com/u/71a420fd12b1">Harshitfit</a>, <a href="https://medium.com/u/2cf3c5aea38f">Pratham Arora</a>, <a href="https://medium.com/u/894b3b833587">Manas Yadav</a>, <a href="https://medium.com/u/a1273217c219">Saket Dandawate</a>, <a href="https://medium.com/u/cf6b0c2affc4">Anjal Saneen</a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84109080c065" width="1" height="1" alt=""><hr><p><a href="https://medium.com/okcredit/how-okcredit-android-app-boosted-network-performance-by-30-84109080c065">How OkCredit Android App boosted Network Performance by 30%</a> was originally published in <a href="https://medium.com/okcredit">OkCredit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Screen response time. A critical metric for user experience]]></title>
            <link>https://medium.com/okcredit/screen-response-time-a-critical-metric-for-user-experience-fc2be922859f?source=rss----40ea5327aac7---4</link>
            <guid isPermaLink="false">https://medium.com/p/fc2be922859f</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[okcredit]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[Anjal Saneen]]></dc:creator>
            <pubDate>Mon, 27 Jun 2022 06:10:37 GMT</pubDate>
            <atom:updated>2022-06-27T16:37:23.503Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<p>A high-quality user experience is always a top priority at OkCredit. We aim to make the mobile app as fast as possible. To better understand performance impact, we measure various L1 and L2 metrics. Among them, a key metric is screen response time. The time it takes the user to reach the first frame of the screen after clicking for opening a screen.</p><p>Screen response time is a core web metric for <a href="https://web.dev/fid/#what-is-fid">web pages</a>. In addition, Google recently introduced a new metric for assessing full-page responsiveness on the web called <a href="https://web.dev/inp/">Interaction to Next Paint</a>. Android vitals are far behind in terms of measuring responsiveness metrics compared to the web. You can watch the state of responsiveness on the web <a href="https://youtu.be/Mizzbsvv8Os">here</a>. Playstore vitals measure frozen frames and slow frames, but they don’t tell the whole story about the responsiveness of the app. In order for your app to be responsive, you must derive multiple metrics yourself. We share our learnings and findings on-screen response time in this blog post.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S-gyzyHYR_0P2ELbtbvA6w.png" /></figure><h3><strong>How the screens loads</strong></h3><p>Let me explain briefly how a screen loads on Android before we move on to the metric. For optimal screen load, it’s important that you understand all the operations that occur there. Please keep in mind the term Screen in Android terms as referring to a fragment or activity. We demonstrate the XML and jetpack compose individually below.</p><h4>XML</h4><p>We must first understand the principle of XML layout loading, If you dig deep into the Android source code of Activity.setContentView, each layout must go through inflation before it can pass the measure and be drawn.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6NSIR0aYL6xTJMvMGfWwNw.png" /><figcaption>XML Layout load to draw Phases</figcaption></figure><p><strong><em>1. Load and parse the XML file</em></strong></p><p><a href="https://cs.android.com/android/platform/superproject/+/android-12.1.0_r5:frameworks/base/core/java/android/content/res/Resources.java;l=2441"><em>loadXmlResourceParser</em></a><em> is the method responsible for loading</em> an XML file<em>. We wouldn’t need to go into the implementation details of this method, we just need to know that it reads the XML file we wrote into memory, and performs some data parsing and encapsulation. Therefore, this is a method that requires I/O. As we know, I/O operations are typically more computationally intensive. you see </em><a href="https://cs.android.com/android/platform/superproject/+/android-12.1.0_r5:frameworks/base/core/java/android/content/res/ResourcesImpl.java;drc=c1f0ff30ad4f71dd89c019688c3d82130bbb6302;l=1180"><em>implementation details</em></a><em> here.</em></p><p><strong><em>2. Populate the View tree</em></strong></p><p><em>you can see the Layout Inflation code </em><a href="https://cs.android.com/android/platform/superproject/+/android-12.0.0_r32:frameworks/base/core/java/android/view/LayoutInflater.java;l=633"><em>here</em></a><em>. it’s internally calling </em><a href="https://cs.android.com/android/platform/superproject/+/android-12.0.0_r32:frameworks/base/core/java/android/view/LayoutInflater.java;l=984;drc=c1f0ff30ad4f71dd89c019688c3d82130bbb6302"><em>createViewFromTag</em></a><em>. and it’s triggering </em><a href="https://cs.android.com/android/platform/superproject/+/android-12.0.0_r32:frameworks/base/core/java/android/view/LayoutInflater.java;drc=c1f0ff30ad4f71dd89c019688c3d82130bbb6302;l=802"><em>createView</em></a><em> method. As can be seen from the code inside createView, it creates View instances by reflection. Creating objects through reflection is a relatively more expensive operation.</em></p><p>Inflating an XML file is an IO process and View instances are created through reflection. Due to these 2 operations, XML inflation is expensive. After inflation of layout, it goes to the Measure pass, layout pass, and then drawing the views. I will not go over the details of the Measure pass, Layout pass, and drawing. You can read the details <a href="https://developer.android.com/guide/topics/ui/how-android-draws">here</a>. The <a href="https://youtu.be/zdQRIYOST64">video</a> below provides detailed information at the system level.</p><p><strong>Systrace of XML Activity Load<br></strong>As soon as <em>startActivity </em>opens the Activity<em> </em>call, the app process interacts with AndroidManagerService. AndroidManagerService is in charge of activity launching which is in the System process. So while opening an Activity, the app requires binder transactions, which take very few milliseconds. later it goes to View Inflate, measures traversals, and the first draws. The screenshot below shows a sample XML activity with markings at each step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xj7rU3vFfyPvMaw9cvQxXw.jpeg" /></figure><h4>Jetpack Compose</h4><p>XML Loading through I/O and creating classes through reflection cost is saved in Jetpack Compose since layouts are written in Kotlin and compiled just like the rest of your app. Although Jetpack Compose is an unbundled library, it does not benefit from Zygote which preloads the View system’s UI Toolkit classes and drawables. It has to load all the global classes related to compose on the first render. So the startup to the initial compose screen is slow. On the screen which uses compose for the first time in the app, we observed a longer screen loading time. However, subsequent screens load more quickly. We believe the small performance drop is worth the trade-off considering the improvement in developer productivity, experience, and reusability. Taking a tiny bit longer to render is a very small downside in a flood of upsides. Our experience with compose so far has been great too and we would suggest it to any apps. You can go through this <a href="https://developer.android.com/jetpack/compose/phases">link</a> to understand more about each step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tkHJ9hdcM5UqcAFx7ej_3A.png" /></figure><p><strong>Systrace of ComposeActivity Load<br></strong>Compose layouts are written in Kotlin and compiled just like the rest of your app. Jetpack compose goes through the three phases for a frame. Composition, Layout, and then Drawing. Below is a screenshot showing a sample compose activity load, including markings at each event.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0aXGKA87CsYeeMeyE6x2ag.jpeg" /></figure><h3>Screen response time</h3><p>We wrote our own implementation for instrumenting/measuring screen response. You can use the library below for measuring screen load time.</p><p><a href="https://github.com/okcredit/android-page-load-instrumentation">GitHub - okcredit/android-page-load-instrumentation: Measure load time of screen (Activity/Fragment)</a></p><h3>What is a good Screen response time?</h3><p><a href="https://www.nngroup.com/articles/response-times-3-important-limits/">Various</a> <a href="https://dl.acm.org/doi/10.1145/2611387">research</a> shows the delay of fewer than 100 milliseconds feels instant to a user. In order to provide a good user experience, we should strive to have a duration of <strong>100 milliseconds</strong> or less. Below is a good score from the <a href="https://web.dev/fid/#what-is-a-good-fid-score">web</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gQA835WhWrWLFuOxD3M9Uw.png" /></figure><h3>Improving screen load time: Action Items</h3><ul><li><strong>Inflate layout Asynchronously</strong><br>We had some critical screens with multiple views which were taking pretty long for inflations. Asynchronously inflating the layout reduced screen load times by 25% and improved frozen frame performance by 30%.<br>We Use Systrace/Perfetto to measure inflate time. Android has <a href="https://cs.android.com/android/platform/superproject/+/android-12.0.0_r32:frameworks/base/core/java/android/view/LayoutInflater.java;l=635;drc=c1f0ff30ad4f71dd89c019688c3d82130bbb6302;bpv=0;bpt=1">slices</a> for inflating on Systrace. For layouts with high inflation times, you might consider Asynchronous loading. We found various limitations with AndroidX LayoutInflater. Below is an improved version of AsyncLayoutInflater with coroutine.</li></ul><p><a href="https://github.com/okcredit/OkLayoutInflater">GitHub - okcredit/OkLayoutInflater: Improved version of Androidx AsyncLayoutInflater</a></p><ul><li><strong>Flatten your layout.</strong><br>The layout goes through measure traversals after inflation of XML. Measuring views determine the sizes and boundaries of view objects. When a layout includes nested hierarchies, the framework may need to iterate several times to resolve portions of the hierarchy that have multiple layers before the elements will be positioned correctly. ConstraintLayout is helpful here. With Constraint Layout, you can create any layout with a flat view hierarchy. You should consider using ConstraintLayout when dealing with large measures. This can be seen in Sytrace/Perfetto. To understand the performance of your layout, you can also extend your root view and measure onMeasure time and number of traversals by wrapping your onMeasure as below on a debug build.</li></ul><pre>override fun onMeasure(width: Int, height: Int) {<br>    val durationForMeasure = <em>measureTimeMillis </em><strong>{<br>        </strong>super.onMeasure(width, height)<br>    <strong>}<br>    </strong>Log.d(&quot;OnMeasure&quot;, &quot;Duration=${durationForMeasure}&quot;)<br>}</pre><ul><li><strong>Offload long-running operations from the main thread.</strong><br>Use Android Studio CPU Profiler to figure out what is going on in the main thread for local investigation. Use ANR watchdog with a shorter timeout to find long-running operations in production. The <a href="https://github.com/SalomonBrys/ANR-WatchDog">ANR watchdog</a> is a simple library that posts messages periodically to the main thread and watches the UI thread block. You should offload all operations except for UI from the main thread. On the debug build, <a href="https://developer.android.com/reference/android/os/StrictMode">StrictMode</a> can also be enabled to identify long-running threads during development.</li><li><strong>Lazily initialize objects</strong><br>Object creation is a heavy process. When we create a class object, all the public and private properties of that class are initialized inside the constructor. Every variable inside a class initialization requires a certain amount of time to allocate the memory on the heap and hold its reference on the stack. The more variables, the more time it may take. If you have an activity/fragment with a lot of objects being created on initialization use lazy Property in Kotlin for initializing lazily. Lazy initialization is a delegation of object creation when that object is called for the first time. If an object is injected with the dagger inject annotation, use dagger lazy.</li><li><strong>Use R8 and baseline profile for improving compose load time.<br></strong>This is for improving jetpack compose load duration specifically. If your compose app is performing poorly, you might have a configuration problem. Make sure the <a href="https://developer.android.com/jetpack/compose/performance#config">configurations</a> with R8 and the baseline profile on the production app are correct. Furthermore, you can improve performance by defining your own <a href="https://developer.android.com/topic/performance/baselineprofiles">baseline profiles</a>. You might end up generating an app profile that doesn’t actually improve the performance of your app if you define your own. It’s a good idea to test the profile before shipping it to production. <a href="https://www.youtube.com/watch?v=EOQB8PTLkpY">Here’s the video</a> of more performance optimizations on compose.</li><li><strong>Custom View<br></strong>Custom ViewGroup allows you to measure and layout views specific to your use case in an efficient way. You can build a flat hierarchy, minimize the number of measure traversals and optimize memory allocation. Nevertheless, maintaining a codebase with custom views is not easy if you are frequently changing them. We can see how the custom view is used for nearly all views in some of the most performant apps, such as Whatsapp, resulting in low view inflation and a short measure and layout time.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_gaQn0GTNwPzXBauvRFH4g.png" /></figure><ul><li><strong>Reduce Overdraw<br></strong>During the process of displaying the exact layout of the UI in a frame, each pixel can be drawn multiple times. These overdrawn pixels are called overdraw. One example of duplicate work is painting the same color pixels twice. The more layers there are to paint on the screen, the more work the GPU has to do as layers are painted from back to front. This optimization is mostly for low-end devices. On High-end devices overdraw is no longer as significant a problem according to <a href="https://developer.android.com/topic/performance/rendering/overdraw#understanding">android developer docs</a>. You can visualize overdraw by enabling GPU Overdraw from the <a href="https://developer.android.com/topic/performance/rendering/inspect-gpu-rendering#debug_overdraw">developer options</a>. The following example illustrates how overdraw visuals before and after.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OrA2qYzyTvyK0lrlIRaQ1Q.png" /></figure><ul><li><a href="https://github.com/iReaderAndroid/X2C"><strong>X2C</strong></a><strong><br></strong>We talked about performance bottlenecks of layout inflation, loading XML into memory through <strong>IO operations</strong> and parsing and creating View through <strong>reflection </strong>can be heavy operations<strong>. </strong><a href="https://github.com/iReaderAndroid/X2C">X2C</a> helps us to avoids reading layout files through IO operations at runtime. My personal opinion is that this library may have integration issues and may add a bit to the size of the APK if used in actual projects. In terms of divergent thinking, We believe some of these ideas are still worthwhile exploring.</li><li><strong>Caching Results in a View Model until the view is ready<br></strong>What we observe in the major android architecture patterns is that the ViewModel starts execution only after inflation of the XML view. You can start ViewModel initialisation on activity initialization. Parallelizing this can save time some precious time on on-screen load. We use MVI Architecture. On MVI, UI is represented as the function of a state. That state can be cached until the view is ready and Parallelize this process. With a few changes in the way the screen loads, we were able to save some precious time on the screen.</li></ul><h3>Summary</h3><p>The Android Vitals does not provide responsive metrics to track user interaction other than frozen/slow frame rates. To ensure a good user experience, it is crucial to measure user action response times. The most common action is to open a screen. We saw how to measure screen load time and multiple action items to improve screen load time. We still believe that tracking the App’s responsiveness across the board is not sufficient. The Android community needs to develop some better solutions. Please feel free to add your thoughts and suggestions about it.</p><p>Targeting 100ms screen load duration also allowed us to reduce frozen frames by 40%. According to Play Vitals, 65% of frozen frames are caused by high input latency for us. We recommend that if your app is also experiencing frozen frames due to high input latency, you can focus on reducing screen load time.</p><p>Like any other software product, Performance work is never really “done”. It is an iterative process. <strong>Define meaningful metrics</strong>, <strong>Measure, Profile, Fix Bottlenecks, and Repeat</strong>. At some point, you will see that there is a diminishing return on your investment of effort. It would be wise to stop and re-evaluate where you are spending your time if it takes massive effort for a few milliseconds to gain. We hope our experience will be helpful in making your apps faster.</p><blockquote>Credits to the entire Android team at OkCredit for making okcredit App faster everyday. <a href="https://medium.com/u/6bd3bb208cdf">Nishant Shah</a>, <a href="https://medium.com/u/f16393a53557">Rashanjyot Singh</a>, <a href="https://medium.com/u/a444e64946c0">Mohitesh</a>, <a href="https://medium.com/u/71a420fd12b1">Harshitfit</a>, <a href="https://medium.com/u/894b3b833587">Manas Yadav</a>, <a href="https://medium.com/u/2cf3c5aea38f">Pratham Arora</a>, <a href="https://medium.com/u/a1273217c219">Saket Dandawate</a>, <a href="https://medium.com/u/3cba0919e898">Shrey Garg</a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc2be922859f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/okcredit/screen-response-time-a-critical-metric-for-user-experience-fc2be922859f">Screen response time. A critical metric for user experience</a> was originally published in <a href="https://medium.com/okcredit">OkCredit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How we reduced our ANR by three times]]></title>
            <link>https://medium.com/okcredit/how-we-reduced-our-anr-by-three-times-d9ae0b41ad94?source=rss----40ea5327aac7---4</link>
            <guid isPermaLink="false">https://medium.com/p/d9ae0b41ad94</guid>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[okcredit]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[mobile-app-performance]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Anjal Saneen]]></dc:creator>
            <pubDate>Tue, 24 May 2022 05:19:21 GMT</pubDate>
            <atom:updated>2022-05-29T09:42:07.588Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<p>App not responding is one of the most frustrating experiences for users. The user is stuck with an app that is hung and must terminate it. It is ridiculously difficult to observe and fix ANR for the android app in production due to their indeterministic nature. After studying stack traces of ANR, we were able to improve ANR by 60%, as well as cold startup performance by 70%. We’ve also been <a href="https://youtu.be/pYo23Pqxnxg?t=1653">featured on Google I/O</a> and the Android developer’s blog has covered our ANR <a href="https://developer.android.com/stories/apps/okcredit">case study</a>. The goal of this blog post is to discuss our learnings about ANR, challenges around solving ANR, how we track ANRs, an analysis of the source code of ANR generation, and some interesting ANRs that we found and how we resolved them.</p><h3>What is ANR</h3><p>A certain period of time needs to be allowed for the Android system to process events. As soon as the processing times out, an ANR dialogue appears, allowing the user to choose to wait or terminate the application immediately.</p><p>To discover ANR, Android implements a set of sophisticated mechanisms at the system level. ANR can be classified into various categories. According to the background/foreground of the App, each category has a different timeout.</p><ol><li><strong>InputDispatching Timeout(5s): </strong>A major reason for this is that the button or input event does not respond within a specific period of time. On Android, the timeout is set at 5 seconds by default.</li><li><strong>Broadcast Timeout (10s): </strong>If the broadcast receiver fails to complete its processing within the specified time, the broadcast timeout message is reported (foreground timeout is 10 seconds, background timeout is 60 seconds).</li><li><strong>Service Timeout (20s): </strong>The service does not complete the processing within the specified timeframe (foreground timeout is 20 seconds, background timeout is 200 seconds).</li></ol><p>User experience is directly affected by ANR since it forces the user to stop using the application through an automated dialogue. However, in the background, this dialogue will not be shown to the user, instead, the app is silently killed. Playstore measures ANR on a daily session level including foreground and background. Crossing Playstore&#39;s bad behavior threshold (0.47%) will have a negative impact on playlisting.</p><h3>Ways to collect ANRs from Production App</h3><p><strong>1. Play Console Android vitals</strong></p><p>Besides displaying daily ANR affected sessions percentages, the Play vitals also shows ANR method traces of all the thread at the point of ANR. Despite the fact that Play consoles offer some ANR observability around ANR, there are some limitations. It was not possible to download ANR data(This capability was added to Google’s <a href="https://android-developers.googleblog.com/2022/03/play-developer-reporting-API.html">Reporting API</a> recently), <a href="https://old.reddit.com/r/androiddev/comments/d5jpe7/are_the_vitals_for_anr_running_like_13_days/">underreporting and delay</a> of traces, ANRs without traces, the grouping of traces is not suitable and it is impossible to know a specific ANR’s trend.</p><p><strong>2. Firebase and AppExitInfo</strong></p><p>ANR traces are now available on <a href="https://github.com/firebase/firebase-android-sdk/pull/2756">Firebase</a> only for Android 11+ devices. Firebase collects traces from <a href="https://developer.android.com/reference/android/app/ApplicationExitInfo#getTraceInputStream()">ApplicationExitInfo.getTraceInputStream()</a>, which is available since SDK API 30. On Firebase you can also add breadcrumb to get more insight into the issue. Additionally, you can send trace files to your server for better analysis by using the code below.</p><pre>if (Build.VERSION.<em>SDK_INT </em>&gt;= Build.VERSION_CODES.<em>R</em>) {<br>    val am = context.getSystemService(Context.<em>ACTIVITY_SERVICE</em>) as ActivityManager<br>    val exitList = am.getHistoricalProcessExitReasons(context.<em>packageName</em>, 0, 1)<br>    if (exitList.isEmpty()) {<br>        return<br>    }<br>    val lastExitInformation: ApplicationExitInfo = exitList.<em>first</em>()<br><br>    if (lastExitInformation.<em>reason </em>== ApplicationExitInfo.<em>REASON_ANR</em>) {<br>        val outputFile = File(context.<em>filesDir</em>.<em>absolutePath</em>.toString() + &quot;/&quot; + FILE_NAME)<br>        lastExitInformation.<em>traceInputStream</em>.<em>use </em><strong>{ </strong>inputStream <strong>-&gt; </strong>copyStreamToFile(inputStream, outputFile) <strong>}<br>        </strong>//Send output file to server<br>    }<br>}</pre><p><a href="https://github.com/SalomonBrys/ANR-WatchDog"><strong>3. ANR-WatchDog</strong></a></p><p>The <a href="https://github.com/SalomonBrys/ANR-WatchDog">ANR watchdog</a> is a simple library that posts messages every five seconds to the main thread and watches the UI thread block. It collects traces and reports ANR whenever the main thread is busy for more than five seconds(it can be configurable). The play store does not indicate that this is an ANR. But this could be a potential source where the thread is blocked. By fixing all slow running methods on the main thread, You can fix ANRs and the rendering performance of the App. Those traces captured by watchdog have proven more valuable than those found in /data/anr/traces.txt in our experience. We have observed cases in which system traces capture native traces from <em>android.os.Message-Queue.nativePollOnce</em>, while ANR watchdog is able to capture meaningful traces which point out to slow java methods. By removing slow methods running on the app’s main thread, this library helps us improve ANR, frozen frames, and App startup.</p><h3>Source code analysis of ANR</h3><p>The following diagram shows how method calls are structured in the Android source code. We’re taking a look at how Android handles ANR inside of the system in this article. The article is based on the android-12.0.0_r4 <a href="https://cs.android.com/android/platform/superproject/+/android-12.0.0_r4:">branch</a> (the latest release of Android 12 at the time of writing this blog).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R30D9dT5alpd7ytARVZUcQ.png" /></figure><p>We reverse tracked the generation mechanism of ANR from <em>ProcessErrorStateRecord.appNotResponding()</em>. You can see from the image above that it is getting called from four places.</p><p>You can see ANRs can happen due to timeout from 4 components. one is InputDispatchingTimeout. Others are from Service, Broadcast Receiver, and Content providers. We will reverse engineer only InputDispatchingTimeout on this article to keep it simple. You can skip understanding the source code part if you want to skip. However, having an understanding of what’s going on at system-level will help you create more mental modals around ANRs and helps you to solve some of the difficult ANRs.</p><p>Let’s look at InputDispatchingTimeout. The InputManager class wraps the C++ InputManager and provides its callbacks. From the native layer, <a href="https://cs.android.com/android/platform/superproject/+/android-12.0.0_r4:frameworks/base/services/core/java/com/android/server/wm/InputManagerCallback.java;l=91-114">these</a> methods are being called from on window responses. This triggers the <em>notifyAppUnresponsive(), notifyWindowUnresponsive(), notifyGesture-MonitorUnresponsive()</em> in AnrController. AnrController dumps WMS state when an app becomes unresponsive and triggers <a href="https://cs.android.com/android/platform/superproject/+/android-12.0.0_r4:frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java;l=16376"><em>ActivityManagerService.inputDispatchingTimedOut()</em></a>. Android services and broadcast receivers also have similar timeout methods. The service timeout is defined in <a href="https://cs.android.com/android/platform/superproject/+/android-12.0.0_r4:frameworks/base/services/core/java/com/android/server/am/ActiveServices.java;l=5181"><em>ActiveServices.serviceTimeout()</em></a>; and for the broadcast receiver, it’s defined in <a href="https://cs.android.com/android/platform/superproject/+/android-12.0.0_r4:frameworks/base/services/core/java/com/android/server/am/BroadcastQueue.java;l=1794"><em>BroadcastQueue.broadcastTimeoutLocked()</em></a>.</p><p>A message is created <a href="https://cs.android.com/android/platform/superproject/+/master:frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java;l=16410">here</a> informing you of the trigger for this ANR (<em>eg: Input dispatching timed out (d6e077e MainActivity (server) is not responding</em>). This is the title displayed in play vitals. In all of those timeout methods, it generates an ANR message and calls <em>ANRHelper.appNotResponding()</em> with information about the process. For input Dispatching timeout, results are <a href="https://cs.android.com/android/platform/superproject/+/android-12.0.0_r4:frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java;l=16387">“Input dispatching timed out $reason”</a>. For broadcast receivers, it’s <a href="https://cs.android.com/android/platform/superproject/+/android-12.0.0_r4:frameworks/base/services/core/java/com/android/server/am/BroadcastQueue.java;l=1887">“Broadcast of $intent”</a> and for services, <a href="https://cs.android.com/android/platform/superproject/+/android-12.0.0_r4:frameworks/base/services/core/java/com/android/server/am/ActiveServices.java;l=5217">it’s “executing service $serviceName“</a>. The same message appears on the title of play vitals ANR.</p><p>Inside <em>ANRHelper.appNotResponding(), </em>It spawns a <a href="https://cs.android.com/android/platform/superproject/+/android-12.0.0_r4:frameworks/base/services/core/java/com/android/server/am/AnrHelper.java;l=93">new thread</a> that calls <a href="https://cs.android.com/android/platform/superproject/+/android-12.0.0_r4:frameworks/base/services/core/java/com/android/server/am/ProcessErrorStateRecord.java;l=219"><em>ProcessErrorStateRecord.appNotResponding</em></a>(), which is responsible for gathering information regarding ANR and storing it into <em>data/anr/traces.txt</em> and <em>/data/system/dropbox</em>. We will take a closer look at the things that are going on in this method.</p><p><strong>Log ANR event. <br></strong>Log ANR on system diagnostic event.</p><pre>EventLog.writeEvent(EventLogTags.AM_ANR, mApp.userId, pid, mApp.processName,<br>        mApp.info.flags, annotation);</pre><p><strong>Get CPU And Memory Pressure</strong></p><p>PSI is an observability tool for Linux-based operating systems. it can be exported through the respective file in <em>/proc/pressure/ — cpu, memory</em>. But App developers don’t have access to this. Even if your app is super performant, ANR can happen due to the high resources used by other apps. So this information is critical to understanding some of ANR. Currently, this information is not stored in <em>data/anr/traces.txt, </em>But this information can get on system events.</p><pre>report.append(MemoryPressureUtil.currentPsiState());<br>ProcessCpuTracker processCpuTracker = new ProcessCpuTracker(true);</pre><p><strong>Dump StackTraces of all threads</strong></p><p>Dump stack traces in <em>data/anr/traces.txt </em>file.</p><pre>File tracesFile = ActivityManagerService.dumpStackTraces(firstPids,<br>        isSilentAnr ? null : processCpuTracker, isSilentAnr ? null : lastPids,<br>        nativePids, tracesFileException, offsets, annotation);</pre><p><strong>Add Error to DropBox</strong></p><p>There is a DropBoxManager in Android that can read logs. However, we require the READ_LOGS permission to read log data. This permission can be granted only to apps signed as part of the firmware build or installed on the privileged partition.</p><pre>mService.addErrorToDropBox(&quot;anr&quot;, mApp, mApp.processName, activityShortComponentName,<br>        parentShortComponentName, parentPr, null, report.toString(), tracesFile,<br>        null, new Float(loadingProgress), incrementalMetrics, errorId);</pre><p><strong>Show ANR Dialog</strong></p><p>We observed a 2,3-second delay between ANR timeout and the appearance of this dialogue, as a result of a delay in capturing stack traces.</p><pre>msg.what = ActivityManagerService.SHOW_NOT_RESPONDING_UI_MSG;<br>msg.obj = new AppNotRespondingDialog.Data(mApp, aInfo, aboveSystem);<br><br>mService.mUiHandler.sendMessageDelayed(msg, anrDialogDelayMs);</pre><h3>When is input dispatch time out triggered?</h3><p>During on-window responses, <a href="https://cs.android.com/android/platform/superproject/+/android-12.0.0_r4:frameworks/base/services/core/java/com/android/server/wm/InputManagerCallback.java;l=91-114">these</a> methods are triggered by <em>notificationAppUnresponsive(), notificationWindowUnresponsive()</em>, and <em>notifyGestureMonitorUnresponsive()</em>. In this section, we’ll examine how and when these methods are triggered by the native layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a9jwZ5z5wGDlDTXXuJWyBQ.png" /><figcaption>Callstack of notifyAppUnresponsive(), notifyWindowUnresponsive(), notifyGestureMonitorUnresponsive()</figcaption></figure><p>The call stack shows that all three types of ANR will eventually terminate in the InputDispatcher::dispatchOnce function. It is the thread body of the InputDispatcher thread that is started by the <a href="https://cs.android.com/android/platform/superproject/+/android-12.0.0_r4:frameworks/native/services/inputflinger/dispatcher/InputDispatcher.cpp;bpv=1;bpt=1;l=554">InputDispatcher::start</a> function.</p><p>As soon as InputDispatcher starts after some input events occur, it calls mLooper.wake() and InputDispatcher::dispatchOnce, and then processAnrsLocked is called to determine whether ANR has occurred.<br>Let’s take a closer look at what happens in dispatchOnce().</p><p>The last mLooper.pollOnce(timeoutMillis) in dispatchOnce function blocks the thread, waits for the timeoutMillis time, and then calls InputDispatcher::dispatchOnce again. The Linux epoll mechanism is used by mLooper to block, and the call to wait for timeoutMillis is epoll_wait. The value of timeoutMillis is 5000, which means the call to mLooper.wake() will likely cause ANR. mLooper.wake() has multiple references from the App. We can observe more than 20+ references. Therefore, no matter how long the UI is blocked, as long as there is not a necessary event to trigger Dispatch (mLooper.wake()), ANR will not be generated. You can check that by creating a click listener with unlimited sleep, ANR will not be generated. ANR will occur only on the next input event, which means the next click or scroll.</p><h3>Intresting case of ContentProvider ANR</h3><p>We observed all references of appNotRespondingViaProvider() inside ContentProvider. From our analysis, all of them have been blocked, and therefore, our hypothesis is the App’s ContentProvider will not trigger the ANR. 2 meaningful refference to <a href="https://cs.android.com/android/platform/superproject/+/android-12.0.0_r4:frameworks/base/services/core/java/com/android/server/am/ContentProviderHelper.java;l=874;bpv=1;bpt=0">appNotRespondingViaProvider</a>() is</p><p>1. <a href="https://cs.android.com/android/platform/superproject/+/android-12.0.0_r4:frameworks/base/services/core/java/com/android/server/am/ContentProviderHelper.java;l=915;bpv=1;bpt=0">getProviderMimeType</a>(), This method is called only once by ActivityManagerShellCommand, but this class is also used by adb shell.</p><p>2. Another trigger is from <a href="https://cs.android.com/android/platform/superproject/+/android-12.0.0_r4:frameworks/base/core/java/android/content/ContentProviderClient.java;l=685;bpv=1;bpt=0">NotRespondingRunnable</a>. However, this can only be done through a SystemApi annotation.</p><p>In OkCredit App, we did not find any ANR for the content provider. Our Hypothesis is that App’s ContentProvider won’t trigger the ANR.</p><h3>The challenges of Fixing ANR</h3><p>The indeterministic nature of ANR presents a challenging problem regarding observability. Among the problems are:</p><ol><li>Google Play Console does not display a stacktrace</li><li>Due to delays in dumping traces and the actual time of ANR, stacktrace will not point to the right place</li><li>It is difficult to know the trend of ANR due to inconsistency in grouping ANR. This prevents hypothesis validation after the predicted fix.</li><li>Traces lack foreground/background information. but Firebase would solve this issue by adding breadcrumbs to Android 11+ devices</li><li>For fixing ANR, the relevant information is missing in-play consoles, such as CPU usage and memory pressure at the point of ANR. In multiple cases, ANR occurred when broadcast receivers and services woke up the app from the background. Due to the high concept of resources in the app, ANR may occur.</li><li>It was impossible to download ANR data from the Play console. A lot of manual work is required. Thanks to the Google Play team. They recently added <a href="https://android-developers.googleblog.com/2022/03/play-developer-reporting-API.html">Reporting API</a> which enables downloading.</li></ol><p>In his book <a href="https://www.brendangregg.com/sysperfbook.html">System Performance</a>, <a href="https://www.brendangregg.com/">Brendan Gregg</a> outlines some of the <strong>“anti-methodologies”</strong> for solving performance issues. To fix ANR on Android, developers have been desperately following some of these anti-methodologies. Trying random things in the hope of catching a win. it can also be time-consuming, disruptive, and may ultimately overlook certain issues.</p><h3>Here are some of the interesting ANRs we encounter</h3><p><strong>1. ANR in broadcast receivers and Services</strong></p><p>Work manager and firebase services in the App make up most of this category for us. You can identify these ANR’s by their play vitals group title.</p><blockquote><em>“executing service your.package.name/….systemjob.SystemJobService”</em></blockquote><blockquote><em>“Broadcast of Intent { act=android.intent.action.TIME_SET flg=0x25200010”</em></blockquote><blockquote><em>“Broadcast of Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x1080010 pkg=your.package.name cmp=com.google.firebase.iid.FirebaseInstanceIdReceiver (has extras) }”</em></blockquote><blockquote><em>“executing service your.package.name/com.google.firebase.auth.api.fallback. service.FirebaseAuthFallbackService”</em></blockquote><p>This does not mean the bottleneck for ANR is in firebase service or work manager broadcast receiver. A number of issues have been <a href="https://www.reddit.com/r/androiddev/comments/dojxme/workmanager_how_do_you_deal_with_anr_in/">reported</a> with these libraries because of the title. The ANR notifies you when a broadcast receiver or service failed to complete the processing within the specified time limit. Timeouts could be caused by your code until and unless these services do long-running operations on <em>BroadcastReceiver.onReceive(), Service.onCreate()</em> and <em>Service.onStartCommand()</em>.</p><p>Almost all of these ANRs occurred in the background for us. If your app is in a killed state, it has to launch the main thread, initialise content providers, and process <em>App.onCreate()</em>. Timeouts can occur here if the operation is slow. Typically, slow operations in <em>App.onCreate()</em> are to blame. There is an interesting <a href="https://medium.com/bumble-tech/how-we-achieved-a-6x-reduction-of-anrs-part-2-fixing-anrs-24fedf9a973f">read</a> from bumble-tech regarding their ANR’s on notification service. They created a separate process to handle notifications. Launching an extra process consumes additional CPU and memory. Use this only as a last resort after resolving all issues in the cold startup process. Our recommendation is to optimize your cold startup time. We use FCM extensively for notification campaigns and critical background synchronization. We solved ANRs by optimizing cold startup. The following article explains what we learned from the cold startup.</p><p><a href="https://medium.com/okcredit/how-okcredit-android-app-improved-cold-startup-by-70-e02bda4836a8">How OkCredit Android App improved Cold Startup by 70%</a></p><p>In production, we measure the time spent by <em>App.onCreate()</em> and content provider initialization during cold startup using the following code.</p><p><a href="https://github.com/okcredit/android-cold-startup-instrumentation">GitHub - okcredit/android-cold-startup-instrumentation: Instrumentation library for Android Cold Startup</a></p><p><strong>Observation:</strong></p><p>In the background, whenever the app wakes up, the app is comparatively slow since there is less memory and CPU to work with. P99 of time it takes for <em>App.OnCreate()</em> to be executed is 2.3x more than when in the foreground.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1UqLG4QKyaajMf0sEKlNcQ.png" /></figure><p>When broadcast receivers and services wake up the app for execution, it has to create an app object, initialize content providers, and execute App.onCreate(). This may exceed the ANR timeout limit due to CPU starvation and trigger ANR.</p><p><strong>Recommendations:</strong></p><ul><li>Profile and optimise startup regularly using CPU Profiling, Systrace/<a href="https://perfetto.dev/">Perfetto</a>.</li><li>Benchmark Cold startup using <a href="https://developer.android.com/studio/profile/macrobenchmark">Macrobenchmark</a> on CI</li><li>Avoid doing heavy work on <em>BroadcastReceiver.onReceive(),</em> <em>Service.onCreate()</em> and <em>Service.onStartCommand()</em></li><li>Avoid frequent broadcast receivers.</li></ul><p><strong>2. ANR Due to slow methods</strong></p><p>Those slow methods should be easy to discover in this category. The thread trace will be pointing to them. We use <a href="https://github.com/SalomonBrys/ANR-WatchDog">ANR watchdog</a> for catching all slow methods running on the main thread. The recommendation is to avoid heavy computation/IO operation on the main thread. It should be handled by the background thread.</p><p><strong>3. ANR Due to Lock</strong></p><p>In certain circumstances, the work that causes an ANR is not directly executed on the application’s main thread. For example, a background thread might hold a lock on a resource that the main thread needs to complete its work. This occurs frequently while using synchronized/mutex blocks.</p><p>Each thread entry in the trace contains some hints that can help you detect a deadlock. First of all, you can see the state of a thread: it usually is Runnable, Sleeping, Waiting, Native or Blocked. It tells you what state the thread was in at the moment the ANR took place, and you will be interested in the threads that are marked as Blocked. The threads marked as blocked typically tell you what mutex (lock) they’re trying to acquire as well as the thread ID of the thread holding that lock. If you scroll down to the entry corresponding to that thread in the list, you can see what mutex it is trying to acquire and which thread holds that lock.</p><p><strong>4. ANR in shared preferences</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AoZBG4Q4dKQzQ-zhEdbDGg.png" /></figure><p><em>apply()</em> method on shared preference may cause ANR, since apply(), keeps values in-memory and stores them asynchronously on onPause(), onReceive(), etc, causing ANR. You can read more about the causes of ANR in this interesting <a href="https://programmer.ink/think/count-the-slots-in-shared-preferences.html">article</a>. Our fix for this was to change all apply() into commit() in the background thread.</p><p><strong>5. WaitingForGcToComplete()</strong></p><blockquote>ANR: &quot;main&quot; prio=5 tid=1 WaitingForGcToComplete</blockquote><p>WaitingForGcToComplete suggests that the main thread might be blocked by the Garbage Collector, which indicates a high memory footprint, as well as an approaching Out of Memory Error. We recommend optimizing memory allocation in the app and fixing memory leaks. We use <a href="https://square.github.io/leakcanary/">leak canary</a> on debug builds for this. leak canary has an option to get leak data. we send all leaks to firebase using <a href="https://github.com/square/leakcanary/issues/2119#issuecomment-945526363">this</a> code.</p><h3>Result</h3><p>After digging deep into some ANRs and all the above changes, we managed to keep the ANR metric on play vital at 0.03%. There are multiple broadcast receivers and services that we use including FCM for notification campaigns and critical sync when the app is running low on resources. Therefore, we still have difficulty solving all ANRs. We intend to keep striving until diminishing returns are reached.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UWZQ4PoBad_fBdpecoOEcg.png" /></figure><p>We saw how cold startups and ANRs are connected. We were able to keep the cold startup at 0.66%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TAdj9km1kPeI3AL7Plb1_w.png" /></figure><h3>Conclusion</h3><p>Due to their nature and observability challenges, ANRs are very challenging to solve. The only way to avoid ANR in Android apps is to ensure the UI thread has the least burden. In addition, we found that when the app wakes from the background, there is always a chance of ANR due to CPU starvation on the user’s device. Applications that have background services and background work are always at risk of receiving an ANR.</p><p>Keeping track of mobile health is incredibly difficult for Android apps. The system needs to provide APIs for reporting the app behavior of Android apps in production. AOSP teams have built amazing tools for local investigation. However, there are no APIs or libraries for reporting app behavior in production. Linux has many <a href="https://medium.com/@chrishantha/linux-performance-observability-tools-19ae2328f87f">observability tools</a>. But app developers do not have access to them.</p><p>We hope that our experience will be valuable in helping you to reduce your ANR rate and improve your application quality. Thanks for reading. A huge thank you to <a href="https://medium.com/u/e1fb03b9ea54">Niharika Arora</a> for helping us understand Android internals and navigate around ANR.</p><blockquote>Credits to the entire Android team at OkCredit for helping to achieve these performance improvements. <a href="https://medium.com/u/6bd3bb208cdf">Nishant Shah</a>, <a href="https://medium.com/u/f16393a53557">Rashanjyot Singh</a>, <a href="https://medium.com/u/a444e64946c0">Mohitesh</a>, <a href="https://medium.com/u/71a420fd12b1">Harshitfit</a>, <a href="https://medium.com/u/894b3b833587">Manas Yadav</a>, <a href="https://medium.com/u/2cf3c5aea38f">Pratham Arora</a>, <a href="https://medium.com/u/a1273217c219">Saket Dandawate</a>, <a href="https://medium.com/u/3cba0919e898">Shrey Garg</a>.</blockquote><h4>Useful Links</h4><ol><li><a href="https://developer.android.com/topic/performance/vitals/anr">https://developer.android.com/topic/performance/vitals/anr</a></li><li><a href="https://developer.android.com/training/articles/perf-anr">https://developer.android.com/training/articles/perf-anr</a></li><li><a href="https://medium.com/bumble-tech/how-we-achieved-a-6x-reduction-of-anrs-part-1-collecting-data-7c473ceb1c83">https://medium.com/bumble-tech/how-we-achieved-a-6x-reduction-of-anrs-part-1-collecting-data-7c473ceb1c83</a></li><li><a href="https://programmer.ink/think/count-the-slots-in-shared-preferences.html">https://programmer.ink/think/count-the-slots-in-shared-preferences.html</a></li><li><a href="https://developer.android.com/stories/apps/okcredit">https://developer.android.com/stories/apps/okcredit</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9ae0b41ad94" width="1" height="1" alt=""><hr><p><a href="https://medium.com/okcredit/how-we-reduced-our-anr-by-three-times-d9ae0b41ad94">How we reduced our ANR by three times</a> was originally published in <a href="https://medium.com/okcredit">OkCredit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Digital payments are surging in informal BNPL; Under Rs 200 payments lead the surge]]></title>
            <link>https://medium.com/okcredit/digital-payments-are-surging-in-informal-bnpl-under-rs-200-payments-lead-the-surge-394330b8eff3?source=rss----40ea5327aac7---4</link>
            <guid isPermaLink="false">https://medium.com/p/394330b8eff3</guid>
            <category><![CDATA[digital-payment]]></category>
            <category><![CDATA[bnpl]]></category>
            <category><![CDATA[retail]]></category>
            <category><![CDATA[upi]]></category>
            <dc:creator><![CDATA[Team OkCredit]]></dc:creator>
            <pubDate>Mon, 23 May 2022 11:27:01 GMT</pubDate>
            <atom:updated>2022-05-23T11:27:01.385Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Xg4jHUSF_rTMZfzv" /><figcaption>Photo by <a href="https://unsplash.com/@dafidvor?utm_source=medium&amp;utm_medium=referral">David Dvořáček</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Prior to 2019, the biggest pain in Nitesh Bansal’s life was getting customers to pay their dues. Bansal runs a Kirana cum mobile recharge store at Surat in Gujarat. Customers would keep on buying things at his store over and above an existing credit line, inflating the dues. “ The typical excuses would be- “Forgot cash at home”, “Settle the current bill, will pay the dues later” , “Don’t have change” etc.</p><p>In June 2019, Bansal latched on to one of the UPI platforms and since then things have changed. Digital payments have made his life a lot easier, by making credit settlements fuss-free. His customers now scan the QR code or pay him via Paytm. That doesn’t mean he has gone completely digital; 60% of the payments at his store still happen in cash- a reality that has also been reflected in OkCredit’s data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zlpactCUtNrNpa83" /></figure><p>UPI and within that QR codes have been the heroes of this digital revolution. Be it the neighbourhood vegetable vendor or the street food hawker, it isn’t uncommon to find QR codes pasted on their shops and carts. The sheer convenience of scanning a code rather than looking for change or navigating through multiple apps makes QR codes a clear favourite among small and micro businesses.</p><p>In fact, 90% of online payments happening on OkCredit take place through UPI, giving it a significant lead over all other forms of payments.</p><p>While convenience is the primary reason, it has also been seen that shops that accept digital payments have a better control on cashflows than those who don’t. Three shops away from Bansal’s store, Ajay Sirohi’s “Beena recharge point” suffers regularly because of non-paying customers. Despite several customers requesting him to add digital payments at the store, Sirohi hasn’t done it for fear of cyber frauds. Payments are always an issue at his store, forcing him to resort to borrowing from his friends.</p><p>Interestingly, for shops accepting digital payments, smaller denomination transactions are mostly happen through UPI. More precisely, OkCredit’s data states that under Rs 200 transactions are happening through UPI. Small purchases such as cigarettes, confectionery etc are most likely being paid through one among the several UPI options available today.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YHttL86P2Ing91WovqiHuw.gif" /></figure><p>The good part is UPI’s share has surged in every category- be it Rs 1000- 5000 or slightly higher purchases such as Rs 5000- 20,000. With increasing adoption, digital payments will be a critical factor for success in the informal BNPL.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=394330b8eff3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/okcredit/digital-payments-are-surging-in-informal-bnpl-under-rs-200-payments-lead-the-surge-394330b8eff3">Digital payments are surging in informal BNPL; Under Rs 200 payments lead the surge</a> was originally published in <a href="https://medium.com/okcredit">OkCredit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[No more chasing jobs, graduates are turning shopkeepers-OkCredit Insights]]></title>
            <link>https://medium.com/okcredit/no-more-chasing-jobs-graduates-are-turning-shopkeepers-okcredit-insights-1e6c7d218bd6?source=rss----40ea5327aac7---4</link>
            <guid isPermaLink="false">https://medium.com/p/1e6c7d218bd6</guid>
            <category><![CDATA[retail]]></category>
            <category><![CDATA[digital-bookkeeping]]></category>
            <category><![CDATA[kirana]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[unemployment]]></category>
            <dc:creator><![CDATA[Team OkCredit]]></dc:creator>
            <pubDate>Mon, 23 May 2022 09:16:53 GMT</pubDate>
            <atom:updated>2022-05-23T09:16:53.358Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7T0a_7XrReMSG8VE" /><figcaption>Photo by <a href="https://unsplash.com/@anmolram46?utm_source=medium&amp;utm_medium=referral">Anmol Ramanujam</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>There’s a particular imagery that comes to mind when one thinks of a shopkeeper- sparsely educated, between 20 and 40 years in age, ceaselessly taking orders on phone with one hand and packing stuff with another. For this neighbourhood “bhaiya” or “uncle”, only three things matter- customers, inventory and his bahi-khata (the account register). Now, picture a retail store owner in the same age group, but genial, well-informed, inclined to technology, using apps for his business needs. There is a stark difference in customer experience at both these stores.</p><p>While there are a bunch of factors responsible for this change, one of them is educated folks, particularly graduates getting into unorganised retail. Neighbourhood stores in India have typically been run by semi-literate, less educated individuals, some of who join it as a family owned business. For others, it’s the easiest source of livelihood, if they aren’t qualified enough for a job.The barriers to entry are so low that anyone with a basic minimum qualification can open a shop.</p><blockquote>While this is true even now, Covid-19 has altered the scenario, partially. Rising unemployment has meant that graduates who would earlier prefer jobs, are now looking at unorganised retail as a viable source of livelihood. At OkCredit, we have credible data that shows this in reality.</blockquote><p>In our annual study released this year in March, the demographic data gave a true picture of this change. Even though, across age groups, owners of small businesses lack education, in the 35–45 age group, a decent chunk of business owners are graduates. Covid-19 may have been the forcing factor but this also points to a mindset shift among the educated class who have typically preferred “safe” jobs over business.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ESM1Ew4vJxYBR755" /></figure><p>For an outsider, this shift may seem trivial, but it’s significant for two reasons- First, as more of educated class joins unorganised retail, there will be an increase in the usage of business apps. Young and educated typically have a tendency to adopt what’s new in technology and if it impacts their business positively, they are likely to get hooked. For apps such as OkCredit, this is great news.</p><p>Second, this will lead to an improved customer experience at retail stores- be it in terms of product selection, layout of the store or checkout experience, it has been seen that these aspects matter a lot for someone who is educated. Simply put, the band of 35–45 year olds will play a key role in elevating both customer experience as well as app usage.</p><p>Take for example Vishnu Prasad’s Ambe General Store which he has been running for 25 years in the Nawabganj area of Barabanki, a district in Uttar Pradesh. There’s nothing unique about the shop which gets a set of loyal customers for staples and grocery products. However, things changed last year when Prasad’s 38 year old son Rajeev started sitting at the shop. Rajeev used to work at a logistics startup in Delhi NCR till 2020. In the second wave of Covid, his firm laid off a number of employees including him. That’s when he came back to Barabanki. In a few days, he was ready with the changes the shop needed. One of the things that irritated him the most was reminding customers to pay their due.</p><p>As a first step, he migrated existing credit records on OkCredit. With in-built reminders, credit started coming back faster than he had expected. Next, he added a dedicated corner in his shop for cosmetics, bringing a bevy of women customers.</p><p>Education has never been a determinant for success in retail but as more graduates come on board, a transformation is inevitable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e6c7d218bd6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/okcredit/no-more-chasing-jobs-graduates-are-turning-shopkeepers-okcredit-insights-1e6c7d218bd6">No more chasing jobs, graduates are turning shopkeepers-OkCredit Insights</a> was originally published in <a href="https://medium.com/okcredit">OkCredit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[No, we are not wonder women, power women or supermoms. We are just ourselves]]></title>
            <link>https://medium.com/okcredit/no-we-are-not-wonder-women-power-women-or-supermoms-we-are-just-ourselves-75e982e4b263?source=rss----40ea5327aac7---4</link>
            <guid isPermaLink="false">https://medium.com/p/75e982e4b263</guid>
            <category><![CDATA[women-in-tech]]></category>
            <category><![CDATA[womens-day]]></category>
            <category><![CDATA[gender-equality]]></category>
            <category><![CDATA[womens-rights]]></category>
            <dc:creator><![CDATA[Team OkCredit]]></dc:creator>
            <pubDate>Tue, 08 Mar 2022 07:36:58 GMT</pubDate>
            <atom:updated>2022-03-08T07:36:58.417Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xxg_G1uHc1__PrkyYTh-pg.jpeg" /></figure><p>A gazillion articles will be published today eulogising women for their “do-it-all” capabilities, ads will sing paeans to how women play multiple roles with aplomb. For this one day every year, women are Durga, Lakshmi (Indian goddesses), superwomen and every possible encomium you can think of. For women, it’s heartening to be showered with so much adulation, but there’s an embedded truth herein. That we as a society celebrate women carrying a disproportionate burden of responsibilities.</p><p>What this leads to, is an impractical set of expectations from women- to be the perfect homemaker, the multi-tasker who should juggle between home, work and kids, perfect daughter, life-partner and so on. Most women end up having a miserable personal life, fraught with stress in a bid to meet these expectations. “Wonder Woman”, “Supermom” — these monikers don’t help except for a momentary boost of energy. For the most part, women struggle and get hurt in the process to become this superhuman which exists only in fantasies.</p><p>Among several images last year, that spoke of the tragedy unleashed by Covid second wave and human resilience, a picture that stood out was that of an Asha worker, braving kneep deep water, carrying infant on her back to execute Covid vaccinations. Was she trying to be a super mom or a star employee who performed both her roles spiritedly? No, She was just doing her job with 100% commitment. The child on her back is not a sign of her being the “super mother”, rather a reflection on us as a society which expects women to unequally shoulder child rearing responsibilities.</p><p>So, world, leave women as they are. Don’t crown and garland them, only to weigh them down with things they don’t deserve to carry alone. Let them be perfectly imperfect. They will grapple with motherhood, suck at the job, may not keep the home in best of shape, but it’s fine. It’s fine to not be constantly pushing boundaries and proving oneself to standards that are not meant to be. Rather, what needs to be encouraged is for women to look after themselves. And for men to lend a helping hand, so that they don’t need to be the “wonder woman”.</p><p>On this note, it’s pertinent to talk about the “women of OKC”. None of these are powerpuff girls, supermoms or other such things, but they are brilliant in their own way. Many of them come from societies where women are not encouraged to study or work. These women are therefore not just shattering established norms but are also an inspiration at the workplace.</p><p>The great thing about these women is- they are not just the job they do, they are multiple things- mentor, friend, agony aunt, secret keeper, joke cracker, lunch buddy and above all team player.</p><p>Thanks Radhika, Sarika, Priyanka, Yamini, Apoorva, Shabina, Mahalakshmi, Bhoomika, Aishwarya, Sanjana, Divya, Lakshmi, Supriya, Aleena, Chaitra, Shivani, Meetasha and Vandana for making OkCredit an awesome place to work. You guys are seizing the day everyday.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75e982e4b263" width="1" height="1" alt=""><hr><p><a href="https://medium.com/okcredit/no-we-are-not-wonder-women-power-women-or-supermoms-we-are-just-ourselves-75e982e4b263">No, we are not wonder women, power women or supermoms. We are just ourselves</a> was originally published in <a href="https://medium.com/okcredit">OkCredit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Winding back the clock on 2021: Many sweet and a few sour memories]]></title>
            <link>https://medium.com/okcredit/winding-back-the-clock-on-2021-many-sweet-and-a-few-sour-memories-e552487081ea?source=rss----40ea5327aac7---4</link>
            <guid isPermaLink="false">https://medium.com/p/e552487081ea</guid>
            <category><![CDATA[new-year]]></category>
            <category><![CDATA[hope]]></category>
            <category><![CDATA[gratitude]]></category>
            <category><![CDATA[reflections]]></category>
            <category><![CDATA[rewind]]></category>
            <dc:creator><![CDATA[Team OkCredit]]></dc:creator>
            <pubDate>Thu, 30 Dec 2021 08:22:47 GMT</pubDate>
            <atom:updated>2021-12-30T08:22:47.265Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wBToh1qx0GUy5L_K6ijM4Q.jpeg" /></figure><p>Roller coaster ride. Chances are you’ll hear the term quite often this year. But that’s what it’s been. There were ups and some really down-downs. It was a year that started with a lot of promise, toned down by Covid for a few months and a happy ending as it should be. Even as the Omicron threatens us in the new year, reminding us that we are still in the pandemic world, it makes sense to count the blessings.</p><p>The highlight for us this year was our much awaited offsite in April. Happy faces, laughter, zero-stress, bonding were some of the things that defined our first offsite. With a majority of our team onboarded during the pandemic, it was a much needed get-together. That apart, singing, dancing and party skills of some of our colleagues were quite a revelation!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pxFM1X6FxgTU24FLqlLJIA.jpeg" /></figure><p>While we came back safe and were still brimming with happiness and positivity post the offsite, the larger environment was starting to get gloomy. As cries for Oxygen and medicines came out from everywhere, we just couldn’t sit quiet. Medical stores were life savers during the second wave and we had several of them on our platform. Our team of engineers worked hard to come up with <strong>Co-aid,</strong> a digital resource to help people discover verified leads for Covid-19 critical medicines and equipment.</p><p>The second wave was a crisis, humankind had never before seen and we are glad to have played a small role in helping out those in need. Many of our colleagues and their families were affected too. As a people first organisation, we stood strongly with them, making sure they had the space to prioritize health and family over everything.</p><p>Tough times do not last but tough people do. The resilience and strength of OkCredit over two Covid waves is a reflection of antifragility and tenacity of its people. To reward their perseverance, we announced an across the board <strong>mid year salary jump</strong> in July. Needless to say everybody was elated. We doubled their joy further by revising our<strong> Esop programme</strong>, making it more attractive for our people.</p><p>This was indeed the year where people took centrestage. It wouldn’t be wrong to call it the year of HR at OkCredit, given the number of employee friendly initiatives we took this year, also mentioned in the last article.</p><p>We organised our third hackathon-<strong> OkHackathon 3.0</strong> with the theme “Delight a user”. Teams within OkCredit presented several amazing ideas winning prizes worth Rs 3 lakh.</p><p>The festive season, like every year shone bright both for merchants and OkCredit. Our <strong>festive season data report</strong> revealed 12% higher than average repayments. Digital payments, the report showed, played a huge role in helping mom and pop stores recover credit.</p><p><strong>Digital payments</strong> in fact, has been the feather in our cap this year. It’s a product that saw rapid scale up, thanks to adoption from merchants who were already using our bookkeeping app. OkCredit’s digital payment feature has made credit collection significantly easier for merchants who had to earlier rely on third party payment apps.</p><p>As the IPL came back in October, we didn’t want miss the fandom and excitement, having partnered the Delhi Capitals team last year. However, this year we wanted to do something different leveraging the IPL euphoria. The result was <strong>our first TV ads</strong> during this IPL season. Called <strong>VASOOLI KE PAINTRE, the campaign</strong> focused on the innovative ways that merchants use to collect their dues from customers and was centered around creativity and street smarts.</p><p>Besides these, there are multiple experiments we’ve been doing , some of which are set to fructify in the coming year. Topping on the cake — — we also received <strong>multiple awards</strong> this year, a validation of our work in mainstreaming the SMB sector. Moonshot startup of the year by SaasBoomi, BW Techtors And Entrepreneur of the year in service business are a few among several that endorse our work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z2RKh28ph75at2OAeJZrHQ.jpeg" /></figure><p>“Never let a good crisis go waste”, said a wise man. We have not. Covid has only made us sharper and more closer to our customers. The best part is- despite hiccups, we are still focussed and missionary in our zeal to empower the smallest entrepreneurs of India. We achieved quite a lot during the year, hence gratitude is the right way to end 2021. There are no failures, only learnings. #noregrets. Here’s to hope and positivity to welcome 2022.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e552487081ea" width="1" height="1" alt=""><hr><p><a href="https://medium.com/okcredit/winding-back-the-clock-on-2021-many-sweet-and-a-few-sour-memories-e552487081ea">Winding back the clock on 2021: Many sweet and a few sour memories</a> was originally published in <a href="https://medium.com/okcredit">OkCredit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>