summaryrefslogtreecommitdiff
path: root/src/managers/ANRManager.cpp
diff options
context:
space:
mode:
authornyx <nnyyxxxx@protonmail.com>2025-03-31 12:06:17 -0400
committerGitHub <noreply@github.com>2025-03-31 18:06:17 +0200
commit2309270752383be30857d9c15cd3e259c4e6ed58 (patch)
treeb99b1571301427f1affde5bdfc3d62e8c6fd0c5b /src/managers/ANRManager.cpp
parent79b526a04199a05d1e9b0bbb035ba20b652a7a2b (diff)
anr: add config for ping number before popup shows up (#9782)
* anr: make pings configurable makes the pings of the dialog popup configurable
Diffstat (limited to 'src/managers/ANRManager.cpp')
-rw-r--r--src/managers/ANRManager.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/managers/ANRManager.cpp b/src/managers/ANRManager.cpp
index ebf02001..3debcda8 100644
--- a/src/managers/ANRManager.cpp
+++ b/src/managers/ANRManager.cpp
@@ -41,7 +41,8 @@ CANRManager::CANRManager() {
void CANRManager::onTick() {
std::erase_if(m_data, [](const auto& e) { return e->isDefunct(); });
- static auto PENABLEANR = CConfigValue<Hyprlang::INT>("misc:enable_anr_dialog");
+ static auto PENABLEANR = CConfigValue<Hyprlang::INT>("misc:enable_anr_dialog");
+ static auto PANRTHRESHOLD = CConfigValue<Hyprlang::INT>("misc:anr_missed_pings");
if (!*PENABLEANR) {
m_timer->updateTimeout(TIMER_TIMEOUT * 10);
@@ -66,7 +67,7 @@ void CANRManager::onTick() {
if (count == 0)
continue;
- if (data->missedResponses > 0) {
+ if (data->missedResponses >= *PANRTHRESHOLD) {
if (!data->isThreadRunning() && !data->dialogThreadSaidWait) {
data->runDialog("Application Not Responding", firstWindow->m_szTitle, firstWindow->m_szClass, data->getPid());
@@ -128,7 +129,8 @@ bool CANRManager::isNotResponding(PHLWINDOW pWindow) {
}
bool CANRManager::isNotResponding(SP<CANRManager::SANRData> data) {
- return data->missedResponses > 1;
+ static auto PANRTHRESHOLD = CConfigValue<Hyprlang::INT>("misc:anr_missed_pings");
+ return data->missedResponses > *PANRTHRESHOLD;
}
SP<CANRManager::SANRData> CANRManager::dataFor(PHLWINDOW pWindow) {
@@ -203,12 +205,13 @@ bool CANRManager::SANRData::isThreadRunning() {
return pthread_kill(dialogThread.native_handle(), 0) != ESRCH;
}
-void CANRManager::SANRData::killDialog() const {
+void CANRManager::SANRData::killDialog() {
if (!dialogProc)
return;
if (!dialogProc->pid()) {
- Debug::log(ERR, "ANR: cannot kill dialogProc, as it doesn't have a pid. If you have hyprutils <= 0.6.0, you will crash soon. Otherwise, dialog failed to spawn??");
+ Debug::log(ERR, "ANR: cannot kill dialogProc, as it doesn't have a pid.");
+ dialogProc = nullptr;
return;
}