Skip to content
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

Call AwaitVSync directly when Animator.RequestFrame is calling #29276

Closed
wants to merge 2 commits into from

Conversation

ColdPaleLight
Copy link
Member

@ColdPaleLight ColdPaleLight commented Oct 21, 2021

fixes flutter/flutter#92258

Currently this new feature is only support on Android and iOS,I have tried to enable this feature on all platforms, but the unit test AnimatorDoesNotNotifyIdleBeforeRender will fail due to timeout.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides].
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the [CLA].
  • All existing and new tests are passing.

@flutter-dashboard
Copy link

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.

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.

@dnfield
Copy link
Contributor

dnfield commented Oct 21, 2021

Do you have any results from running this on any of the devicelab tests? You can run those with a locally built engine in the framework tree by doing dart bin/run.dart -t flutter_gallery__transitions_perf --local-engine=android_profile_arm64 for example.

@ColdPaleLight
Copy link
Member Author

I tested it with a high-end phone (HUAWEI P40 Pro) and a low-end phone (Vivo Y67), and the specific results are as follows:
https://github.com/ColdPaleLight/flutter_gallery__transitions_perf_result

At the same time, I also recorded the time from Animator::RequestFrame to VSyncWaiter::FireCallback, and the results are as follows (The unit is microseconds) :
low-end device(VIVO Y67) without patch

  "average": 18049.60023174971,
  "90th_percentile": 27253.0,
  "99th_percentile": 51004.0,

low-end device(VIVO Y67) with patch

 "average": 16362.756043956044,
  "90th_percentile": 18833.0,
  "99th_percentile": 42793.0,

high-end device(HUAWEI P40 Pro) without patch

 "average": 17069.057142857142,
  "90th_percentile": 17210.0,
  "99th_percentile": 33972.0,

high-end device(HUAWEI P40 Pro) with patch

  "average": 16088.125536480688,
  "90th_percentile": 17001.0,
  "99th_percentile": 32726.0,

Preliminary conclusion:

Almost no effect on frame build time

Advantage:

  1. The frame count may increase in the same scenario. For example, the frame count of high-end mobile phones increases from 884 to 897.
  2. The time from Animator::RequestFrame to VSyncWaiter::FireCallback will be shortened。

Disadvantage:

average_vsync_frame_lag, 90th_percentile_vsync_frame_lag and 99th_percentile_vsync_frame_lag will be worse.

@dnfield
Copy link
Contributor

dnfield commented Oct 25, 2021

It looks like frame build times got slightly better over all, but with an average increase in the worst times. Raster times got worse across the board.

@ColdPaleLight
Copy link
Member Author

It looks like frame build times got slightly better over all, but with an average increase in the worst times. Raster times got worse across the board.

This is very strange, this patch should not affect raster times in theory.

@ColdPaleLight
Copy link
Member Author

Hi, @dnfield
Do you have any other ideas about this issue: flutter/flutter#92258 ? I think the current implementation needs to be improved. We cannot miss the next VSync signal just because one frame exceeds 16.6ms. This makes the experience of flutter on low-end devices not so good, especially in the add-to-app scenario, when comparing with native.

@ColdPaleLight
Copy link
Member Author

It looks like frame build times got slightly better over all, but with an average increase in the worst times. Raster times got worse across the board.

This is very strange, this patch should not affect raster times in theory.

I will test it again tomorrow

@ColdPaleLight
Copy link
Member Author

ColdPaleLight commented Oct 26, 2021

@dnfield
Here is the result I measured with low-end device MI 6 today. From this result, there is no problem with raster times https://github.com/ColdPaleLight/flutter_gallery__transitions_perf_result/tree/master/Day2/low-end%20device%20(MI%206)

At the same time I drew some pictures to illustrate the problem
flutter/flutter#92258 (comment)

@CaseyHillers CaseyHillers changed the base branch from master to main November 15, 2021 18:13
@flutter-dashboard
Copy link

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.

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.

@chinmaygarde
Copy link
Member

From our call in person on December 09, we were seeking a benchmark you could share with us so we ensure we don't regress here.

@chinmaygarde
Copy link
Member

Gentle ping on the benchmark.

@ColdPaleLight
Copy link
Member Author

@chinmaygarde
Since I couldn't provide a suitable benchmark to prove this optimization, I decided to close this PR. I will reopen if I find a suitable benchmark in the future.

@fzyzcjy
Copy link
Contributor

fzyzcjy commented Oct 27, 2022

Hi, did you have further experiments on this? Related: #36911

@ColdPaleLight
Copy link
Member Author

Hi, did you have further experiments on this? Related: #36911

Sorry, I don't have a benchmark to support it.

@fzyzcjy
Copy link
Contributor

fzyzcjy commented Oct 28, 2022

@ColdPaleLight Thank you all the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants