Skip to content

fix(custom): prevent UI starvation (missing tooltips) when restart-interval is 0#4843

Open
tteeaa wants to merge 1 commit intoAlexays:masterfrom
tteeaa:fix/restart-interval-starvation
Open

fix(custom): prevent UI starvation (missing tooltips) when restart-interval is 0#4843
tteeaa wants to merge 1 commit intoAlexays:masterfrom
tteeaa:fix/restart-interval-starvation

Conversation

@tteeaa
Copy link

@tteeaa tteeaa commented Feb 10, 2026

Closes #4842

Bug

When a custom module script exits immediately and "restart-interval": 0 is set, tooltips for the entire bar stop working.

Cause

As documented in man/waybar-custom.5.scd, the minimum restart interval is 1ms (0.001).

"Minimum value is 0.001 (1ms). Values smaller than 1ms will be set to 1ms."

A 1ms restart loop on a script that exits instantly creates a tight loop. This prevents mouse hover events (tooltips) from processing.

Fix

Fix: I have added a safety check in src/modules/custom.cpp. If the user sets a restart-interval lower than 1000ms (1 second), the module now:

  1. Logs a warning to spdlog explaining the issue.
  2. Enforces a minimum delay of 1000ms.
    This breaks the tight loop, allowing the UI to remain responsive even if a user misconfigures a fast-exiting script.

Verification

  • Before: Hovering over any module (e.g. Clock) showed no tooltip.
  • After: Tooltips appear instantly, and a warning is logged:
    [warning] Custom module: restart-interval (0ms) too low. Enforcing 1000ms to prevent UI starvation.
image

Copilot AI review requested due to automatic review settings February 10, 2026 18:43
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a Waybar UI responsiveness issue where a custom module configured with a very small restart-interval can create a tight restart loop that starves the UI event loop, causing tooltips across the bar to stop working.

Changes:

  • Adds a lower-bound clamp for restart-interval in Custom::continuousWorker().
  • Logs a warning when the configured restart-interval is below the enforced minimum.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +98 to +101
if (interval_ms < 1000) {
spdlog::warn("Custom module: restart-interval ({}ms) is too low. Enforcing 1000ms to prevent UI starvation.", interval_ms);
interval_ms = 1000;
}
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning will be emitted on every restart when the interval is clamped (potentially once per second indefinitely), which can spam logs for a misconfigured module. Consider logging this warning only once per module instance (e.g., track a boolean) or rate-limit it.

Copilot uses AI. Check for mistakes.
Comment on lines +98 to +101
if (interval_ms < 1000) {
spdlog::warn("Custom module: restart-interval ({}ms) is too low. Enforcing 1000ms to prevent UI starvation.", interval_ms);
interval_ms = 1000;
}
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation inside this if block is inconsistent with the surrounding 2-space indentation in this file; please reformat to match the existing style.

Copilot uses AI. Check for mistakes.
Comment on lines +95 to +102
long interval_ms = static_cast<long>(config_["restart-interval"].asDouble() * 1000);

// Minimum interval (1 second) to prevent UI starvation from tight loops
if (interval_ms < 1000) {
spdlog::warn("Custom module: restart-interval ({}ms) is too low. Enforcing 1000ms to prevent UI starvation.", interval_ms);
interval_ms = 1000;
}
thread_.sleep_for(std::chrono::milliseconds(interval_ms));
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This enforces a 1000ms minimum restart-interval, but the documented minimum for restart-interval is 1ms. This is a behavioral change that will override legitimate configurations that intentionally use sub-second restarts (e.g. 0.5s). Consider keeping the documented minimum (1ms) and instead adding a throttling/backoff mechanism only when the script exits too quickly (to prevent tight restart loops), or update the manpage/docs to match the new enforced minimum.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] "restart-interval": 0 on one-shot scripts creates silent render loop that kills all tooltips

1 participant