Termux-app: Termux slows down in "doze mode" (battery optimization) even with the wake lock

Created on 4 Aug 2017  路  4Comments  路  Source: termux/termux-app

This is not really a bug, but rather an "improvement request".

When Termux runs using the Wake Lock, the performance greatly slows down because of "Doze" (explained in details here: https://developer.android.com/training/monitoring-device-state/doze-standby.html)

If a user leaves a device unplugged and stationary for a period of time, with the screen off, the device enters Doze mode. In Doze mode, the system attempts to conserve battery by restricting apps' access to network and CPU-intensive services. It also prevents apps from accessing the network and defers their jobs, syncs, and standard alarms.
Periodically, the system exits Doze for a brief time to let apps complete their deferred activities. During this maintenance window, the system runs all pending syncs, jobs, and alarms, and lets apps access the network.
As soon as the user wakes the device by moving it, turning on the screen, or connecting a charger, the system exits Doze and all apps return to normal activity

This means if you're connected with SSH on Termux, it will suddenly get really laggy (until you wake it up again), even worse if you use Termux as a web server.

See the conversation here: https://gitter.im/termux/termux?at=57a2253c836d2d0211610052

@fornwall said: "I'm just trying if disabling battery optimizaton for termux helps the wake-lock not working problem" and "I have disabled battery optimization earlier today and have not noticed any slowdowns yet. I will continue to test this."

The whitelist described here might be a solution: https://developer.android.com/training/monitoring-device-state/doze-standby.html#whitelisting-cases

Since I'm looking forward to this, here's an issue to know if it eventually does work :)

Most helpful comment

Disabling the battery optimizations is the only real solution. It would be a good idea to ask the user for adding to the white list (ideally when first creating a wake lock).

All 4 comments

I have solved the problem with SSH by enabling termux-wake-lock and creating a separate session which is running this command:

ping -i 0.3 -s 0 192.168.1.1

Of course, you may need to replace '192.168.1.1' to different IP.

I used anther app named "keep mobile light" to avoid this problem.

Turn this app's switch on, the mobile screen will keep light until switch off.

Disabling the battery optimizations is the only real solution. It would be a good idea to ask the user for adding to the white list (ideally when first creating a wake lock).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ngroup picture ngroup  路  5Comments

AlainKnaff picture AlainKnaff  路  4Comments

AnkurJagani picture AnkurJagani  路  3Comments

joakim-noah picture joakim-noah  路  5Comments

msh2050 picture msh2050  路  4Comments