Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text color is sometimes randomly black on iOS #245

Open
DavidBuzzTheStone opened this issue Dec 26, 2024 · 14 comments
Open

Text color is sometimes randomly black on iOS #245

DavidBuzzTheStone opened this issue Dec 26, 2024 · 14 comments

Comments

@DavidBuzzTheStone
Copy link

Hi!

I have a flashcard app, and I use the Markdown() Composable to display the text on the flashcards. On iOS, the text (or certain cases, only parts of it) is shown in black, instead of the color I set.

  1. the code is fully shared between iOS and Android, yet the issue is only present on iOS
  2. it seems completely random. If I close and reopen the app, the same text might have the correct color the second time, or vice versa. I couldn't identify any pattern.
  3. sometimes only parts of the text are black, for example only the bold part (third pic)
  4. when I logged LocalMarkdownColors.current.text, the logged color code was white for those texts that appeared black, too
  5. it happens for both dark and light mode

I am happy to provide any additional info!
PS: Thank you so much for your work! It is tremendously helpful!

IMG_0033
IMG_0035
Only bold text turns black:
IMG_0032

@mikepenz
Copy link
Owner

mikepenz commented Dec 28, 2024

That's super strange. Can you reproduce this with the sample app?

Do you see it on other platforms like desktop? Wondering if it may be a compose multiplatform bug or so

@mikepenz
Copy link
Owner

(Can you please also test with v0.28.0-rc01?)

@mikepenz
Copy link
Owner

Closing due to inactivity. please report back to open up again.

@hypergonial
Copy link

hypergonial commented Feb 25, 2025

For what it's worth, I can reproduce this on iOS as well, but only on iOS, and what's even more interesting is that copying text that has turned black actually copies as black when pasted and turned into another Markdown component, even though nothing internally reports the text being black.

Unfortunately I can't find a clear way to reproduce it, but just messing around in the app for a bit seems to trigger it consistently.

My project, for reference: https://github.com/hypergonial/chat-frontend
With Markdown being used here

I can't seem to find any bug reports on the Compose YouTrack about this either, so maybe this library is doing something very specific to upset the Compose gods?

Edit: Also worth noting that this only affects text contained in Markdown composables. It does not affect any other text in the app.

@mikepenz
Copy link
Owner

@hypergonial can you please retest with the latest release v0.32.0-b01 as well?

do you set any special colors via theme or anything similar?

@hypergonial
Copy link

@hypergonial can you please retest with the latest release v0.32.0-b01 as well?

do you set any special colors via theme or anything similar?

I do quite a bit of theming via Material Kolor to support Material You on other platforms, but I am not entirely certain that it's the culprit here. In theory it should just generate a MaterialTheme and from then on it should be business as usual.

It's also highly unusual that the text initially looks fine, but after navigating back & forth in the app, it eventually turns black. And it's not consistent either, my messaging app contains a list of potentially hundreds of Markdown composables and only some of them are affected, although the ones that have been "tainted" persist until app restart.

I'll try retesting with the latest release (This was using 0.31.0) but it may take some time as I don't have immediate access to a Mac at the moment, I'll report back as soon as able.

@mikepenz
Copy link
Owner

Thank you for the additional information @hypergonial

it sounds/seems like there might be either some wrong recomposition, some state remembered which shouldn't or some other problem at play.

with 0.32.0-b01 some of the duplicated ways to set text colors have been changed to prioritize colors via the TextStyle so I'd expect this to have some impact.

No urge, thank you for spending some extra cycles on looking into that!

@hypergonial
Copy link

hypergonial commented Feb 26, 2025

Hello again,

I updated to 0.32.0-b01 and the issue is still present. It takes a bit of time scrolling back & forth the message list, sometimes minimizing the app & resuming it, but eventually it starts to fall apart again.

Here's a screenshot:

Image

Each line is a seperate Markdown component with identical configuration (besides the content, of course).

@mikepenz mikepenz reopened this Mar 1, 2025
@sigmadeltasoftware
Copy link

Can confirm the presence of this issue as well on 0.31.0.

In my case I'm using the Markdown component to render SSE-based text coming from the OpenAI API (so fast, iterative updates on the content-field) and sometimes it also causes the textcolor for certain divs/paragraphs to discolor/fallback to black for no reason.

Haven't seen this happen on Android either so it's likely iOS-specific indeed.

@mikepenz
Copy link
Owner

mikepenz commented Mar 3, 2025

Thank you for the additional input.

This is absolutely very strange, and I don't have an answer why that would be. I wonder if we can reproduce without this library using similar components, e.g. text only and style via composition local

@sigmadeltasoftware
Copy link

Thank you for the additional input.

This is absolutely very strange, and I don't have an answer why that would be. I wonder if we can reproduce without this library using similar components, e.g. text only and style via composition local

No worries, I also took a quick glance at the MarkdownParagraph / MarkdownText / MarkdownBasicText implementations and there wasn't really anything that caught my eye in terms of being a potential issue.

Given it's iOS only though, there's also a slight chance that it's related to an underlying issue in compose-multiplatform. I'll try to see if I can come up with a steady, reproducible scenario.

@sigmadeltasoftware
Copy link

Thank you for the additional input.

This is absolutely very strange, and I don't have an answer why that would be. I wonder if we can reproduce without this library using similar components, e.g. text only and style via composition local

No worries, I also took a quick glance at the MarkdownParagraph / MarkdownText / MarkdownBasicText implementations and there wasn't really anything that caught my eye in terms of being a potential issue.

Given it's iOS only though, there's also a slight chance that it's related to an underlying issue in compose-multiplatform. I'll try to see if I can come up with a steady, reproducible scenario.

Tried to recreate a scenario but it's very inconsistent throughout sessions and I also couldn't catch anything particular from the logging.

Strangely enough, I feel like it's also happening less frequently now despite not really having changed anything.

If I encounter anything usable in the future, I'll make sure to pick this one up again.

@keta1
Copy link
Contributor

keta1 commented Mar 10, 2025

Image
I tried to set two different colors for the text, blue during the light and red at dark, but the text color displayed as black.

@keta1
Copy link
Contributor

keta1 commented Mar 10, 2025

Image
The color passed to BasicText is correct, but the rendered color is incorrect.
I guess this is an internal error in compose, but I don't know how to reproduce it stably, Nor do I know how to debug compose's internal code on iOS.

Maybe this requires reporting a bug to JetBrains after this repository's sample supports run on iOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants