trime icon indicating copy to clipboard operation
trime copied to clipboard

Crash on uninitialized theme property

Open Bambooin opened this issue 11 months ago • 6 comments

Describe the bug A clear and concise description of what the bug is.

Random crash on input pop

To Reproduce Steps to reproduce the bug:

  1. Lock the screen
  2. Unlock the sreen
  3. Trime show process with deployment
  4. Input the password
  5. The screen was unlocked and seen the crash

Expected behavior A clear and concise description of what you expected to happen.

Log If applicable, add crash log to quick focus your problem.

--------- Crash stacktrace
kotlin.UninitializedPropertyAccessException: lateinit property activeTheme has not been initialized
	at com.osfans.trime.data.theme.ThemeManager.getActiveTheme(ThemeManager.kt:52)
	at com.osfans.trime.data.theme.ColorManager.getTheme(ColorManager.kt:22)
	at com.osfans.trime.data.theme.ColorManager.getColorSchemeId(ColorManager.kt:172)
	at com.osfans.trime.data.theme.ColorManager.switchNightMode(ColorManager.kt:161)
	at com.osfans.trime.data.theme.ColorManager.onSystemNightModeChange(ColorManager.kt:107)
	at com.osfans.trime.ime.core.TrimeInputMethodService.onConfigurationChanged(TrimeInputMethodService.kt:385)
	at android.window.WindowTokenClient.onConfigurationChanged(WindowTokenClient.java:260)
	at android.window.WindowTokenClient$$ExternalSyntheticLambda1.accept(Unknown Source:16)
	at com.android.internal.util.function.pooled.PooledLambdaImpl.doInvoke(PooledLambdaImpl.java:295)
	at com.android.internal.util.function.pooled.PooledLambdaImpl.invoke(PooledLambdaImpl.java:204)
	at com.android.internal.util.function.pooled.OmniFunction.run(OmniFunction.java:97)
	at android.os.Handler.handleCallback(Handler.java:942)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.app.ActivityThread.main(ActivityThread.java:7924)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

Screenshots If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

  • Device: [e.g. Xiaomi Mix 4]
  • OS: [e.g. Android 11]
  • Theme: [e.g. Tongwenfeng]
  • Version: [e.g. 3.2.1]
  • Build info:
--------- Build Info
Package Name: com.osfans.trime
Builder: Bambooin
Version Code: 20240501
Version Name: v3.2.17-21-g038045bd-release
Build Time: 2024-03-11T11:00:18Z
Build Git Hash: 038045bdfb0e8ef8b5d0f9bb4c97aec00ab80b94

Additional context Add any other context about the problem here.

Bambooin avatar Mar 13 '24 11:03 Bambooin

悬浮候选窗即将显示出来的时候也会崩溃

lidawei97688 avatar Mar 14 '24 08:03 lidawei97688

Trime just init the theme managed by ThemeManager on the input method service created. I think it's not a good place to do that, since the service can be created once and run a long time. Initializing in TrimeApplication may be a good idea, but due to our usage of the storage requiring user to grant the permissions, it may be hacky to do so.

WhiredPlanck avatar Mar 16 '24 01:03 WhiredPlanck

現在有很多地方直接使用 ThemeManager.activeTheme,但 Theme 依賴於 rime 的「部置」,而「部置」有時很快有時卻很慢。要徹底改善的話只能在代碼建立一個預設的 theme,然後在部置完成後再載入選擇的 theme

goofyz avatar Mar 22 '24 04:03 goofyz

現在有很多地方直接使用 ThemeManager.activeTheme,但 Theme 依賴於 rime 的「部置」,而「部置」有時很快有時卻很慢。要徹底改善的話只能在代碼建立一個預設的 theme,然後在部置完成後再載入選擇的 theme

主题的部署和方案的部署是分开的,RimeWrapper 考虑的是方案的部署,主题不需要和方案一同进行部署。

WhiredPlanck avatar Mar 22 '24 05:03 WhiredPlanck

Theme 要等 Rime.startupRime() 完成後才能部署吧? 我記得有試過同步部署 Rime 和 Theme,結果Theme 會報錯目錄不正確。(因為 rime 設定目錄和部署是同一 function) 如果將目錄設定等相關抽出來成獨立 function,應該可以實現同時部署。

goofyz avatar Mar 22 '24 06:03 goofyz

Theme 要等 Rime.startupRime() 完成後才能部署吧? 我記得有試過同步部署 Rime 和 Theme,結果Theme 會報錯目錄不正確。(因為 rime 設定目錄和部署是同一 function) 如果將目錄設定等相關抽出來成獨立 function,應該可以實現同時部署。

是的,Theme 只要启动完 Rime 就能部署,它初始化时调用了一个用于编译单个配置文件的 API,和方案的部署流程互不影响。

WhiredPlanck avatar Mar 22 '24 13:03 WhiredPlanck