<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Lakshmi Priya S P on Medium]]></title>
        <description><![CDATA[Stories by Lakshmi Priya S P on Medium]]></description>
        <link>https://medium.com/@lakshmipriya.sp74?source=rss-5c520ae31ab3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ivH2csjfGJH59wZG</url>
            <title>Stories by Lakshmi Priya S P on Medium</title>
            <link>https://medium.com/@lakshmipriya.sp74?source=rss-5c520ae31ab3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 23:43:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lakshmipriya.sp74/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Flutter LMK Guide: Fix Low Memory Kills]]></title>
            <link>https://medium.com/@lakshmipriya.sp74/flutter-lmk-guide-fix-low-memory-kills-fc8e9ddff02a?source=rss-5c520ae31ab3------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc8e9ddff02a</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[performance-optimization]]></category>
            <category><![CDATA[crashlytics]]></category>
            <category><![CDATA[flutter-development]]></category>
            <category><![CDATA[mobile-app-performance]]></category>
            <dc:creator><![CDATA[Lakshmi Priya S P]]></dc:creator>
            <pubDate>Wed, 07 Jan 2026 15:22:43 GMT</pubDate>
            <atom:updated>2026-01-07T15:22:43.096Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter Performance Optimization (Part 2): Low Memory Kills (LMKs)</h3><p>When developers see a crash, they react. When they see an ANR, they panic. But when they see a <strong>Low Memory Kill (LMK)</strong> — most of the time, they ignore it.</p><p>That’s because LMKs don’t come with stack traces. They don’t point to a specific line of code. And they don’t look like crashes in traditional logs.</p><p>Yet from a user’s perspective, LMKs feel just as bad — sometimes worse. The app reloads unexpectedly, state is lost, and the user assumes the app is unreliable.</p><p>In this article, we’ll break down what LMKs really are, why Flutter apps are particularly vulnerable, how to diagnose them using Play Console signals, and how to design your app so LMKs stop happening silently in production.</p><h3>What Is a Low Memory Kill (LMK)?</h3><p>A <strong>Low Memory Kill</strong> occurs when the Android operating system terminates an app’s process because the device is running low on available memory. In Play Console, LMKs are tracked as a stability metric because they directly affect crash-free user sessions.</p><p>Key characteristics of LMKs:</p><ul><li>The app <strong>does not crash</strong></li><li>No exception is thrown in your code</li><li>No crash dialog is shown to the user</li><li>The OS kills the process to protect overall system stability</li></ul><p>From Android’s perspective, this is <strong>normal resource management</strong>.</p><p>From the user’s perspective:</p><ul><li>The app suddenly restarts</li><li>Previously open screens are lost</li><li>Ongoing actions disappear</li></ul><p>To users, <strong>an LMK is indistinguishable from a crash</strong>.</p><h4>Why LMKs Are Harder to Debug Than Crashes</h4><p>Unlike crashes or ANRs:</p><ul><li>LMKs don’t generate stack traces</li><li>Crashlytics often shows <em>nothing, </em>because the app is terminated externally by the OS.</li></ul><p>This leads to a common (and dangerous) assumption:</p><blockquote><em>“There’s no bug — the OS just killed the app.”</em></blockquote><p>In reality, <strong>LMKs are almost always a signal of excessive memory usage</strong>, especially on constrained devices. They are often misclassified as “random restarts,” which delays root-cause analysis and leads to repeated regressions.</p><h4>Diagnosing LMKs Using Android Vitals</h4><p>The first step in addressing LMKs is recognizing them <strong>correctly</strong>.</p><h4>Where LMKs Appear</h4><p>In Google Play Console:</p><ul><li>Android Vitals Overview → User-perceived LMK rate</li><li>Reported per device class, OS version, and RAM tier</li></ul><h4>Key Diagnostic Pattern</h4><p>In real-world production data, LMKs almost always show consistent patterns:</p><ul><li>Spike on <strong>≤ 4GB RAM devices</strong></li><li>Appear more frequently on:<br> a. Older Android versions<br> b. OEMs with aggressive memory policies</li><li>Correlate with:<br> a. Media-heavy screens<br> b. Long navigation flows<br> c. Background → foreground transitions</li></ul><p>If your LMK graph looks “fine” on high-end devices but spikes on low-end phones, <strong>that’s not random</strong> — it’s a design mismatch.</p><h4>Why Flutter Apps Are Especially Prone to LMKs</h4><p>Flutter apps are uniquely sensitive to memory pressure because:</p><ul><li>Images are decoded into <strong>uncompressed bitmaps in memory</strong></li><li>Animations retain <strong>GPU textures</strong></li><li>Widgets and controllers can outlive screens</li><li>SDKs allocate native buffers invisibly</li><li>Dart objects and native memory coexist</li></ul><p>Unlike crashes or ANRs, LMKs are rarely caused by a single mistake.</p><p>They are usually the result of:</p><blockquote><strong><em>Many small memory decisions compounding over time.</em></strong></blockquote><p>This is why LMKs must be addressed <strong>architecturally</strong>, not with isolated fixes.</p><h3>What Happens at the OS Level During a Low Memory Kill (LMK)</h3><p>When an Android device runs low on available RAM, the operating system prioritizes keeping the system responsive over preserving individual apps. Android continuously monitors memory pressure across the system and assigns each app process a priority (OOM score) based on its state (foreground, visible, background, cached).</p><p>When memory becomes critically low, the OS invokes the <strong>Low Memory Killer</strong>, which terminates one or more lower-priority processes to immediately reclaim RAM. This termination happens <strong>without notifying the app</strong>, without throwing an exception, and without generating a stack trace.</p><p>From the app’s perspective, execution simply stops. When the user returns, Android recreates the process from scratch, causing the app to reload and lose state.</p><p>On devices with limited RAM or aggressive OEM memory policies, this process happens more frequently, especially when apps consume large amounts of memory through images, animations, media buffers, or retained objects — leading users to perceive these forced restarts as crashes or instability.</p><h3>Fixing LMKs in Practice: High-Impact Strategies That Actually Work</h3><p>Low Memory Kills cannot be fixed with a single patch or optimization. They require <strong>deliberate design decisions</strong> that reduce peak memory usage, shorten object lifetimes, and adapt behavior based on device constraints.</p><h4>1. Device-Aware Rendering for Heavy Animations and Media</h4><p>Animations — especially Lottie and video — consume CPU, GPU memory, and heap memory. On low-RAM devices, these costs compound quickly.</p><h4>Strategy</h4><p>Before rendering heavy animations:</p><ul><li>Inspect device memory characteristics</li><li>Check available and free RAM</li><li>Fall back to static assets when needed</li></ul><pre>class DeviceSpecs {<br>  static bool checkRamCapability() {<br>    final int totalMb =<br>        SysInfo.getTotalPhysicalMemory() ~/ (1024 * 1024);<br>    final int availableMb =<br>        SysInfo.getAvailablePhysicalMemory() ~/ (1024 * 1024);<br>    final int freeMb =<br>        SysInfo.getFreePhysicalMemory() ~/ (1024 * 1024);<br><br>    if (totalMb &lt; 4000 || availableMb &lt; 400 || freeMb &lt; 120) {<br>      return false;<br>    }<br>    return true;<br>  }<br><br>  static bool evaluateDevicePerformance() {<br>    return checkRamCapability();<br>  }<br>}</pre><h4>Outcome</h4><ul><li>Rich animations preserved on capable devices</li><li>Static images rendered on constrained devices</li><li>Significant reduction in memory spikes and LMKs</li></ul><blockquote><strong><em>Key insight:</em></strong><em> LMKs are often a </em>device-class problem<em>, not a global one.</em></blockquote><h4>2. Image Cache &amp; Decode Size Control</h4><p>Flutter’s default ImageCache retains decoded images aggressively.</p><pre>void configureImageCache() {<br>  PaintingBinding.instance.imageCache.maximumSize = 50;<br>  PaintingBinding.instance.imageCache.maximumSizeBytes =<br>      1024 * 1024 * 60; // 60 MB<br>}</pre><p>Call this early in your app lifecycle.<br> <strong>Note:</strong> Cache limits should be tuned based on your app’s image usage patterns and tested on low-RAM devices.</p><h4>3. Explicitly Disposing All Controllers</h4><p>Controllers are one of the most common sources of <strong>silent memory retention</strong> in Flutter.</p><p>This includes:</p><ul><li>AnimationControllers</li><li>ScrollControllers</li><li>PageControllers</li><li>TextEditingControllers</li><li>Video or media controllers</li></ul><h4>Why This Matters</h4><p>Controllers often hold:</p><ul><li>Native handles</li><li>GPU resources</li><li>Internal listeners</li></ul><p>If not disposed, they <strong>outlive their screens</strong>, keeping memory alive unnecessarily.</p><h4>Rule of Thumb</h4><blockquote><em>If a widget creates a controller, it must dispose it.</em></blockquote><p>This alone can dramatically lower baseline memory usage across navigation flows.</p><h4>4. Cancel Stream Subscriptions and Listeners</h4><p>Streams, event buses, and listeners are easy to forget — and costly when leaked.</p><h4>Common LMK Pattern</h4><ul><li>Widget subscribes to a stream</li><li>Widget is popped</li><li>Stream continues emitting</li><li>References are retained</li><li>Memory accumulates invisibly</li></ul><h4>Best Practice</h4><ul><li>Cancel all subscriptions in dispose()</li><li>Avoid long-lived global listeners unless absolutely necessary</li><li>Prefer scoped streams tied to widget lifecycle</li></ul><p>Reducing retained listeners directly reduces <strong>heap pressure</strong>, which lowers LMK probability.</p><h4>5. Audit Complex UI Flows for Lifecycle Leaks</h4><p>Screens with:</p><ul><li>Nested navigators</li><li>Bottom sheets</li><li>Carousels</li><li>Multi-step flows</li></ul><p>are especially prone to objects <strong>outliving their intended lifecycle</strong>. A common signal is memory usage not dropping after popping screens.</p><h4>What to Review</h4><ul><li>Are widgets kept alive unnecessarily? (Are you using PageStorage or AutomaticKeepAliveClientMixin without need?)</li><li>Are animations paused and disposed?</li><li>Are references held across navigation boundaries?</li><li>Are nested navigators retaining pages unintentionally?</li></ul><p>LMKs often originate not from one large object, but from <strong>many small ones that never die</strong>.</p><h4>6. Defer SDK Initialization Until After App Load</h4><p>Many SDKs allocate memory eagerly:</p><ul><li>Caches</li><li>Buffers</li><li>Native resources</li></ul><p>Initializing them during app startup increases <strong>peak memory usage</strong>, which is exactly when the system is most vulnerable.</p><h4>Strategy</h4><ul><li>Move non-critical SDK initialization:</li><li>After first frame</li><li>After initial navigation</li><li>Or lazily when needed</li></ul><h4>Result</h4><ul><li>Lower memory pressure during startup</li><li>Fewer LMKs during cold start and early navigation</li><li>Faster perceived app launch</li></ul><h4>7. Foreground Priority ≠ Immunity from LMKs (OS Reality)</h4><p>A common misconception is that <strong>only background apps get killed</strong>. In reality, Android uses a process score (OOM score) to determine termination order, and:</p><ul><li>Foreground apps have <em>lower</em> kill priority</li><li>But <strong>are not immune</strong> to memory pressure</li><li>Especially on low-RAM devices or aggressive OEM memory policies</li></ul><p>What this means in practice:</p><blockquote><em>Even if your app is visible or interacting with the user, the OS may still kill it if system memory is exhausted and other processes cannot be terminated first. This is not a “bug” — it’s how Android protects system responsiveness at the cost of individual process survival.</em></blockquote><p>This is exactly why LMKs often appear during:</p><ul><li>Heavy navigation transitions</li><li>First launch with rich media</li><li>On devices with constrained memory</li></ul><p>Understanding this dispels the notion that “LMKs only affect background apps.” The OS is <em>memory first, process second</em>.</p><h4>Why These Fixes Work Together</h4><p>Individually, each fix reduces memory usage slightly.</p><p>Together, they:</p><ul><li>Lower baseline memory consumption</li><li>Reduce peak memory spikes</li><li>Shorten object lifetimes</li><li>Adapt UI complexity to device capability</li></ul><p>This is exactly what the Android OS expects from well-behaved apps — and why LMKs decrease when these patterns are applied consistently.</p><h3>Monitoring Memory Pressure with Flutter DevTools</h3><p>While Flutter does not expose Low Memory Kill (LMK) events directly, <strong>memory pressure leading up to an LMK can be observed using Flutter DevTools</strong>.</p><p>Using the <strong>Memory</strong> tab in DevTools, you can:</p><ul><li>Track Dart heap growth over time</li><li>Identify sustained memory increases across navigation or animations</li><li>Detect objects that are allocated but not released after screen disposal</li><li>Spot high baseline memory usage that increases LMK risk on low-RAM devices</li></ul><p>DevTools is especially useful for validating whether fixes — such as controller disposal, image cache limits, or device-aware rendering — are actually reducing memory retention.</p><p>For a detailed, step-by-step guide, refer to the official Flutter documentation:<br> 👉 <strong>Flutter DevTools — Memory View</strong><br> <a href="https://docs.flutter.dev/tools/devtools/memory">https://docs.flutter.dev/tools/devtools/memory</a></p><h3>Final Takeaway: LMKs Are a Design Signal, Not a Bug</h3><p>Low Memory Kills are not random failures, and they are not something you can fix with a single optimization or hotfix.</p><p>They are the operating system telling you that:</p><ul><li>Your app is retaining more memory than the device can afford</li><li>Peak memory usage is too high for certain device classes</li><li>Lifecycle boundaries are being crossed silently</li></ul><p>The most effective way to reduce LMKs is not aggressive micro-optimizations, but <strong>intentional design</strong>:</p><ul><li>Design for low-RAM devices first</li><li>Treat animations and media as conditional, not default</li><li>Dispose aggressively and shorten object lifetimes</li><li>Defer heavy work until it’s truly needed</li><li>Continuously monitor LMKs as a stability signal, not noise</li></ul><p>When memory becomes a first-class concern in your Flutter architecture, LMKs stop being mysterious — and start becoming predictable and preventable.</p><h3>📖 Additional Reading &amp; References</h3><ul><li><strong>Android Developers — Low Memory &amp; App Responsiveness</strong><br> Official explanation of memory pressure, LMKs, and process prioritization.<br><a href="https://developer.android.com/topic/performance/memory"> https://developer.android.com/topic/performance/memory</a></li><li><strong>Android Developers — Android Vitals: Low Memory Kills</strong><br> How Google measures LMKs and why they affect stability metrics.<br><a href="https://developer.android.com/topic/performance/vitals/lmk"> </a><a href="https://developer.android.com/topic/performance/vitals/lmk">https://developer.android.com/topic/performance/vitals/lmk</a></li><li><strong>Flutter — Performance Best Practices</strong><br> Official guidance on image handling, rendering, and memory-friendly UI.<br> <a href="https://docs.flutter.dev/perf/best-practices">https://docs.flutter.dev/perf/best-practices</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc8e9ddff02a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter App Stability & ANR Optimization Guide]]></title>
            <link>https://medium.com/@lakshmipriya.sp74/flutter-performance-optimization-fixing-app-stability-responsiveness-android-vitals-deep-dive-eb6173470725?source=rss-5c520ae31ab3------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb6173470725</guid>
            <category><![CDATA[performance-optimization]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[flutter-development]]></category>
            <category><![CDATA[crashlytics]]></category>
            <category><![CDATA[mobile-app-performance]]></category>
            <dc:creator><![CDATA[Lakshmi Priya S P]]></dc:creator>
            <pubDate>Thu, 01 Jan 2026 04:11:03 GMT</pubDate>
            <atom:updated>2026-01-01T04:11:03.579Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter Performance Optimization (Part 1): Fixing App Stability &amp; Responsiveness (Android Vitals Deep Dive)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BGKhmM0FqRtio43emh92LA.png" /></figure><p>When we talk about <em>Flutter performance</em>, most developers think about <strong>smooth animations, jank-free scrolling, or fast app launches</strong>.</p><p>But on Google Play, none of that matters if your app <strong>freezes or crashes</strong>.</p><p>In fact, <em>App Stability &amp; Responsiveness</em> is the <strong>highest-priority Android Vital</strong>. If you violate its thresholds, Google Play will:</p><ol><li>Reduce your app’s discoverability</li><li>Lower ranking in search and recommendations</li><li>Potentially block promotional visibility</li></ol><p>This article is a deep dive into <strong>what App Stability &amp; Responsiveness really means for Flutter apps</strong>, why many issues are <strong>not Flutter bugs at all</strong>, and how we stabilized a real production app by fixing problems that <em>looked unrelated at first</em>.</p><blockquote><strong><em>Who this is for:</em></strong><em> Flutter developers shipping production apps to Google Play who want to systematically reduce ANRs, crashes, and stability regressions.</em></blockquote><h4>What Is “App Stability &amp; Responsiveness” in Play Store Terms?</h4><p>Android groups the following under this single vital:</p><h4>1. Crashes</h4><p>Your app process terminates unexpectedly due to:</p><ul><li>Unhandled Dart exceptions</li><li>Native Android crashes</li><li>Plugin-level failures</li></ul><p>To users, crashes feel sudden and unforgiving. Anything they were doing is instantly lost.</p><h4>2. ANRs (Application Not Responding) — The Most Dangerous Metric</h4><p>ANRs occur when the <strong>main UI thread is blocked for too long</strong>.</p><p>From the user’s perspective:</p><ul><li>The UI freezes</li><li>Touch input stops responding</li><li>Android shows the dreaded system dialog:</li></ul><blockquote>“This app isn’t responding”</blockquote><p>At this point, almost everyone taps <strong>“Close app”</strong>.</p><p><strong>Google treats user-perceived ANRs more severely than crashes.</strong></p><h4>3. Low Memory Kills (LMKs)</h4><p>LMKs are <strong>OS-initiated process kills</strong>, not crashes.</p><p>To users:</p><ul><li>The app suddenly reloads</li><li>State is lost</li><li>It <em>feels</em> like a crash</li></ul><p>To Play Console:</p><ul><li>LMKs count against stability metrics</li><li>Especially penalized on low-RAM devices</li></ul><h4>Why Flutter Apps Are Especially Prone to These Issues</h4><p>Flutter runs Dart code on a <strong>single main isolate</strong>.</p><p>That means:</p><ul><li>Any <strong>CPU-heavy work</strong></li><li>Any <strong>blocking plugin call</strong></li><li>Any <strong>synchronous I/O</strong></li></ul><p>…can block rendering and input handling.</p><p>Flutter does <strong>not</strong> isolate you from platform mistakes. Plugins execute real Android and iOS code, and <strong>any blocking call on the main isolate freezes the UI — just like a native app</strong>.</p><p>This is true for iOS as well. Flutter’s cross-platform nature means many of these problems reproduce on both platforms, often with different symptoms.</p><h3>1. Metric Study — Before Fixes</h3><p>Before making any changes, the first step was <strong>observability, not code changes</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-WJH1Qhn3pnZx-5ThmMjaQ.png" /></figure><p>From Android Vitals (initial 28-day observation window):</p><ul><li><strong>User-perceived crash rate</strong>: ~1.79%<br> ❌ Exceeded Google’s “bad behavior” threshold<br>❌ almost <strong>double Google’s bad-behavior threshold (~0.47%)</strong></li><li><strong>User-perceived ANR rate</strong>: <strong>~0.91%</strong><br> ❌ Exceeded Google’s “bad behavior” threshold<br> ❌ Almost <strong>50× worse than peer median</strong></li></ul><p>This clearly indicated:</p><blockquote><strong><em>The app wasn’t crashing often — it was freezing.</em></strong></blockquote><p>That distinction mattered enormously for the fix strategy.</p><h3>2. Short Case Study: What Was Actually Going Wrong?</h3><p>The investigation surfaced <strong>multiple independent stability issues</strong>, not a single root cause.</p><p>Once the metrics made it clear that <strong>freezes — not crashes — were the primary issue</strong>, we deep-dived into ANR traces and Firebase Crashlytics reports.</p><h4>A. The Real Incident: When ANRs Looked Like an SDK Bug (But Weren’t)</h4><p>Play Console showed a <strong>user-perceived ANR rate of ~0.91%</strong>, almost <strong>double Google’s bad-behavior threshold (~0.47%)</strong></p><h4>Initial Symptoms</h4><ul><li>Stack traces referenced obfuscated classes (motObfuscate.*)</li><li>Errors appeared to be triggered during <strong>Motiv8AI SDK callbacks — </strong>a 3rd party SDK used in the application</li><li>Some crashes mentioned:</li></ul><pre>IllegalStateException: You need to use a Theme.AppCompat theme</pre><p>At first glance, this looked like:</p><ul><li>A Dart runtime issue</li><li>Or a third-party SDK bug</li></ul><p>Both assumptions were wrong.</p><h4>Root Cause: A Flutter Plugin Behaving Like Native Android Code</h4><p>The real culprit was <strong>fluttertoast</strong>.</p><p>Here’s what actually happened:</p><ol><li>fluttertoast internally uses <strong>Android AppCompat UI components</strong></li><li>Our MainActivity used a <strong>non-AppCompat theme</strong></li><li>A callback from another SDK indirectly triggered a toast</li><li>Android attempted to render an AppCompat dialog</li><li>Boom → <strong>UI thread blocked → ANR / crash</strong></li></ol><p>Because everything was obfuscated, the stack trace pointed to:</p><ul><li>SDK code</li><li>Native UI internals</li><li>Random-looking classes</li></ul><p><strong>The SDK wasn’t broken — the integration was.</strong></p><h4>The Fix (And Why It Worked Everywhere)</h4><h4>A.1. Removed fluttertoast</h4><p>Transient UI feedback was replaced with:</p><ul><li>Disabled buttons</li><li>Inline Flutter widgets</li><li>State-based feedback instead of native dialogs</li></ul><p>This removed an entire class of native UI dependency.</p><h4>A.2. Defensive Android Theming</h4><p>Even for Flutter-only apps, your Android activity <strong>must be AppCompat or Material-based</strong>:</p><pre>&lt;style name=&quot;LaunchTheme&quot; parent=&quot;Theme.AppCompat.Light.NoActionBar&quot;&gt;<br>    &lt;item name=&quot;android:windowBackground&quot;&gt;@android:color/white&lt;/item&gt;<br>&lt;/style&gt;<br>&lt;style name=&quot;NormalTheme&quot; parent=&quot;Theme.AppCompat.Light.NoActionBar&quot;&gt;<br>    &lt;item name=&quot;android:windowBackground&quot;&gt;@android:color/white&lt;/item&gt;<br>&lt;/style&gt;</pre><p>This prevents crashes from:</p><ul><li>Dialogs</li><li>Toasts</li><li>Bottom sheets</li><li>Any plugin using Android UI internally</li></ul><h4>A.3. Treat Flutter Plugins as Native Code</h4><p>A key mindset shift:</p><blockquote><strong><em>Flutter plugins are not “safe abstractions.”<br> They are native Android and iOS code running inside your app.</em></strong></blockquote><p>That means:</p><ul><li>They can block the UI thread</li><li>They can crash your process</li><li>They assume platform conventions (themes, lifecycle, threading)</li></ul><h3>Other High-Frequency Issues Found in Crashlytics</h3><p>Beyond the primary ANR issue, Crashlytics revealed several <strong>classic Flutter stability patterns</strong>.</p><h4>B. Null Safety Violations During setState</h4><p>Example crash:</p><pre>type &#39;Null&#39; is not a subtype of type &#39;String&#39;</pre><p><strong>Root Cause</strong></p><ul><li>Assumed non-null values from async flows</li><li>setState executed with invalid or missing data</li></ul><p><strong>Fix</strong></p><ul><li>Explicit type checks before calling setState</li><li>Defensive null handling for async responses</li></ul><p><strong>Why This Is Common?</strong><br> Flutter’s null safety protects compilation — <strong>not runtime data</strong>.</p><h4>C. Concurrent Permission Requests</h4><p>Example crash:</p><pre>A request for permissions is already running</pre><p><strong>Root Cause</strong></p><ul><li>Permission requests triggered multiple times</li><li>No guard against parallel requests</li></ul><p><strong>Fix</strong></p><ul><li>Introduced a simple boolean / throttle</li><li>Ensured only one permission flow runs at a time</li><li>Displayed loaders instead of re-triggering requests</li></ul><h4>D. setState() Called After Widget Disposal</h4><p>Multiple crashes of the form:</p><pre>Null check operator used on a null value</pre><p><strong>Root Cause</strong></p><ul><li>Async callbacks firing after widget unmount</li><li>setState invoked on disposed widgets</li></ul><p><strong>Fix</strong></p><pre>if (!mounted) return;<br>setState(() {});</pre><p><strong>Why This Is Critical?</strong><br> This is one of the <strong>most common Flutter crash patterns</strong>, especially in:</p><ul><li>Bottom sheets</li><li>Delayed futures</li><li>Gesture callbacks</li></ul><h4>E. Using BuildContext After Disposal</h4><p>Crashes involving:</p><ul><li>State.context</li><li>RenderBox.localToGlobal</li></ul><p><strong>Root Cause</strong></p><ul><li>Context accessed after widget lifecycle ended</li><li>Native method channel callbacks firing late</li></ul><p><strong>Fix</strong></p><ul><li>Checked mounted</li><li>Avoided context-dependent calls after async delays</li><li>Added safe string and null access</li></ul><h3>3. Metric Study — After Fixes</h3><p>After deploying the fixes and observing metrics over the <strong>latest 28-day window</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*45s8x-GfafMaY0XRCFKarQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F_O1l2Z2Pw6Nbd_OHxUgdg.png" /></figure><ul><li><strong>User-perceived</strong> <strong>ANR rate reduced from ~0.91% → ~0.75%</strong></li><li><strong>Crash rate:</strong> stabilized well below bad-behavior threshold</li><li>Variance reduced significantly</li><li>Trendline consistently downward</li></ul><p>Most importantly:</p><blockquote><strong><em>The app returned below Play Store risk thresholds.</em></strong></blockquote><h3>4. Most Common Flutter Stability Issues (Industry-Wide)</h3><p>Across Flutter apps in production, these issues appear <strong>again and again</strong>.</p><h4>4.1. Blocking the Main Isolate</h4><p><strong>Cause</strong></p><ul><li>JSON parsing</li><li>File I/O</li><li>Platform calls on UI thread</li></ul><p><strong>Fix</strong></p><ul><li>Move work off the main isolate</li><li>Defer until after first frame</li><li>Use background isolates</li></ul><h4>4.2. Plugin Assumptions About Platform State</h4><p><strong>Cause</strong></p><ul><li>Plugins invoking native UI</li><li>Assumptions about themes or lifecycle</li></ul><p><strong>Fix</strong></p><ul><li>Treat plugins as <strong>native code</strong></li><li>Audit internals when crashes appear</li><li>Remove unused plugins aggressively</li></ul><h4>4.3. Memory Retention from Media &amp; Animations</h4><p><strong>Cause</strong></p><ul><li>Lottie</li><li>Videos</li><li>Large images decoded at full resolution</li></ul><p><strong>Fix</strong></p><ul><li>Device-aware rendering</li><li>Cache size limits</li><li>Static fallbacks for low-end devices</li></ul><h4>4.4. Lifecycle Mismanagement</h4><p><strong>Cause</strong></p><ul><li>Controllers not disposed</li><li>Streams not cancelled</li></ul><p><strong>Fix</strong></p><ul><li>Strict disposal discipline</li><li>Audit every screen exit path</li></ul><h4>4.5. Permission &amp; Lifecycle Races</h4><p><strong>Cause</strong></p><ul><li>Multiple permission requests</li><li>Requests triggered from rebuilds</li></ul><p><strong>Fix</strong></p><ul><li>Centralize permission handling</li><li>Throttle and serialize requests</li></ul><h3>5. Turning Fixes into Guardrails (Preventing Regressions)</h3><p>One important lesson from this stabilization effort was that <strong>fixing bugs once is not enough</strong>.</p><p>Every time a small but critical issue was identified — whether it was a missing mounted check, unsafe null access, or an implicit cast — the goal wasn’t just to fix the line of code, but to <strong>encode the lesson into the codebase itself</strong> so the same class of bug could not silently reappear.</p><p>This meant moving beyond ad-hoc fixes and introducing <strong>static guarantees and process-level safeguards</strong>.</p><h4>5.1. Enforcing Safer Defaults with Dart Analyzer &amp; Lints</h4><p>After addressing several stability issues, stricter analyzer rules were introduced to proactively catch the same patterns during development and code review.</p><h4>Analyzer Configuration</h4><pre>analyzer:<br>  language:<br>    strict-raw-types: true<br>  strong-mode:<br>    implicit-casts: false<br>    implicit-dynamic: false<br>  errors:<br>    implicit_call_tearoffs: ignore</pre><pre>include: package:flutter_lints/flutter.yaml</pre><h4>Lint Rules Added</h4><pre>linter:<br>  rules:<br>    - avoid_dynamic_calls<br>    - always_require_non_null_named_parameters<br>    - null_closures<br>    - cast_nullable_to_non_nullable<br>    - avoid_null_checks_in_equality_operators<br>    - use_build_context_synchronously<br>    - cancel_subscriptions</pre><h4>Why These Rules Matter for Stability</h4><p>These rules deliberately trade short-term convenience for long-term stability by forcing explicit lifecycle and null-safety decisions.</p><p><strong>Outcome:</strong></p><blockquote>Many bugs that previously surfaced only in production now fail at <strong>compile time or during PR review</strong>.</blockquote><h4>5.2. Making Stability a Continuous Process (Not a One-Time Fix)</h4><p>Stability is not something you “fix once and forget.” It requires <strong>continuous feedback loops</strong> at multiple levels.</p><h4>Continuous Monitoring of Production Signals</h4><p>Two dashboards became the primary early-warning system:</p><ul><li><strong>Google Play Console (Android Vitals)</strong></li><li><strong>Firebase Crashlytics</strong></li></ul><p>The key habit:</p><blockquote><em>Review these dashboards </em><strong><em>periodically</em></strong><em>, not only when alerts appear. Small regressions compound quickly if ignored.</em></blockquote><h4>5.3. Catching Stability Issues During PR Reviews</h4><p>Common review-time checks:</p><ul><li>if (!mounted) return; before setState</li><li>Async callbacks respecting lifecycle</li><li>Streams and subscriptions cancelled</li><li>Permission requests throttled</li><li>No heavy work triggered synchronously</li></ul><p>Over time, these became <strong>review heuristics</strong>, not just lint rules.</p><h4>5.4. Testing Across Device Classes (Not Just Happy Paths)</h4><p>Many stability issues only surfaced on:</p><ul><li>Low-RAM devices</li><li>Older OS versions</li><li>OEM-modified Android builds</li></ul><p>To reduce blind spots:</p><ul><li>Test on <strong>multiple device configurations</strong></li><li>Include low-end devices intentionally</li><li>Use device farms (BrowserStack, LambdaTest, Firebase Test Lab)</li></ul><p>Most importantly:</p><blockquote><strong><em>Plan releases with enough buffer time</em></strong><em> to test across devices — stability fixes require observation, not just validation.</em></blockquote><h3>Final Takeaway: Stability Is a System, Not a Patch</h3><p>What ultimately improved App Stability &amp; Responsiveness wasn’t a single fix — it was a <strong>shift in approach</strong>:</p><ul><li>Metrics guided the work</li><li>Root causes were fixed, not masked</li><li>Learnings were encoded into tooling</li><li>Reviews and testing were tightened</li><li>Monitoring became routine</li></ul><p>Flutter enables rapid development, but <strong>production stability demands discipline</strong>.</p><p>When stability becomes part of:</p><ul><li>Your analyzer rules</li><li>Your PR culture</li><li>Your release planning</li><li>Your monitoring cadence</li></ul><p>…performance improvements stop being reactive — and start becoming predictable.</p><p><strong><em>Treat stability as a system, not a sprint — and your performance metrics will stop surprising you.</em></strong></p><h3>📖 Additional Reading &amp; Industry Case Studies</h3><p>If you’d like to explore <strong>production-grade app stability and responsiveness</strong> further, these resources provide excellent real-world and platform-level perspectives:</p><ul><li><strong>Hotstar Engineering — Road to 99.9% Crash-Free Users</strong><br> A large-scale Android case study on reducing crashes through metrics-driven engineering.<br> <a href="https://blog.hotstar.com/jiohotstar-android-app-road-to-99-9-cfur-e6bdd1299558">https://blog.hotstar.com/jiohotstar-android-app-road-to-99-9-cfur-e6bdd1299558</a></li><li><strong>Android Developers — ANRs &amp; App Responsiveness</strong><br> Official documentation explaining how Android detects ANRs and why main-thread blocking is heavily penalized.<br> <a href="https://developer.android.com/topic/performance/vitals/anr?utm_source=chatgpt.com">https://developer.android.com/topic/performance/vitals/anr</a></li><li><strong>FreeCodeCamp — Firebase Crashlytics in Flutter (iOS &amp; Android)</strong><br> A practical guide to integrating and using Crashlytics effectively in Flutter apps.<br> <a href="https://www.freecodecamp.org/news/how-to-set-up-firebase-crashlytics-in-a-flutter-app-ios-and-android?utm_source=chatgpt.com">https://www.freecodecamp.org/news/how-to-set-up-firebase-crashlytics-in-a-flutter-app-ios-and-android</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb6173470725" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>