sillsdev / sillsdev/languageforge-lexbox

Race condition when closing app with a commit pending

Open
#2,169 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

💻 FW Lite bug
Dominant language
C#
Stars
9
Forks
8
Avg merge
2d 13h
Merged PRs (30d)
49

Description

Describe the bug
If I make a change in FW Lite, then close the program without clicking anywhere else, sometimes that change gets stored and will be sent the next time the program is run. Most of the time, though, the change is lost.

There is probably a race condition between the thread saving the SQLite commit and the OS closing the window and terminating the program. Honestly, it's actually rather impressive that the uncommitted change got saved at all.

However, it might be possible to detect an uncommitted change and delay closing the OS. But where other programs would have a "You have unsaved changes. Do you want to save?" dialog, we can just store the commit for the current change, just as we would in the on-blur event handler, and then allow the program to be closed. It would probably not make a noticeable difference in closing time, either.

This might not be possible on Android, though: I have never seen a program present a "you have unsaved data" dialog when I close it with a swipe gesture on my Android phone, so it's possible the OS wouldn't allow this. Worth doing for Windows, though.

To Reproduce
Steps to reproduce the behavior:

  1. Go to a project
  2. Click on a word
  3. Edit one field
  4. Click on the window's X button to close the window (without clicking anywhere else within FW Lite)
  5. Reopen FW Lite
  6. Reopen project
  7. See if edit got saved
  8. If edit did get saved, it will sync to other copies of FW Lite as usual

Expected behavior
Closing the app would save the current edit. OR we would document that closing the app without tapping anywhere else would throw away the current edit, but that will cause user surprise so I'd prefer for an autosave to happen before closing the app.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing FW Lite's window-close lifecycle and the SQLite commit path, then compare how closing is handled on Windows and Android. Done means the current edit is reliably saved before closing on supported platforms, with unsupported behavior documented if necessary.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sqlite
Domain
databases, desktop, mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.