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

未关闭
#755 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
csharp
领域
frontend

调研方向

使用提供的 Marquee 标记并设置 Behavior="Looping" 和 Direction="Down",重现该崩溃。阅读 components/Marquee/src/Marquee.xaml、Marquee.cs 的第 69、211 和 241 行,以及 Marquee.Events.cs 的第 36 和 62 行,重点关注 SizeChanged 订阅和 segment 可见性的变化。完成的标准是垂直 looping 不再导致 layout 循环或崩溃,并且 container 不会被重复订阅。

由索引模型根据 Issue 内容生成。

描述

bug :bug:
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

主要语言
C#
星标
485
派生
89
平均合并
19 小时 46 分钟
30 天内合并 PR
2

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

CommunityToolkit/Labs-Windows 的其他 Issue

查看 CommunityToolkit/Labs-Windows 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。