Labs-Windows icon indicating copy to clipboard operation
Labs-Windows copied to clipboard

(Marquee) When Behavior="Looping" and Direction is set to vertical, it causes “Layout cycle detected. Layout could not complete.”

Open lgztx96 opened this issue 3 months ago • 1 comments

Describe the bug

https://github.com/CommunityToolkit/Labs-Windows/blob/acda1c3df1b71dbf77bc80a0544eae7955398d49/components/Marquee/src/Marquee.xaml#L9

https://github.com/CommunityToolkit/Labs-Windows/blob/acda1c3df1b71dbf77bc80a0544eae7955398d49/components/Marquee/src/Marquee.Events.cs#L62

https://github.com/CommunityToolkit/Labs-Windows/blob/acda1c3df1b71dbf77bc80a0544eae7955398d49/components/Marquee/src/Marquee.cs#L241

https://github.com/CommunityToolkit/Labs-Windows/blob/acda1c3df1b71dbf77bc80a0544eae7955398d49/components/Marquee/src/Marquee.cs#L211

I noticed that the Marquee control crashes. After debugging, I believe the SizeChanged event causes the visibility of segment2 to change. Since the control’s default vertical alignment is set to Top, this triggers another SizeChanged event, resulting in an infinite loop. Setting VerticalAlignment="Stretch" allows it to work correctly, but this is not a real solution.

In addition, I noticed that _marqueeContainer is repeatedly subscribing to the SizeChanged event. https://github.com/CommunityToolkit/Labs-Windows/blob/acda1c3df1b71dbf77bc80a0544eae7955398d49/components/Marquee/src/Marquee.cs#L69

https://github.com/CommunityToolkit/Labs-Windows/blob/acda1c3df1b71dbf77bc80a0544eae7955398d49/components/Marquee/src/Marquee.Events.cs#L36

Steps to reproduce

<labs:Marquee
     Behavior="Looping"
     Content="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
     Direction="Down"
     FontSize="18"
     RepeatBehavior="Forever"
     Speed="200" />


Just setting Behavior="Looping" is enough to trigger the crash.

Expected behavior

This shouldn't cause the program to crash.

Screenshots

Image

Code Platform

  • [ ] UWP
  • [ ] WinAppSDK / WinUI 3
  • [ ] Web Assembly (WASM)
  • [ ] Android
  • [ ] iOS
  • [ ] MacOS
  • [ ] Linux / GTK

Windows Build Number

  • [ ] Windows 10 1809 (Build 17763)
  • [ ] Windows 10 1903 (Build 18362)
  • [ ] Windows 10 1909 (Build 18363)
  • [ ] Windows 10 2004 (Build 19041)
  • [ ] Windows 10 20H2 (Build 19042)
  • [ ] Windows 10 21H1 (Build 19043)
  • [ ] Windows 11 21H2 (Build 22000)
  • [ ] Other (specify)

Other Windows Build number

No response

App minimum and target SDK version

  • [ ] Windows 10, version 1809 (Build 17763)
  • [ ] Windows 10, version 1903 (Build 18362)
  • [ ] Windows 10, version 1909 (Build 18363)
  • [ ] Windows 10, version 2004 (Build 19041)
  • [ ] Other (specify)

Other SDK version

No response

Visual Studio Version

No response

Visual Studio Build Number

No response

Device form factor

No response

Additional context

No response

lgztx96 avatar Oct 18 '25 02:10 lgztx96