Fix possible text styles cache corruption#2630
Merged
siarb merged 1 commit intorelease/1.10from Jan 13, 2026
Merged
Conversation
igordmn
approved these changes
Dec 9, 2025
MatkovIvan
added a commit
that referenced
this pull request
Dec 9, 2025
Fixes [CMP-8028](https://youtrack.jetbrains.com/issue/CMP-8028) Text color is sometimes randomly black on iOS when using Compose Multiplatform (BasicText) The main change here is to make sure that keys in `skTextStylesCache` are immutable. However, during the paragraph building, we need this class to be mutable to avoid unnecessary allocations. While it's possible to fix the issue with just a few lines (#2630), it seems really dangerous long term, so this PR replaces `ComputedStyle` to `sealed intefrace` with both variants to ensure immutability at compile time instead. In addition to that, it contains a small cleanup of code around: - Add `@InternalTextApi` to functions with `TODO: Remove from public`, so we can actually remove them later - Optimize cleaning up styles cache: remove in-place during iteration to avoid allocation of extra list and additional look-ups ## Testing - Existing tests on CI - Reproducer from [CMP-8028](https://youtrack.jetbrains.com/issue/CMP-8028) ```kt val textMeasurer = rememberTextMeasurer(cacheSize = 100) Canvas(Modifier.background(Color.DarkGray)) { for (i in 0 until 100) { drawText( textLayoutResult = textMeasurer.measure(text = "$i"), color = Color.White, topLeft = Offset(x = i % 10 * 50f, y = i / 10 * 50f) ) } } ``` Additional auto tests are problematic because the issue reproduces only on K/N (both macOS and iOS) where we didn't have infrastructure for fonts-related testing yet. ## Release Notes ### Fixes - iOS - Fix possible text styles cache corruption (text color is sometimes randomly black)
ASalavei
approved these changes
Dec 9, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes CMP-8028 Text color is sometimes randomly black on iOS when using Compose Multiplatform (BasicText)
It's a minimal, simplified version of #2629
Testing
Release Notes
Fixes - iOS