Skip to content

feat: add wrapper of native config parser#1668

Closed
WhiredPlanck wants to merge 2 commits into
osfans:developfrom
WhiredPlanck:native-config
Closed

feat: add wrapper of native config parser#1668
WhiredPlanck wants to merge 2 commits into
osfans:developfrom
WhiredPlanck:native-config

Conversation

@WhiredPlanck

@WhiredPlanck WhiredPlanck commented Jun 15, 2025

Copy link
Copy Markdown
Collaborator

Pull request

Issue tracker

Fixes will automatically close the related issues

Fixes #1656

Feature

Describe features of this pull request

The yaml parser of Kotlin/Java is not powerful enough to deal with librime's style yaml config. So I bring back a wrapper of the native config api.

Code of conduct

Code style

Build pass

  • make debug

Manually test

  • Done

Code Review

  1. No wildcards import
  2. Manual build and test pass
  3. GitHub Action CI pass
  4. At least one contributor review and approve
  5. Merged clean without conflicts
  6. PR will be merged by rebase upstream base

Daily build

Login and download artifact at https://github.com/osfans/trime/actions

Additional Info

@WhiredPlanck
WhiredPlanck requested a review from Bambooin June 15, 2025 20:09
@WhiredPlanck
WhiredPlanck force-pushed the native-config branch 2 times, most recently from f696f50 to df6b9c9 Compare June 16, 2025 15:20
@Bambooin

Copy link
Copy Markdown
Collaborator

Found one crash with latest commit in Android 15.

--------- Crash stacktrace
androidx.startup.StartupException: lateinit property _activeTheme has not been initialized
	at com.osfans.trime.data.theme.ThemeManager.getActiveTheme(SourceFile:8)
	at com.osfans.trime.ime.core.TrimeInputMethodService.onCreateInputView(SourceFile:11)
	at android.inputmethodservice.InputMethodService.updateInputViewShown(InputMethodService.java:2423)
	at android.inputmethodservice.InputMethodService.prepareWindow(InputMethodService.java:3289)
	at android.inputmethodservice.InputMethodService.showWindow(InputMethodService.java:3175)
	at android.inputmethodservice.InputMethodService$InputMethodImpl.showSoftInput(InputMethodService.java:1057)
	at android.inputmethodservice.InputMethodService$InputMethodImpl.showSoftInputWithToken(InputMethodService.java:1017)
	at android.inputmethodservice.IInputMethodWrapper.executeMessage(IInputMethodWrapper.java:232)
	at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:44)
	at android.os.Handler.dispatchMessage(Handler.java:109)
	at android.os.Looper.loopOnce(Looper.java:232)
	at android.os.Looper.loop(Looper.java:317)
	at android.app.ActivityThread.main(ActivityThread.java:8934)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:591)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)

@WhiredPlanck

Copy link
Copy Markdown
Collaborator Author

Found one crash with latest commit in Android 15.

--------- Crash stacktrace
androidx.startup.StartupException: lateinit property _activeTheme has not been initialized
	at com.osfans.trime.data.theme.ThemeManager.getActiveTheme(SourceFile:8)
	at com.osfans.trime.ime.core.TrimeInputMethodService.onCreateInputView(SourceFile:11)
	at android.inputmethodservice.InputMethodService.updateInputViewShown(InputMethodService.java:2423)
	at android.inputmethodservice.InputMethodService.prepareWindow(InputMethodService.java:3289)
	at android.inputmethodservice.InputMethodService.showWindow(InputMethodService.java:3175)
	at android.inputmethodservice.InputMethodService$InputMethodImpl.showSoftInput(InputMethodService.java:1057)
	at android.inputmethodservice.InputMethodService$InputMethodImpl.showSoftInputWithToken(InputMethodService.java:1017)
	at android.inputmethodservice.IInputMethodWrapper.executeMessage(IInputMethodWrapper.java:232)
	at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:44)
	at android.os.Handler.dispatchMessage(Handler.java:109)
	at android.os.Looper.loopOnce(Looper.java:232)
	at android.os.Looper.loop(Looper.java:317)
	at android.app.ActivityThread.main(ActivityThread.java:8934)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:591)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)

May you use the default theme then try again?

@Bambooin

Copy link
Copy Markdown
Collaborator

After switching the theme from standard to default, no crash shows up anymore.

Step to reprodue

  1. Use the standard theme in old verion
  2. Install the latest version
  3. Deploy
  4. Crash show up

@WhiredPlanck

WhiredPlanck commented Jun 18, 2025

Copy link
Copy Markdown
Collaborator Author

After switching the theme from standard to default, no crash shows up anymore.

Step to reprodue

1. Use the standard theme in old verion

2. Install the latest version

3. Deploy

4. Crash show up

In my test, for somehow, app will crash on first-time startup after install the new apk when initialize the theme. However, if you select the other theme or then just reselect the previous theme, everything is OK. It seems that this PR has nothing to do with the issue. It may cause by the Kotlin-made config parser, I will replace it with this native config parser in the future PR.

@WhiredPlanck

Copy link
Copy Markdown
Collaborator Author

I polish the refctors again. So... if there is no problem else, I'd like to merge this PR first then fix the crash in other PR.

@WhiredPlanck

Copy link
Copy Markdown
Collaborator Author

Code style check failed on macOS. But I have nothing to do.

@WhiredPlanck
WhiredPlanck force-pushed the native-config branch 2 times, most recently from 582b474 to f2cdea4 Compare June 18, 2025 13:09
@WhiredPlanck

Copy link
Copy Markdown
Collaborator Author

@Bambooin Done. I replace the Kotlin-made config parser to native's one, and map the theme config to data classes. This can eliminate a lot of ugly code and make stronger code.

@Bambooin

Copy link
Copy Markdown
Collaborator

The latest commit will cause Trime crash after clicking the icon immediately.

@WhiredPlanck

Copy link
Copy Markdown
Collaborator Author

@Bambooin Hm,it seems that native config parser can only be used when rime is ready, leading to make user waiting for keyboard show up. I think I should polish the Kotlin-made config parser.

@WhiredPlanck
WhiredPlanck deleted the native-config branch July 6, 2025 08:22
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.

主题文件中同一键值下无法使用多个 __include

2 participants