Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit af6d9b98 authored by jshe32X's avatar jshe32X Committed by Steve Kondik
Browse files

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: default avatar <jshe32X&lt;jianchunx.shen@intel.com>
Signed-off-by: default avatarGuobin <Zhang&lt;guobin.zhang@intel.com>
parent eff323bf
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment