-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Make Android UI dispatcher asynchronous by default #427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
cc @JakeWharton |
I personally never rely on dispatch and waiting layout passes or frames in coroutines. I just rely on which thread/thread pool they will run. |
If we want to be super precise there are two axes at play here: UI vs. Main thread and sync vs. async. I'm not sure it's worth slicing all of them into official API since it'll only lead to, "which should I use?" questions where the answer will almost always be, "async/main thread." We do make distinctions in Android APIs around main vs. UI thread - they aren't the same since you can create a window with UI thread that is a looper thread other than the app's main ActivityThread. This is uncommon and usually only comes up in system code, but we do try to keep API docs and thread hint annotations precise around this. Then you have the sync/async distinction here. Ever since Jellybean introduced vsync barriers that delay posted messages until after a pending measure/layout/draw operation when the looper thread is otherwise idle there have been APIs to bypass it and get lower latency behavior if you don't need the results of the pending view tree traversal. The functionality itself is not a new feature; the only new feature is the Given that:
The only looper thread that you can offer a global coroutine context for is the app's main thread, and offering two options out of the box probably isn't worth the, "which should I use?" speed bump. The async variant is almost certainly what people want outside of some special cases. The |
Regarding In other words,
|
Could be nice to have a prototype of such a |
Using the snippet in #381 for compatibility, |
I'd even link to the comment containing the snippet here. I'll try, thanks! |
this article may be of interest https://medium.com/@sweers/rxandroids-new-async-api-4ab5b3ad3e93 |
Giving this a bump now that |
Can't agree more.
Did anyone started a PR? If not, I'll be happy to take it as my first non
typo fix PR for this repo.
…On Mon, Sep 17, 2018, 4:53 PM Adam Powell ***@***.***> wrote:
Giving this a bump now that UI has become Dispatchers.Main. Now that this
is generalized beyond UI into all other main looper tasks it would be great
to get this default behavior change in for 1.0 so that coroutines-based
code doesn't start relying on the compatibility vsync barrier behavior out
of the gate.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#427 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGpvBVw1rG9H_EUSXwBfQMjgsEulxwVZks5ub7eBgaJpZM4VGu7I>
.
|
I'm doing it. I spent 2m making the change and am entering hour 2 writing
tests.
…On Mon, Sep 17, 2018 at 2:03 PM Louis CAD ***@***.***> wrote:
Can't agree more.
Did anyone started a PR? If not, I'll be happy to take it as my first non
typo fix PR for this repo.
On Mon, Sep 17, 2018, 4:53 PM Adam Powell ***@***.***>
wrote:
> Giving this a bump now that UI has become Dispatchers.Main. Now that this
> is generalized beyond UI into all other main looper tasks it would be
great
> to get this default behavior change in for 1.0 so that coroutines-based
> code doesn't start relying on the compatibility vsync barrier behavior
out
> of the gate.
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <
#427 (comment)
>,
> or mute the thread
> <
https://github.com/notifications/unsubscribe-auth/AGpvBVw1rG9H_EUSXwBfQMjgsEulxwVZks5ub7eBgaJpZM4VGu7I
>
> .
>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#427 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEEEQqEIdewSHxEG6NoiVAB5r6XfsT2ks5ub-P6gaJpZM4VGu7I>
.
|
This can be closed now. |
See discussion in #381
We can make
UI
asynchronous by default and provide a fallback (system property?) for sync behaviour and something likeSyncUI
.Asynchronous handlers are the new feature in Android and it's unclear for us (as we're not Android devs) whether it's sane default which is safe to expose, so we'd like to hear community opinion on this.
The text was updated successfully, but these errors were encountered: