-
Notifications
You must be signed in to change notification settings - Fork 6k
Avoid vsync scheduling delay #34363
Avoid vsync scheduling delay #34363
Conversation
|
Dan, can you take a look since @gaaclarke is out? |
|
Test? |
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
This is an implementation detail covered by existing tests. Not sure how to add a test for this in a simple manner, would you be able to advise? |
|
I guess you could test that a handler created with the createAsync compat layer makes isAsynchronous true on messages it sends? |
|
Thanks, yes we can add a test for the |
|
FYI I know I've seen this issue with |
|
Going to revert this in #36091 first since it causes flutter/flutter#110867 (comment) |
The
Handlercreated throughnew Handler(Looper.getMainLooper())is subject to synchronization barriers like vsync. This means that posting tasks to it can result in scheduling delays of up to 16ms. Empirically I have noticed this happening only before the first frame has been drawn, but not sure if it might happen on other occasions.This is a common pattern for platform message handlers on the main thread, and the delay can stack up and affect startup latency when apps do something like:
Handler.createAsynchelps to avoid this, but this API is only available on SDK >=28. Ideally we would useandroidx.core.os.HandlerCompatbut we don't have a dependency on it so I opted for a small reimplementation. It differs slightly in that we don't do the reflection fallback to keep things simple.Tested: Internal global presubmit. I did not add new tests since this is an implementation change and should be covered by existing tests.
This also improves the startup latency for
customer:moneyby 3%. See b/237035671 for more details.Related Issues
b/237035671
Might be related to flutter/flutter#81559 (comment)
Pre-launch Checklist
writing and running engine tests.
///).