Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change the AnrDetector executor frequency from scheduleAtFixedRate to…
… scheduleWithFixedDelay Summary: As title. This is a change requested by Google. Currently, we are utilizing `ExecutorService.scheduleAtFixedRate` to schedule a ANR check task. However, this approach encounters issues with newer Android versions that restrict or freeze the app. A recommended alternative is to use `scheduleWithFixedDelay`, which ensures the libary won't make up for the missed period of time, and keep the system_server healthy. ---- > Newer versions of Android use the Cached App Freezer feature (see https://source.android.com/docs/core/perf/cached-apps-freezer), which pauses the execution of apps once they're in the cached state. > scheduleAtFixedRate triggers the passed runnable periodically, which means that if an app is frozen for some time, when it's un-frozen that runnable will be called repeatedly, sometimes many (thousands) of times, depending on the requested interval. > The behavior we actually want in this case is the behavior of scheduleWithFixedDelay, which triggers the runnable after the previous iteration has terminated. In this case, after an app is frozen for a period, we will still call the runnable upon returning from being frozen and at the desired cadence thereafter, but won't try to "make up for" the missed period of time. Reviewed By: wx0165927473 Differential Revision: D47309581 fbshipit-source-id: 5bb44275e0376088b626bf1a03d4d7864b704c68
- Loading branch information