The Issue
We will be looking at proxy autoconfiguration issue that has affected Android users when a proxy.pac file is used. This issue appears to be caused by overzealous stock battery optimisation settings in Android.
The default power-saving settings in Android will cause proxy auto-configuration support apps to be in a sleep-state at times when they are required to be active, and this leads to timeouts and connection failures. From a user perspective the issue is seen as a network failure for several popular and commonly-installed android applications when proxy.pac is in place, including the use of the Google Play Store.
Daniel Aleksandersen first noted this problem in a report to Google in 2015, and in 2019 wrote the issue up on a blog post. The original 2015 ticket was closed, but a newer Google Issue Tracker ticket he opened in 2016 continues to discuss this matter.
The apps having the problem with battery optimisation are “PacProcessor” and “ProxyHandler”; they are “battery optimised” by default. This strict battery optimisation causes the problem with using a proxy.pac file. Even if you use a functionally empty proxy.pac which only tells all connections to go direct, the problems seem identical.
A Simple Solution
I have successfully de-optimised these two system apps on devices from Android v6 to v9, and the settings from the proxy.pac are now always respected in every case where I have made these changes. I should note though that these devices where the fix was successfully applied were all Samsung. I have not tried the solution on a device from any other manufacturer, but I am hoping it is useful for others.
Here are the instructions I wrote and recently added to the current Google Issue Tracker ticket;
For Android 6.0.x
- Go to Settings > Battery > Battery Usage
- Tap on the three dots in the top right of the screen.
- From the Drop-down menu select “Battery optimization”
- Using the menu filter near the top of the screen, switch from “Not optimized” to “All apps”
- Scroll down to each of
PacProcessor
andProxyHandler
and ensure the slider is disabled. This should solve the issue permanently with no significant negative effects.
For Android 7.1.x, 8.0.x, and 9.x
- Go to Settings > Apps
- Tap on the three dots in the top right of the screen.
- From the Drop-down menu select “Special Access”
- From the next menu select “Optimize battery usage”
- Using the menu filter near the top of the screen, switch from “Apps not optimized” to “All apps” (“Apps” in v9.x)
- Scroll down to each of
PacProcessor
andProxyHandler
and ensure the slider is disabled. This should solve the issue permanently with no significant negative effects.
Further Comments
It’s quite uncomplicated to resolve, at least for the Samsung devices. The only sticking point seems to be that the system app optimisation settings moved between major revisions. In Android v6 they can be changed via the “Battery” menu. However, for v7 onward this has to be done in the “Apps” section, and is further buried under the “Special Access”.
To be honest though, it makes little sense to me that it has to be done at all (I think it should come like this natively), but after a full year where little has made sense, it is a tiny thing.
All the best.