Skip to content

Fix infinite recomposition in Text.foregroundStyle(LinearGradient())#438

Open
dfabulich wants to merge 1 commit into
skiptools:mainfrom
dfabulich:gradient-infinite-recomposition
Open

Fix infinite recomposition in Text.foregroundStyle(LinearGradient())#438
dfabulich wants to merge 1 commit into
skiptools:mainfrom
dfabulich:gradient-infinite-recomposition

Conversation

@dfabulich
Copy link
Copy Markdown
Contributor

Fixes #437

Skip Pull Request Checklist:


  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.

Cursor tracked this down and fixed it. I manually tested it with skiptools/skipapp-showcase#107 in Showcase Lite mode.

@cla-bot cla-bot Bot added the cla-signed label May 18, 2026
@dfabulich
Copy link
Copy Markdown
Contributor Author

I think this was caused by #424 … not sure if I'm undoing your fix in this PR.

But… what did it fix, exactly? Was there a bug you were fixing there that I could repro, and test that I didn't just re-break it?

@marcprux
Copy link
Copy Markdown
Member

I think you are right. I've updated the rationale for that earlier (admittedly minimally tested) fix at: #424 (comment)

I had intended to have the brush itself be remember'd — I'm not sure how I missed that. I've confirmed that your fix also fixes the original bug I was seeing.

@Composable override func asBrush(opacity: Double, animationContext: ComposeContext?) -> Brush? {
let stops = gradient.colorStops(opacity: opacity)
return LinearGradientShaderBrush(colorStops: stops, startPoint: startPoint, endPoint: endPoint)
return remember(gradient, startPoint, endPoint, opacity) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add remember(…) to the two places we create a RadialGradientShaderBrush?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Infinite recomposition rendering Text with a .foregroundStyle(LinearGradient())

2 participants