ashish-yadav11 / dwmblocks

Rewrite of dwmblocks with added features including clickability, cursor hinting and color.
ISC License
212 stars 30 forks source link

Freezing issues #45

Closed sourav-majumdar-math closed 1 year ago

sourav-majumdar-math commented 1 year ago

I have moved to a new laptop and occasionally dwmblocks freezes, i.e. no text update happens for any of the blocks. Cursor hinting and clickability still work during the freeze. I had never faced this issue on my previous machine. How would I go about debugging this?

ashish-yadav11 commented 1 year ago

First check if the scripts are being called or not (add something in the script so that you know that they have been launched - like a notification or something).

sourav-majumdar-math commented 1 year ago

Yeah, none of the scripts are being called in the frozen state.

ashish-yadav11 commented 1 year ago

Is the dwmblocks process still active in the frozen state (see in htop or something)? Launch dwmblocks from a terminal and check whether any errors pop up when it freezes.

sourav-majumdar-math commented 1 year ago

Yes, it remains active (pid shows in htop). I have tried to run dwmblocks from the terminal but when the freeze happens no error messages come up.

On Thu, Dec 1, 2022 at 6:07 AM Ashish Kumar Yadav @.***> wrote:

Is the dwmblocks process still active in the frozen state (see in htop or something)? Launch dwmblocks from a terminal and check whether any errors pop up when it freezes.

— Reply to this email directly, view it on GitHub https://github.com/ashish-yadav11/dwmblocks/issues/45#issuecomment-1333259505, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP5FLMKZMHDONZ4KPDVRNVLWLA6A7ANCNFSM6AAAAAASMP2UBY . You are receiving this because you authored the thread.Message ID: @.***>

ashish-yadav11 commented 1 year ago

Around line 150 in dwmblocks.c make the following changes:

        for (i = 1; ; i++) {
                updatestatus();
                sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL);
                t.tv_sec = INTERVALs, t.tv_nsec = INTERVALn;
                while (nanosleep(&t, &t) == -1);
                sigprocmask(SIG_BLOCK, &blocksigmask, NULL);
                for (Block *block = blocks; block->pathu; block++)
                        if (block->interval > 0 && i % block->interval == 0)
                                updateblock(block, NILL);
        }

to

        for (i = 1; ; i++) {
                fprintf(stderr, "Debug: %d loop updating status.\n", i);
                updatestatus();
                fprintf(stderr, "Debug: %d loop unblocking signals.\n", i);
                sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL);
                t.tv_sec = INTERVALs, t.tv_nsec = INTERVALn;
                fprintf(stderr, "Debug: %d going to sleep.\n", i);
                while (nanosleep(&t, &t) == -1);
                fprintf(stderr, "Debug: %d waking up from sleep.\n", i);
                sigprocmask(SIG_BLOCK, &blocksigmask, NULL);
                fprintf(stderr, "Debug: %d unblocking signals, updating blocks.\n", i);
                for (Block *block = blocks; block->pathu; block++)
                        if (block->interval > 0 && i % block->interval == 0)
                                updateblock(block, NILL);
        }

Report what you see on the terminal when dwmblocks freezes.

ashish-yadav11 commented 1 year ago

Remember to make.

sourav-majumdar-math commented 1 year ago

I haven't encountered freezing yet. But on first run of this modified dwmblocks I get,

Translate ID error: '-1' is not a valid ID (returned by default-nodes-api)

(standard_in) 1: syntax error
Debug: 1 loop updating status.
Debug: 1 loop unblocking signals.
Debug: 1 going to sleep.
Debug: 1 waking up from sleep.
Debug: 1 unblocking signals, updating blocks.
Translate ID error: '-1' is not a valid ID (returned by default-nodes-api)

(standard_in) 1: syntax error
Debug: 2 loop updating status.
Debug: 2 loop unblocking signals.
Debug: 2 going to sleep.
Debug: 2 waking up from sleep.
Debug: 2 unblocking signals, updating blocks.
Translate ID error: '-1' is not a valid ID (returned by default-nodes-api)

(standard_in) 1: syntax error
Debug: 3 loop updating status.
Debug: 3 loop unblocking signals.
Debug: 3 going to sleep.
Debug: 3 waking up from sleep.
Debug: 3 unblocking signals, updating blocks.
Debug: 4 loop updating status.
Debug: 4 loop unblocking signals.
Debug: 4 going to sleep.
Debug: 4 waking up from sleep.
Debug: 4 unblocking signals, updating blocks.
Debug: 5 loop updating status.

When I kill dwmblocks and run it again I don't get those error messages until I reboot where I get it on the first run.

ashish-yadav11 commented 1 year ago

Some block is giving that output, find out which by manually launching all.

sourav-majumdar-math commented 1 year ago

I further modified it as following,

for (Block *block = blocks; block->pathu; block++){
                        if (block->interval > 0 && i % block->interval == 0){
                                fprintf(stderr, "%d \n", block->signal);
                                updateblock(block, NILL);
                      }
}

I was able to possibly catch the culprit script,

Debug: 31275 loop updating status.
Debug: 31275 loop unblocking signals.
Debug: 31275 going to sleep.
Debug: 31275 waking up from sleep.
Debug: 31275 unblocking signals, updating blocks.
2

and it stays frozen.

Here 2 is the signal for my volume script for pipewire with wireplumber. I have added a timeout hack for the script, which should prevent it from getting stuck.

The earlier error was also some bizzare quirk of the same script which I was able to "fix" by initializing in xprofile, I can't figure out whether this is a hardware, driver or pipewire issue.

For reference my volume script was,

    A=$(amixer -c 0 sget Headphone | awk 'FNR == 7 {print}' | awk '{print $7}')
    A=$(echo $A | sed 's/[][]//g')
    if [ "$A" == "off" ]; then
        H="S"
    else
        H="H"
    fi

    volume=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print $2}')

    volume_adj=$(bc <<< "$volume*100/1")
    printf "| %s %s%% " "$H" "$volume_adj"

and I have modified it to,

function timeout_loop(){
    A=$(amixer -c 0 sget Headphone | awk 'FNR == 7 {print}' | awk '{print $7}')
    A=$(echo $A | sed 's/[][]//g')
    if [ "$A" == "off" ]; then
        H="S"
    else
        H="H"
    fi

    volume=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print $2}')

    volume_adj=$(bc <<< "$volume*100/1")
    printf "| %s %s%% " "$H" "$volume_adj"
}

export -f timeout_loop

b=$(timeout 3 bash -c "timeout_loop")

exit_status=$?

if [[ $exit_status -ne 124 ]]; then
    echo $b
fi
sourav-majumdar-math commented 1 year ago

Thanks a lot for your help!