jeziellago / compose-markdown

Markdown Text for Android Jetpack Compose 📋.
MIT License
590 stars 50 forks source link

Resize on rendering table. #106

Closed zjn0505 closed 4 months ago

zjn0505 commented 4 months ago

I am using version 4.6.2 to render OpenAI LLM streaming outputs which could be Markdown format.

The text grows when the streaming output is received in every 10 - 100 milliseconds.

I see when it is rending emojis or table. It will resize dramatically.

Here is a simulated case by emitting characters to a muteableState.

// A mutable state holding text
private var chat  by mutableStateOf("        "))

// Add this MarkdownText to LazyColumn in the sample app

MarkdownText(
    modifier = Modifier
        .padding(start = 20.dp, end = 20.dp)
        .background(
            color = Color(0xff191919),
            shape = RoundedCornerShape(topStart = 0.dp, topEnd = 15.dp, 15.dp, 15.dp)
        )
        .padding(horizontal = 25.dp, vertical = 15.dp),
    markdown = chat,  // text will grow every 50 ms
    fontResource = R.font.opensans_regular,
    style = TextStyle(
        color = Color.White,
        fontSize = 23.sp,
        fontWeight = FontWeight.Light,
        lineHeight = 15.sp,
    )
)

https://github.com/jeziellago/compose-markdown/assets/6925920/416173f5-835a-4013-af46-48f62f0962c0

As can be seen in the video, when rendering the table, it resizes rapidly.

Sometimes I will encounter a horizontal flicking when rending a row of emojis, but in this video I could only reproduce the vertical flicking when rendering a table.

I suppose I should look into Layer Inspector and try to remember the max. size for my use case.

zjn0505 commented 4 months ago

I suppose it is related to Markwon.

After remembering the max size, it is getting better, as the textview is no longer flicking. But still the table itself is not looking good when being built.

zjn0505 commented 4 months ago

Close this as I think it is in Markwon..