Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API to write user input history to disk #754

Open
wengxt opened this issue Nov 3, 2023 · 2 comments
Open

API to write user input history to disk #754

wengxt opened this issue Nov 3, 2023 · 2 comments

Comments

@wengxt
Copy link
Contributor

wengxt commented Nov 3, 2023

Is your feature request related to a problem? Please describe.
Right now fcitx5-rime uses RimeSync to write data to disk, this has many down sides.

  1. it seems to do more things than just flush the data
  2. it will release all the sessions.
  3. it might be slow and interrupt user

Fcitx5's autosave mechanism will invoke save() for every addon every 30min, and it can be delayed if user is still actively typing text. But in reallife, we still got some report that the auto save is extremely slow (over 5s) and interrupts user's input.

Describe the solution you'd like
I want a fast, maybe async api that

  1. doesn't require session to be released
  2. just user input history to be written and nothing else.

In the mobile case crash/oom kill/slow write maybe more common so having such an option can help a lot on those cases.

@wxyzh
Copy link
Contributor

wxyzh commented Nov 3, 2023

Rimesync not only writes data to the sync directory, but also merges the local userdict.
To temporarily solve this problem, we can execute RImesync after a period of time when the screen is off or the keyboard is hidden.

@lotem
Copy link
Member

lotem commented Feb 9, 2024

I understand that the RimeSync is expensive, sounds like an overkill for the job.

I took the safe and convenient option which shuts down the engine in order to free all the dictionaries, making the front-end responsible for blocking all user input activities while the synching job is run.

I imagined a better solution that would make a single database temporarily unavailable for input, while the sync job obtained access to it. That would keep all live Rime session running, and loosing user dictionary support for a short period. The same goes for "autosave user dicrtionary".

It's not a trival change because the dictionary logic isn't prepared for such exceptional case of suddenly unvailable dictionary. Moreover, a Rime dictionary can be only backed by a user dictionary, for example "custom phrase".

If the front end ensures that the autosave task is run in the same thread as processing key input, this could be a simpler change (providing non-thread-safe API).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants