Android added support for adding Proxy Auto-Configuration (PAC) configuration profiles to the Wi-Fi network in Android 6 “Marshmallow”. Android 7 “Nougat” introduced a bug that causes almost all network connections to time out that still remains in today’s Android 9 “Oreo”. Here is why this longstanding system bug happens and how you work around it.
Android 7 introduced a new and more aggressive battery optimization system that prevents apps from running for more than a few seconds unless they’re a media app or an open foreground app. This restriction also applies to Android’s own internal helper apps.
Using a PAC configuration involves two helper apps: the ProxyHandler, responsible for intercepting all network connections and forwarding them to the appropriate proxy server depending on your PAC configuration, and the PacProcessor, responsible for interpreting the PAC file.
These helper apps are written to have a minuscule impact on battery performance, but they’ve both been restricted from running in the background by default since Android 7.
Many apps, including almost all of Google’s apps, will try to open a network connection that will route through ProxyHandler and eventually time out. Since ProxyHandler is prevented from running in the background, it can’t do anything with the incoming network requests and they’re just left in a queue until the calling app times them out.
The Google Chrome app and apps that work as front-ends for the Chromium WebView still works, however, as they use a slightly different proxy handling than the system default. Other apps like Firefox, Twitter, Google Play Services, and YouTube will just time out.
You can work-around the issue by plugging your Android device into a charger as the battery optimization policy changes for all apps to allow them to run in the background while charging. This means the problem can be frustrating to debug as your device will be plugged into the computer to interact with debugging software.
You can disable battery optimizations for the ProxyHandler and PacProcessor through Android Settings. The exact steps vary from make and model, but you’ll find a list of all your apps under the headline Battery Optimization or Optimize Battery Usage somewhere inside the Settings app.
Once on that screen, click the “Apps not optimized” label and choose “All apps” instead. Find the two apps and disable the optimization option for both of them. You can technically disable optimization only for the ProxyHandler and have your network working again; but that will introduce a tiny delay for every network connection as it has to wake up the PacProcessor app for each connection.
I reported this issue to the Android Open Source Project over two years ago but the issue was dismissed by a Google engineer as working as intended.
The same issue also affects some configurations of Chrome OS/Chromebooks.