我正在使用OkHttp(首先原始版本,然後我升級到OkHttp3),當應用程序未運行時,我的應用程序的某些用戶報告顯着的電池壽命損失。CPU使用率異常 - Okio看門狗
我跑了探查,這是結果:
正如你所看到的,奧基奧看門狗正在運行的全部時間。大致在中途點,我的應用程序完全在後臺。目前沒有HTTP任務發生。我在最後的HTTP任務結束後開始分析。
看門狗是否正常運行?如果是這樣,我是否認爲這個線程造成了很多電池浪費?如果這種情況不正常,像是泄露的上下文會讓Watchdog運行嗎?
這裏的Watchdog code運行時,它似乎想運行沒有終止條件:
private static final class Watchdog extends Thread {
public Watchdog() {
super("Okio Watchdog");
setDaemon(true);
}
public void run() {
while (true) {
try {
AsyncTimeout timedOut = awaitTimeout();
// Didn't find a node to interrupt. Try again.
if (timedOut == null) continue;
// Close the timed out node.
timedOut.timedOut();
} catch (InterruptedException ignored) {
}
}
}
}
您是否設法重現了這一切? – Knossos
我還沒有調查,說實話。今天,希望。 –