trime icon indicating copy to clipboard operation
trime copied to clipboard

Potential UI thread blocking issue

Open nbd-boss opened this issue 1 month ago • 2 comments

摘要 / Summary

In LiquidTabsUi, the onCreateViewHolder() method creates TabUi instances. During TabUi initialization, FontManager.getTypeface() is called. If the font is not already cached, getTypeface() synchronously loads and builds the Typeface. This synchronous operation may block the UI thread, especially when multiple tabs are created at once, potentially causing performance degradation.

Similarly, in KeyboardView.kt, onDrawKeyboard() is synchronously called within onDraw(). Although onDrawKeyboard() must run on the UI thread, some of its operations—such as FontManager.getTypeface() potentially loading fonts from disk—and the per-key drawing logic can involve relatively heavy computations, which may also cause UI stuttering during app startup or keyboard rendering.

重现步骤 / Steps to Reproduce

nothing

预期行为 / Expected Behavior

Preload and cache fonts to avoid synchronous file I/O during drawing.

Minimize per-key calculations and complex logic inside onDrawKeyboard().

Implementing these changes can reduce main thread load and improve keyboard rendering and app startup performance.

日志 / Log

No response

截图 / Screenshot

No response

附加信息 / Additional Context

No response

系统版本 / OS Version

latest

应用版本 / App Version

1.3.7

构建信息 / Build Information

nothing

nbd-boss avatar Nov 08 '25 08:11 nbd-boss

Thank you for your feedback. I will optimize the relevant implementation as soon as possible to reduce the load on the UI thread and improve keyboard rendering and application startup performance. Please stay tuned for future updates.

WhiredPlanck avatar Nov 08 '25 10:11 WhiredPlanck

@nbd-boss But unfortunately, it has been confirmed that FontManager.getTypeface() indeed prioritizes fetching fonts from the cache, so this should not be the primary cause of the stuttering.

WhiredPlanck avatar Nov 09 '25 02:11 WhiredPlanck