<?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 Sutaek Oh on Medium]]></title>
        <description><![CDATA[Stories by Sutaek Oh on Medium]]></description>
        <link>https://medium.com/@diskerr_17971?source=rss-ac58ef98eb1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*0nYRMADObM6j49Fd.jpg</url>
            <title>Stories by Sutaek Oh on Medium</title>
            <link>https://medium.com/@diskerr_17971?source=rss-ac58ef98eb1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 14:46:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@diskerr_17971/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[ImmutableList vs. List in Jetpack Compose: Rethinking “Best Practice” After Strong Skipping Mode]]></title>
            <link>https://medium.com/@diskerr_17971/immutablelist-vs-list-in-jetpack-compose-rethinking-best-practice-after-strong-skipping-mode-d364bbba46b2?source=rss-ac58ef98eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/d364bbba46b2</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[compose]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Sutaek Oh]]></dc:creator>
            <pubDate>Wed, 21 Jan 2026 13:20:32 GMT</pubDate>
            <atom:updated>2026-01-25T18:28:27.252Z</atom:updated>
            <content:encoded><![CDATA[<p>Before <strong>Strong Skipping Mode </strong>[<a href="https://developer.android.com/develop/ui/compose/performance/stability/strongskipping">1</a>]<strong> </strong>became the default, it was widely considered best practice in Compose to prefer <strong>immutable collections</strong> (e.g., kotlinx ImmutableList&lt;T&gt;) over <strong>unstable collections</strong> like List&lt;T&gt; for “stability” and better skipping behavior.</p><p>With <strong>Strong Skipping Mode</strong> now being the default, the situation has changed. In most real-world screens, immutable collections don’t automatically outperform unstable ones — in many cases they provide little to no performance benefit, and can even become pure overhead due to conversion and equality costs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nvxot2lpHof33QJjDw8Wyg.png" /></figure><h3><strong>Case-by-Case Analysis</strong></h3><p>To make this discussion concrete, I’ll compare ImmutableList&lt;T&gt; and List&lt;T&gt; across three common cases.</p><p>In most Android apps, data from Retrofit, Ktor, Room, or similar libraries usually comes as List&lt;T&gt;. So using ImmutableList&lt;T&gt; for Compose stability typically means calling toImmutableList().</p><p>With that in mind, this post assumes:</p><ul><li>List&lt;T&gt; is not backed by a MutableList&lt;T&gt; that is mutated from elsewhere.</li><li>ImmutableList&lt;T&gt; is created via toImmutableList().</li></ul><p>Also, this post only discusses Compose skippability, not the architectural benefits of immutable collections.</p><h4>Case 1. The list never changes (always the same instance)</h4><p>If your list never changes and you keep the exact same instance, List&lt;T&gt; and ImmutableList&lt;T&gt; behave almost the same in practice: both end up with the cost of an <strong>instance equality check</strong> (===).</p><p>Though ImmutableList&lt;T&gt; still has an <strong>O(N) conversion cost</strong> (e.g., toImmutableList()), it&#39;s usually negligible since you do it only once in this case.</p><h4>Case 2. The list instance changes only when the content actually changes</h4><p>In this scenario, using ImmutableList&lt;T&gt; adds extra work: you pay a <strong>conversion cost</strong> to build it, and you also pay an <strong>O(N) object equality cost </strong>(structural equality, == or equals()) when Compose compares the new parameter to the previous one. Since you need to recompose anyway, that extra work is <strong>pure overhead</strong> — and List&lt;T&gt; avoids both costs.</p><h4>Case 3. The content doesn’t change, but a new list instance is created frequently</h4><p>This is the one case where ImmutableList&lt;T&gt; can help. If you keep recreating List&lt;T&gt; instances with the same content, Compose will treat the parameter as changed because the <strong>instance equality</strong> check fails. With ImmutableList&lt;T&gt;, Compose can use <strong>object equality</strong> to recognize “same content” and skip work higher up the composition tree.</p><p>The catch is the cost: equals() for lists is <strong>O(N)</strong>, and you’re also paying the conversion cost upfront. If most of the UI work is already isolated in skippable leaf composables, these costs are sometimes harder to justify than just letting List&lt;T&gt; flow down and relying on skipping at the leaf — especially with lazy composables like LazyColumn.</p><p>And there’s another catch: instance changes without content changes can sometimes be filtered upstream, turning Case 3 into Case 2 — for example, using StateFlow&lt;T&gt; in your ViewModel. Details are in the <strong>Appendix</strong>.</p><p>So even in this case, ImmutableList&lt;T&gt; isn’t an automatic win.</p><h3>Conclusion</h3><p>If your concern is skippability, there’s no need to convert List&lt;T&gt; coming from your data sources — the old assumption that &quot;unstable = always bad&quot; no longer holds. Still, ImmutableList&lt;T&gt; can sometimes be worth the overhead for better skippability — and it may offer architectural benefits beyond what this post covers. So if you’re already using it, there’s no reason to switch back to List&lt;T&gt; either. Don’t worry too much upfront. It’s enough to optimize when you see a real bottleneck.</p><p>Remember: not every composable should be skippable. [<a href="https://developer.android.com/develop/ui/compose/performance/stability/fix#not-composable">2</a>] And not every list needs to be ImmutableList&lt;T&gt;.</p><h3><strong>Appendix. Case-by-Case Details</strong></h3><h4>Case 3–1. Lazy composables</h4><p>With lazy composables like LazyColumn, it’s easy to overestimate <strong>what you</strong> <strong>save by skipping </strong>higher up. Even if the parent recomposes, actual work is still bounded by the visible range, rather than scaling with the total list size. In that setup, paying O(N) for equals() and conversion can outweigh the work saved by higher-level skipping.</p><h4>Case 3–2. StateFlow&lt;T&gt; and upstream filtering</h4><p>StateFlow&lt;T&gt; has distinctUntilChanged() built-in: if the new value equals the current one, it doesn&#39;t emit and keeps the existing instance. So if you call update { it.copy(list = ...) } with the same content and nothing else changed, StateFlow&lt;T&gt; won&#39;t emit — the original list instance stays intact. This effectively turns Case 3 into Case 2. Thus, in this scenario, List&lt;T&gt; saves a conversion cost and an object equality check cost as described in Case 2.</p><p>Note: StateFlow&lt;T&gt; doesn’t eliminate Case 3 entirely. For example, if you call update { it.copy(list = newInstance, isLoading = true) } and only isLoading actually changed, StateFlow&lt;T&gt; will emit because T.equals() returns false — and the new list instance gets delivered anyway.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d364bbba46b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fixing Animated WebP Jitter on Android with Jetpack Compose]]></title>
            <link>https://medium.com/@diskerr_17971/fixing-animated-webp-jitter-on-android-with-jetpack-compose-45c9e8f67adb?source=rss-ac58ef98eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/45c9e8f67adb</guid>
            <category><![CDATA[coils]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Sutaek Oh]]></dc:creator>
            <pubDate>Sat, 10 Jan 2026 09:27:07 GMT</pubDate>
            <atom:updated>2026-01-29T02:03:32.566Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever noticed some animated WebP images jittering by about 1 pixel on Android? It’s subtle, but it becomes obvious once you notice it. This post covers why it happens and how to fix it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*ev68M2JMxCTSqh7x_R8fNw.gif" /><figcaption>1px jitter visible on grid lines</figcaption></figure><p>In my testing, this issue reproduced on Android 15 and earlier, but not on Android 16 (tested on emulator and Samsung Galaxy S23+). However, many users are still on older OS versions, so this workaround remains relevant. A repro asset is included at the end of this post if you want to test it yourself.</p><h3>The Problem</h3><p>I was displaying animated WebP images in an app when I noticed them shaking slightly — about 1 pixel. It only happened at certain downscaled sizes, and the same image displayed normally in Chrome on the same device.</p><p>In our production setup, this issue is common. Design assets are typically exported at higher resolutions than their display size, and most animations are delivered as animated WebP. So downscaling is almost always involved.</p><h3>Root Cause Analysis</h3><p>This happens when animated WebP is decoded via ImageDecoder (Android 9+) into AnimatedImageDrawable — the common setup for Coil and Glide.</p><p>After digging in, I found the issue occurs when two conditions are met:</p><ol><li>The animated WebP uses <strong>partial frames</strong></li><li>The image is scaled at a <strong>non-integer ratio</strong> (e.g., 0.7x, 0.8x)</li></ol><h4>What Are Partial Frames?</h4><p>Animated images can store frames in two ways:</p><ul><li><strong>Full frames</strong>: Every frame contains the complete image.</li><li><strong>Partial frames</strong>: Only the changed region relative to the previous frame is stored.</li></ul><p>Partial frames (or delta frames) reduce file size, so they’re often the default. Each one also includes coordinates (offset) like “draw this patch at position (x: 100, y: 100).”</p><h4>Why Non-Integer Scaling Causes Problems</h4><p>Since Android generally handles image placement coordinates in integer pixel units, the renderer must round scaled coordinates to integers. The problem is that partial frames can have slightly different offsets, and rounding errors vary depending on the scale ratio.</p><p>For example, at 0.7x scaling with offsets that shift by 2px each frame (100 → 102 → 104 → 106):</p><ul><li>100 × 0.7 = 70.0 → 70</li><li>102 × 0.7 = 71.4 → 71</li><li>104 × 0.7 = 72.8 → 73 ← skips 72</li><li>106 × 0.7 = 74.2 → 74</li></ul><p>Rendered positions: 70 → 71 → 73 → 74 (irregular spacing causes jitter)</p><p>This manifests in two ways:</p><ol><li><strong>Jittering/Shaking</strong>: The partial frame position shifts by 1 pixel between frames, making the image appear to vibrate.</li><li><strong>Gray lines/Seams</strong>: A thin gray line where the image was cut and reassembled.</li></ol><p>Both symptoms have the same root cause, so the fix is identical.</p><h3>The Solution</h3><p>Assuming you’re using Coil with Jetpack Compose. If you don’t override size, Coil resolves the request size from the destination constraints and passes it to ImageDecoder. <strong>The jitter only reproduced when decoded at a scaled size.</strong></p><p>The fix is simple — <strong>decode at original size (</strong><strong>Size.ORIGINAL), and let Compose handle the scaling to fit your layout constraints:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a9e9235c7b20da9243b1ae3dfa941698/href">https://medium.com/media/a9e9235c7b20da9243b1ae3dfa941698/href</a></iframe><h4>Fixing Scaling Quality Degradation</h4><p>The above workaround fixes the jitter, but there’s a catch: <strong>scaling quality can degrade on some devices.</strong></p><p>By decoding at Size.ORIGINAL, scaling shifts to the draw path of AnimatedImageDrawable, and the filtering quality can be noticeably worse. I tried a few common quality-tuning knobs, but none made a difference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*JE4smge5Us_l7PC8ZMgccg.png" /><figcaption>Quality loss with first workaround</figcaption></figure><p>To fix the quality issue, render at original size into an offscreen layer first, then scale the <strong>layer output</strong> via GPU:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54730390adc2132196184a87d7ca6f21/href">https://medium.com/media/54730390adc2132196184a87d7ca6f21/href</a></iframe><p>With CompositingStrategy.Offscreen, the drawable renders into an offscreen buffer, and scaledLayout() ensures it renders at original size by passing unbounded constraints. Then placeWithLayer() applies GPU-accelerated scaling to the buffer output, bypassing AnimatedImageDrawable&#39;s low-quality draw-time scaling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gtl8OyU5IpDVHe-v3gD39g.gif" /><figcaption>Left: Default AsyncImage (1px jitter). Right: Workaround applied (stable + clean).</figcaption></figure><p>In production, you may want to skip this workaround on Android 16+ where I couldn’t reproduce the issue.</p><h3>Trade-offs</h3><p>This solution uses somewhat more memory — you’re decoding at original size, plus maintaining a full-size offscreen canvas. It also adds GPU overhead from offscreen rendering and scaling. However, in my testing on lower-end devices, I didn’t observe any noticeable performance impact. It’s a reasonable trade-off for smooth animations.</p><h3>Repro Asset</h3><p><a href="https://github.com/diskerr/blog-resources/blob/main/jitter-sample.webp">blog-resources/jitter-sample.webp at main · diskerr/blog-resources</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45c9e8f67adb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>