Having Chrome-specific AsyncTask wrapper would provide the following benefits:
1. Make AsyncTask methods visible in tracing. Right now doInBackground() calls on worker threads are completely transparent, and UI thread callbacks (e.g. onPostExecute) are showing up as "android.os.AsyncTask$InternalHandler".
2. Assert that AsyncTask is created/executed on the main thread. The documentation says AsyncTask can only be used on the main thread, but Android implementation doesn't enforce that.
3. Provide a way to deprecate features/replace AsyncTask completely with something task-schedulery (see issue 825947).
So, my tasks on this are:
1) Switch all usages over to use our third_party copy
2) Bytecode check to see if android.os.AsyncTask is being used - Add error to enforce usage
3) Investigate prebuilt library usage of AsyncTask (consider bytecode rewrite)
4) Investigate framework usage of AsyncTask (see if we can call shutdown() to prevent it from using threads - not sure if we care)
5) See what's running for crashes (modifying SerialExecutor to give more information on queue full RejectedExecutionException)
6) Delete unused methods
7) Delete get() (convert existing usages to callbacks/promises)
8) Add tracing
9) Ensure exceptions can be seen from doInBackground()
This will provide a way to deprecate features on AsyncTask and pave a way towards something task-schedulery (see issue 825947).
So, my tasks on this are:
1) Switch all usages over to use our third_party copy
2) Bytecode check to see if android.os.AsyncTask is being used - Add error to enforce usage
3) Investigate prebuilt library usage of AsyncTask (consider bytecode rewrite)
4) Investigate framework usage of AsyncTask (see if we can call shutdown() to prevent it from using threads - not sure if we care)
5) See what's running for crashes (modifying SerialExecutor to give more information on queue full RejectedExecutionException)
6) Delete unused methods
7) Delete get() (convert existing usages to callbacks/promises)
8) Add tracing
9) Ensure exceptions can be seen from doInBackground()
10) Remove SerialExecutor and force usages to create own SerialExecutor
This will provide a way to deprecate features on AsyncTask and pave a way towards something task-schedulery (see issue 825947).
So, my tasks on this are:
1) Switch all usages over to use our third_party copy
2) Bytecode check to see if android.os.AsyncTask is being used - Add error to enforce usage
3) Investigate prebuilt library usage of AsyncTask (consider bytecode rewrite)
4) Investigate framework usage of AsyncTask (see if we can call shutdown() to prevent it from using threads - not sure if we care)
5) See what's running for crashes (modifying SerialExecutor to give more information on queue full RejectedExecutionException)
6) Delete unused methods
7) Delete get() (convert existing usages to callbacks/promises)
8) Add tracing
9) Ensure exceptions can be seen from doInBackground()
10) Remove SerialExecutor and force usages to create own SerialExecutor
This will provide a way to deprecate features on AsyncTask and pave a way towards something task-schedulery (see issue 825947).
One alternative to cloning AsyncTask.java is to just use build rules to ban using its executors and also ban uses of .execute(), and .get(). The main advantage for cloning it that I see:
* The logic of AsyncTask has changed over time, this will avoid quirks with variations in the OS's version.
* It allows for more flexibility in terms of changing the api (if we want to)
So, my tasks on this are:
1) Switch all usages over to use our third_party copy
2) Bytecode check to see if android.os.AsyncTask is being used - Add error to enforce usage
3) Investigate prebuilt library usage of AsyncTask (consider bytecode rewrite)
4) Investigate framework usage of AsyncTask (see if we can call shutdown() to prevent it from using threads - not sure if we care)
5) See what's running for crashes (modifying SerialExecutor to give more information on queue full RejectedExecutionException)
6) Delete unused methods
7) Delete get() (convert existing usages to callbacks/promises)
8) Add tracing
9) Ensure exceptions can be seen from doInBackground()
10) Remove SerialExecutor and force usages to create own SerialExecutor, and have it run each task's onPostExecute before the next one's onPreExecute.
This will provide a way to deprecate features on AsyncTask and pave a way towards something task-schedulery (see issue 825947).
One alternative to cloning AsyncTask.java is to just use build rules to ban using its executors and also ban uses of .execute(), and .get(). The main advantage for cloning it that I see:
* The logic of AsyncTask has changed over time, this will avoid quirks with variations in the OS's version.
* It allows for more flexibility in terms of changing the api (if we want to)
Comment 1 by dskiba@chromium.org
, May 16 2018