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

Cursor becomes invisible when crash occur during loading #74

Open
davidbtadokoro opened this issue Oct 26, 2024 · 1 comment
Open

Cursor becomes invisible when crash occur during loading #74

davidbtadokoro opened this issue Oct 26, 2024 · 1 comment
Labels
bug Something isn't working properly

Comments

@davidbtadokoro
Copy link
Collaborator

Description:

Wherever there is a loading screen in patch-hub, if the application crashes due to the working thread panicking, for example, the cursor becomes invisible. The terminal doesn't meltdown like when we crash the application before restoring the terminal, but the cursor only reappears after resetting the terminal or doing a Ctrl+L.

How to reproduce:

  1. Run patch-hub and do a delayed action that involve a loading scree (consult the patchsets of a mailing list)
  2. Before the loading completes, unplug from the network (you can disable WiFi, disable networking, etc.)
  3. Notice that the cursor won't be visible

Expected behavior:

In this case, the terminal should be fully restored if this type of crash occurs.

Setup:

  • Project branch: unstable
  • Project commit hash: 55d2416
@davidbtadokoro davidbtadokoro added the bug Something isn't working properly label Oct 26, 2024
@OJarrisonn
Copy link
Contributor

The reason for this probably is:

The loading_screen! macro spawns a new thread to draw the loading screen in the terminal that is finished once the code it wraps finishes. But if this piece of code panics we run our panic hook (utils::install_hooks) before finishing the thread.

Probably the panic hook restores the terminal and then the thread tries to draw again (it will run until the program exists). It probably fails to draw since we already restored but it might hide the cursor.

The solution is kill any running threads at the begging of the panic hook. I think the best way to achieve this is by:

  1. Create a global variable to store the atomic bool used to kill the thread and it's handle
  2. Change the macro to properly set and unset this variable with the created atomic boolean and thread handle
  3. On the panic hook, if the atomic boolean and handle are set, set it to false and join the handle

@davidbtadokoro davidbtadokoro moved this from In Progress to Todo in patch-hub-v0.2.0 Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working properly
Projects
None yet
Development

No branches or pull requests

2 participants