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

[Linux] Path is not clipping inside a ScrollViewer. #18473

Open
ramezgerges opened this issue Oct 15, 2024 · 2 comments
Open

[Linux] Path is not clipping inside a ScrollViewer. #18473

ramezgerges opened this issue Oct 15, 2024 · 2 comments
Assignees
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification

Comments

@ramezgerges
Copy link
Contributor

ramezgerges commented Oct 15, 2024

Current behavior

In the repro below, scrolling the scrollviewer will make the Path inside remain visible even though it should be partially clipped. The shocking part is that this only happens on Linux. The WPF target on Windows clips accurately. Note that the repro seems to be very stable. I've tried a bunch of variations and they all repro 100% of the time.

The problem was originally discovered in SamplesApp (notice the unclipped chevron):
image

Expected behavior

The Path should only be visible within the viewport of the ScrollViewer.

How to reproduce it (as minimally and precisely as possible)

	<StackPanel>
		<Border Height="100" HorizontalAlignment="Stretch" Background="Blue" />
		<ScrollViewer Height="30">
			<StackPanel>
				<Path Data="m 0,0 c -0.639,0 -1.276,0.243 -1.765,0.729 -0.977,0.974 -0.98,2.557 -0.006,3.535 L 16.925,23.032 -1.768,41.725 c -0.976,0.976 -0.976,2.559 0,3.535 0.977,0.976 2.559,0.976 3.536,0 L 22.225,24.803 c 0.975,-0.975 0.976,-2.555 0.004,-3.532 L 1.771,0.736 C 1.283,0.245 0.642,0 0,0" Fill="Red" />
			</StackPanel>
		</ScrollViewer>
	</StackPanel>

Workaround

No response

Works on UWP/WinUI

None

Environment

No response

NuGet package version(s)

No response

Affected platforms

No response

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

@ramezgerges ramezgerges added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels Oct 15, 2024
@ramezgerges ramezgerges self-assigned this Oct 15, 2024
@ramezgerges
Copy link
Contributor Author

I've reduced the render cycle to drawing the visual of the Path only and it still reproduced. Here are the insane results of this investigation:

  1. The problematic part is
session.Canvas.DrawPath(geometryWithTransformations, fillPaint)

inside CompositionSpriteShape.skia.cs, which actually draws the path. The code is accurate and works on WPF as mentioned above, but it somehow completely ignores the SKCanvas's current clipping. The canvas's clip numbers are accurate, they're just ignored as if the clip rect didn't exist.
2. Changing that line to

session.Canvas.DrawPath(SKPath.ParseSvgPathData(geometryWithTransformations.ToSvgPathData()), fillPaint);

which just encodes the SKPath to svg and decodes it again makes things work correctly!!! This, however, doesn't work:

session.Canvas.DrawPath(new SKPath(geometryWithTransformations), fillPaint);
  1. Another solution is to create a new SKPaint. Replacing the problematic line with
session.Canvas.DrawPath(SKPath.ParseSvgPathData(geometryWithTransformations.ToSvgPathData()), new SKPaint() { Color: SKColors.Red });

fixes the bug too.
4. Yet another solution is to set IsAntiAlias on the SKPaint to false. (╯°□°)╯︵ ┻━┻

@ramezgerges
Copy link
Contributor Author

Update: This gets fixed using SkiaSharp 3.0.0-preview.4.1 (or any version >= 3.0.0 I guess), which confirms that it's a bug in skia.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification
Projects
None yet
Development

No branches or pull requests

1 participant