Skip to content

Fix color stop interpolation when positioned stop has no gap before it#57356

Open
nduaarte wants to merge 1 commit into
react:mainfrom
nduaarte:fix/color-stop-interpolation
Open

Fix color stop interpolation when positioned stop has no gap before it#57356
nduaarte wants to merge 1 commit into
react:mainfrom
nduaarte:fix/color-stop-interpolation

Conversation

@nduaarte

Copy link
Copy Markdown

Summary:

Fixes #57345

ColorStopUtils.getFixedColorStops() produced incorrect positions when a
color stop with an explicit position was immediately followed by a color
stop without a position (i.e. zero unpositioned stops between them).

The root cause is that lastDefinedIndex was only advanced when
interpolation actually occurred (unpositionedStops > 0). When a positioned
stop was encountered with no unpositioned stops before it, lastDefinedIndex
failed to advance, causing the next interpolation to use a stale start
point and silently overwrite the explicitly declared position of the
skipped stop.

The fix adds an else if branch that advances lastDefinedIndex whenever
the current stop has a defined position, even when no interpolation is
needed at that step.

Changelog:

[ANDROID] [FIXED] - Fix incorrect color stop positions in gradients when a positioned stop is immediately followed by an unpositioned stop

Test Plan:

Added testColorStopsWithPositionedStopAdjacentToUnpositionedStop to
ColorStopTest.kt, covering the exact case from the issue:

Input: [red 0%, green 20%, blue (no position), yellow 80%, purple 100%]
Expected: [0.0, 0.2, 0.5, 0.8, 1.0]

Before the fix this produced [0.0, 0.267, 0.533, 0.8, 1.0].

Verified the new test passes via CI (no local Android environment available).

@meta-cla

meta-cla Bot commented Jun 28, 2026

Copy link
Copy Markdown

Hi @nduaarte!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Jun 28, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 28, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] CSS gradient color stop interpolation incorrect when positioned stops are adjacent to unpositioned stops

1 participant