Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements page preloading to reduce animation stuttering when first navigating to certain pages in HMCL. The preloading occurs when the user's mouse enters specific sidebar items, but only when animations are enabled to avoid performance issues on low-end devices.
Key changes:
- Migrated
DownloadPageandLauncherSettingsPagefromLazyinitialization to manual nullable initialization with explicit prepare methods - Added utility methods
prepareNode()andprepareOnMouseEnter()to support preloading - Integrated mouse-enter event handlers on download and settings sidebar items to trigger preloading
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| RootPage.java | Added mouse-enter event handlers to download and settings sidebar items that trigger preloading when animations are enabled |
| FXUtils.java | Added utility methods prepareNode() for preloading nodes and prepareOnMouseEnter() for registering one-time mouse-enter handlers |
| Controllers.java | Converted download and settings pages from Lazy to nullable fields with explicit prepare methods; updated shutdown logic |
| TabControl.java | Made the Tab inner class final |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| downloadPage = null; | ||
| accountListPage = null; | ||
| settingsPage = null; | ||
| terracottaPage = null; |
There was a problem hiding this comment.
Type mismatch: terracottaPage is declared as Lazy<TerracottaPage> (line 115), but here it's being assigned null. Either change the field declaration to Lazy<TerracottaPage> terracottaPage (nullable) or remove this line since Lazy instances don't need to be nulled out in shutdown.
| terracottaPage = null; |
|
修复后首次进入设置界面依然会出现卡顿,原因不明。 |
部分低性能设备上似乎还是会卡,可能是还有其他负载。不过我自己和灵车群的测试来看,对大部分用户应该还是能明显改善卡顿情况。 |
|
我合到主线试试吧。如果大部分用户的设备上还有明显卡顿,那我再试试预先将页面藏到主界面的底层会不会好点。 |
HMCL 在初次进入一部分页面时过渡动画会异常卡顿,这主要是 JavaFX 计算页面布局导致的。
为了减少这种明显的卡顿,本 PR 实现了页面预加载。当用户鼠标进入主页的部分 Tab 中时,HMCL 会预先加载页面并计算该页面的布局,这样实际打开此页面时就能正常播放过渡动画。
考虑到预加载页面主要是为了避免过渡动画异常卡顿。如果用户关闭了动画效果,我们就不进行预加载。这样对于一些低性能设备也更友好。
例如,我在 N5105 的设备上进行测试时,预加载设置页面需要约 0.9 秒,这段时间中整个 UI 会短暂无响应。通过关闭动画效果阻止预加载即可避免这种情况发生。