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

When deleting a break, there is a chance it hangs forever on closing the settings screen, and on subsequent startup. #567

Open
deltragon opened this issue Mar 6, 2024 · 2 comments
Labels

Comments

@deltragon
Copy link
Collaborator

Describe the bug
Deleting the break that happened to be the next scheduled one will remove the break from the existing queue, but keep it as last_break in the BreakQueue.
This leads to an infinite loop in this code:

SafeEyes/safeeyes/model.py

Lines 110 to 113 in 00c3390

if last_break != current_break.name:
brk = self.next()
while brk != current_break and brk.name != last_break:
brk = self.next()

To Reproduce
Steps to reproduce the behavior:

  1. Start SafeEyes.
  2. Ensure that there are exactly two breaks, and delete all breaks except those (eg. "Tightly close your eyes" and "Have some water"). This is needed to increase the likelyhood of the bug happening, but can occur with any number of breaks.
  3. Click on 'Take a break now' -> 'Any Break'.
  4. After the break, open the Settings.
  5. Go to the break list.
  6. Delete either break (eg. "Have some water").
  7. Click "Delete" in the confirmation dialog.
  8. Try to close the settings dialog - this will hang in about 50% of the time.

Since it is a coinflip each time, it is needed to repeat step 2-7 a few times to reproduce.

Expected behavior
Deleting any break should not hang.

Desktop (please complete the following information):

  • OS: Fedora 39
  • Desktop Env: KDE Plasma Wayland
  • Version: Plasma 5.27

Debug Log
Run the Safe Eyes using safeeyes --debug command attach the ~/safeeyes.log` file.

2024-03-06 20:26:18,911 [INFO]:[Thread-7] Start Safe Eyes core
2024-03-06 20:26:18,912 [INFO]:[WorkThread] Waiting for 15 minutes until next break
2024-03-06 20:26:18,912 [INFO]:[MainThread] Update next break information
2024-03-06 20:26:21,881 [INFO]:[MainThread] Show Settings dialog
2024-03-06 20:26:29,394 [INFO]:[MainThread] Saving settings to safeeyes.json
2024-03-06 20:26:29,394 [INFO]:[MainThread] Disable Safe Eyes
2024-03-06 20:26:29,395 [INFO]:[MainThread] Stop Safe Eyes core
2024-03-06 20:26:29,395 [INFO]:[WorkThread] Pre-break waiting is over
2024-03-06 20:26:29,396 [INFO]:[MainThread] Initialize SafeEyesCore with modified settings
2024-03-06 20:26:29,396 [INFO]:[MainThread] Initialize the core

After Initialize the core, it will hang.

@deltragon deltragon added the bug label Mar 6, 2024
@deltragon
Copy link
Collaborator Author

deltragon commented Mar 6, 2024

Since I know what the issue is, I am planning to file a PR fixing it.
I just wanted to file this to make sure it doesn't get lost.

@deltragon
Copy link
Collaborator Author

Oh, I've found a new reproducer:

  1. Start SafeEyes.
  2. Click on 'Take a break now' -> 'Any Break'.
  3. After the break, open the Settings.
  4. Delete all breaks.
  5. Add completely new breaks with different names to the existing breaks.
  6. Try to close the settings dialog - this will hang 100% of the time.

Step 4 and 5 can also be using the "Reset" button, if there is no overlap between the names of the breaks in Step 1 and 2 and the default breaks.

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

No branches or pull requests

1 participant