Skip to content

fix(#6154): layout race in instance download page#6155

Open
SALTWOOD wants to merge 5 commits into
HMCL-dev:mainfrom
SALTWOOD:fix/6154
Open

fix(#6154): layout race in instance download page#6155
SALTWOOD wants to merge 5 commits into
HMCL-dev:mainfrom
SALTWOOD:fix/6154

Conversation

@SALTWOOD

@SALTWOOD SALTWOOD commented May 31, 2026

Copy link
Copy Markdown

Fix #6154

这边怀疑是 race condition 导致没能成功设置标签的 Height 属性,所以选择了一个不大不小的值放在上面,暂时解决了问题。如果可能的话,我会尝试寻找更好的方法修好

需要更多测试。该修改之后,我已无法再复现此问题,但是不排除测试姿势不对导致的复现失败。

@SALTWOOD SALTWOOD marked this pull request as ready for review May 31, 2026 12:47
@Glavo

Glavo commented Jun 1, 2026

Copy link
Copy Markdown
Member

/gemini review

@SALTWOOD SALTWOOD changed the title fix(#6154): fix by replacing NaN with a placeholder value fix(#6154): layout race in instance download page Jun 1, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request simplifies the layout of TwoLineListItem by removing the ScrollPane wrapper around tagsBox and placing tagsBox directly into firstLine. It also binds the managed and visible properties of tagsBox to the presence of tags. A review comment suggests extracting the duplicate Bindings.isNotEmpty(tags) call into a local variable to avoid creating multiple binding instances and duplicate listeners, which helps reduce memory overhead and GC pressure.

Comment thread HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/TwoLineListItem.java Outdated
…Item.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@Glavo

Glavo commented Jun 1, 2026

Copy link
Copy Markdown
Member
image

tag 多的时候又会全部被挤压成 ...

@SALTWOOD

Copy link
Copy Markdown
Author

request review(雾

@Minecraft269

Copy link
Copy Markdown

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the tag layout in TwoLineListItem by replacing the ScrollPane with a direct HBox (tagsBox) and using a Rectangle clip to handle overflow. The reviewer suggested using JavaFX property binding (bind) instead of manual listeners to synchronize the clip's dimensions with the tagsBox dimensions, which simplifies the code and reduces overhead.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/TwoLineListItem.java Outdated
@Minecraft269

Copy link
Copy Markdown

666还真能用

@Minecraft269

Copy link
Copy Markdown

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@Minecraft269

Copy link
Copy Markdown

这个Codex好像得连自己的Codex?

…Item.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@Minecraft269

Copy link
Copy Markdown

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the TwoLineListItem class by replacing the ScrollPane container for tags with a direct HBox (tagsBox) that uses a Rectangle clip to handle overflow. The reviewer suggested overriding layoutChildren() on the HBox to update the clip dimensions synchronously during the layout pass, which avoids potential visual flickering and reduces binding overhead.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines 167 to +180
var tagsBox = new HBox(8);
tagsBox.getStyleClass().add("tags");
tagsBox.setAlignment(Pos.CENTER_LEFT);
HBox.setHgrow(tagsBox, Priority.ALWAYS);
Bindings.bindContent(tagsBox.getChildren(), tags);
var isNotEmpty = Bindings.isNotEmpty(tags);
tagsBox.managedProperty().bind(isNotEmpty);
tagsBox.visibleProperty().bind(isNotEmpty);

// Clip overflow tags, matching the previous ScrollPane behavior.
var clip = new Rectangle();
tagsBox.setClip(clip);
clip.widthProperty().bind(tagsBox.widthProperty());
clip.heightProperty().bind(tagsBox.heightProperty());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

在 JavaFX 中,将 clip 的宽和高属性直接绑定到 tagsBoxwidthProperty()heightProperty() 可能会导致在窗口缩放或动画过程中出现“慢一帧”的视觉闪烁(因为绑定是在布局完成后的监听器中异步/延迟更新的)。

为了确保裁剪区域与组件大小完全同步,并减少绑定带来的性能开销,更推荐的做法是重写 HBoxlayoutChildren() 方法,在布局阶段直接同步更新 clip 的尺寸。

            var clip = new Rectangle();
            var tagsBox = new HBox(8) {
                @Override
                protected void layoutChildren() {
                    super.layoutChildren();
                    clip.setWidth(getWidth());
                    clip.setHeight(getHeight());
                }
            };
            tagsBox.getStyleClass().add("tags");
            tagsBox.setAlignment(Pos.CENTER_LEFT);
            HBox.setHgrow(tagsBox, Priority.ALWAYS);
            Bindings.bindContent(tagsBox.getChildren(), tags);
            var isNotEmpty = Bindings.isNotEmpty(tags);
            tagsBox.managedProperty().bind(isNotEmpty);
            tagsBox.visibleProperty().bind(isNotEmpty);

            // Clip overflow tags, matching the previous ScrollPane behavior.
            tagsBox.setClip(clip);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 在版本滚动时修改版本类型筛选器部分版本的 Tag 显示可能消失

3 participants