Avoid AsyncTask ThreadPool leak in RecentTaskLoaser
In MTBF test, if “Press KEYCODE_HOME” is simulated quickly and frequently, ThreadPool overflow would be triggered, which would crash systemui. When pressing hardware KEYCODE_HOME on the phone repeatedly, upon key down, systemui will preload recent task list; upon key up, it will cancel the request for preloading. During preloading, two AsyncTasks (mTaskLoader and mThumbnailLoader) will be started. Both of them will use executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR) to run. Cancel predloading means we don't need mTaskLoader and mThumbnailLoader any more, so we'd better use cancel(true) to interrupt these two AsyncTasks and catch this InterruptedException to return directly. If we use cancel(false) it won't interrupt these two AsyncTasks and mThumbnailLoader may be blocked in blocking queue "tasksWaitingForThumbnails" whcih will cause ThreadPool overflow. There is situation that mThumbnailLoader’s thread runs before mTaskLoader’s. Just at this moment, cancelPreloadingRecentTasksList tries to cancel both mTaskLoader and mThumbnailLoader. Then mTaskLoader was cancelled directly as it didn't start, mThumbnailLoader could not stop and blocks on "tasksWaitingForThumbnails" forever. At last, many AsyncTasks for mThumbnailLoader are not cancelled but left in waited state. Change-Id: I62bef320a62f28a442117f7d2c8160ea49e1a1fe Signed-off-by:<jshe32X<jianchunx.shen@intel.com> Signed-off-by:
Guobin <Zhang<guobin.zhang@intel.com>
Loading
Please register or sign in to comment