Skip to content

Perf: Set fixed cell size for versions list#6186

Merged
Glavo merged 1 commit into
HMCL-dev:mainfrom
KSSJW-Contribution:download-list-scrolling-fix
Jun 16, 2026
Merged

Perf: Set fixed cell size for versions list#6186
Glavo merged 1 commit into
HMCL-dev:mainfrom
KSSJW-Contribution:download-list-scrolling-fix

Conversation

@KSSJW

@KSSJW KSSJW commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

游戏版本下载列表性能优化

缘由

  • 在版本下载界面切换到“全部”分类后,由于 ListView 中版本数量较多,首次滚动时会出现明显卡顿。

原因推测

  • 每个 ListCell 需要动态计算 prefHeight

修改内容

  • 为 ListView 启用 setFixedCellSize()

优化效果

  • 首次滚动卡顿明显减少

对比

录屏好像有问题,切换选项时没有被采集(

修改前

0.mp4

修改后

1.mp4

@KSSJW

KSSJW commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

/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 introduces a fixed cell size of 65 to a JFXListView in VersionsPage.java to optimize rendering performance. The reviewer recommends increasing this value to 72 to prevent potential text clipping and layout issues on systems with larger fonts or different default font metrics.

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.

list = new JFXListView<>();
list.getStyleClass().add("jfx-list-view-float");

list.setFixedCellSize(65);

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

Setting a hardcoded fixed cell size of 65 is very tight and risks clipping the cell content.

The cell layout (RemoteVersionListCell) has a top and bottom margin of 10 each (totaling 20 pixels of vertical margin). This leaves only 45 pixels of vertical space for the cell content. Within this space, the cell renders a TwoLineListItem which contains a title, potentially tags, and a subtitle.

If the user has a slightly larger system font, or on operating systems with different default font metrics (such as some Linux distributions or when using Chinese system fonts), the combined height of these two lines can easily exceed 45 pixels, leading to vertical clipping or text truncation.

Using a slightly larger and safer height (e.g., 72 pixels) provides enough headroom to prevent layout breakage while retaining the performance benefits of setFixedCellSize.

Suggested change
list.setFixedCellSize(65);
// Use 72 to provide headroom for two-line items with tags and prevent clipping
list.setFixedCellSize(72);

@Glavo

Glavo commented Jun 16, 2026

Copy link
Copy Markdown
Member

/gemini reivew

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Hello! It looks like you're trying to trigger a code review. Please use the command /gemini review to initiate the process. I see you've already made some good progress on optimizing the ListView performance by setting a fixed cell size. I'll be happy to take a look at the implementation once you run the command!

@Glavo Glavo merged commit ca2f8a5 into HMCL-dev:main Jun 16, 2026
2 checks passed
@KSSJW KSSJW deleted the download-list-scrolling-fix branch June 16, 2026 12:20
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.

2 participants