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

Setting Panel.Clip and Composition.Visual.Clip causes a crash #4914

Open
Foda opened this issue Nov 22, 2024 · 0 comments
Open

Setting Panel.Clip and Composition.Visual.Clip causes a crash #4914

Foda opened this issue Nov 22, 2024 · 0 comments

Comments

@Foda
Copy link
Member

Foda commented Nov 22, 2024

Describe the bug

Setting Panel.Clip and Composition.Visual.Clip causes a crash:

E_NOINTERFACE - No such interface supported in Microsoft_UI_Xaml!HWCompTreeNodeWinRT::UpdateVisualClipAndTransform

Steps to reproduce the bug

  1. Create a custom panel and set the Panel.Clip property and Composition.Visual.Clip property:
public class LayoutPanel : Panel
{
	public LayoutPanel()
	{
		this.SizeChanged += LayoutPanel_SizeChanged;
	}

	private void LayoutPanel_SizeChanged(object sender, SizeChangedEventArgs e)
	{
		var visual = ElementCompositionPreview.GetElementVisual(this);
		var compositor = visual.Compositor;

		var device = CanvasDevice.GetSharedDevice();
		CanvasPathBuilder pathBuilder = new CanvasPathBuilder(device);
		pathBuilder.BeginFigure(1, 1);
		pathBuilder.AddLine(300, 300);
		pathBuilder.AddLine(1, 300);
		pathBuilder.EndFigure(CanvasFigureLoop.Closed);

		CanvasGeometry geometry = CanvasGeometry.CreatePath(pathBuilder);

		var path = new CompositionPath(geometry);
		var pathGeometry = compositor.CreatePathGeometry(path);
		var geometricClip = compositor.CreateGeometricClip(pathGeometry);
		visual.Clip = geometricClip;
	}

	protected override Size ArrangeOverride(Size finalSize)
	{
		var actual = base.ArrangeOverride(finalSize);
		Clip = new RectangleGeometry { Rect = new Rect(0, 0, finalSize.Width, finalSize.Height) };
		return actual;
	}
}
  1. Try and use the panel:
<local:LayoutPanel Background="Red">
	<TextBlock Text="Label Inside the Border"/>
</local:LayoutPanel>

Expected behavior

This should not crash

Screenshots

No response

NuGet package version

Windows App SDK 1.6.3: 1.6.241114003

Packaging type

Packaged (MSIX), Unpackaged

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

No response

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

1 participant