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

[android] set presentation time via eglPresentationTimeANDROID #33881

Merged
merged 3 commits into from
Jun 8, 2022

Conversation

iskakaushik
Copy link
Contributor

Attempt to reland: #29727

TODO:

  1. This isn't right in the cases where the frame has been resubmitted.
  2. This hasn't been wired for impeller yet.

@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 (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.

Attempt to reland: flutter#29727

TODO:

1. This isn't right in the cases where the frame has been resubmitted.
2. This hasn't been wired for impeller yet.
@iskakaushik
Copy link
Contributor Author

On a test application, this was seen to reduce the total time spent in dequeueBuffer from ~550ms to ~150ms.

  1. pprof prior to this change.
  2. pprof with this change

cc: @dnfield

Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be great to have some kind of test for this, especially if we have to special case resubmit frames.

@@ -604,6 +604,9 @@ RasterStatus Rasterizer::DrawToSurfaceUnsafe(
}

SurfaceFrame::SubmitInfo submit_info;
// TODO (kaushikiska): this can be in the past and might need to get snapped
// to future as this frame could have been resubmitted.
submit_info.presentation_time = frame_timings_recorder.GetVsyncTargetTime();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug?

Should we avoid setting this if it's a resubmit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filed an issue. for now i'll set this only if it is > now(), I think it should be the case for majority of frames. Once the issue is addressed we can snap this to the next vsync target time,.

@@ -63,6 +63,8 @@ std::unique_ptr<SurfaceFrame> GPUSurfaceGLImpeller::AcquireFrame(
GLPresentInfo present_info = {
.fbo_id = 0,
.damage = std::nullopt,
// TODO (kaushikiska): wire-up presentation time to impeller backend.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

@@ -60,6 +60,17 @@ void LogLastEGLError() {
FML_LOG(ERROR) << "Unknown EGL Error";
}

namespace {

static bool HasExtension(const char* extensions, const char* name) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have this method in like 3 or 4 places now. Or maybe we will with the swiftshader patch. We should consider moving it somewhere common

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dnfield i think this is out of scope for this PR. Will refactor this later if that is ok.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@iskakaushik
Copy link
Contributor Author

It'd be great to have some kind of test for this, especially if we have to special case resubmit frames.

Done! Added tests for cases where the frame is submitted in the future vs in past.

thread_host.raster_thread->GetTaskRunner(),
thread_host.ui_thread->GetTaskRunner(),
thread_host.io_thread->GetTaskRunner());
MockDelegate delegate;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use NiceMock<MockDelegate> (using ::testing::NiceMock) so this doesn't spam output about unused calls, here and elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! flutter/flutter#105631, i think we want to use it everywhere in this file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm updating the rest of the file in #33890 which is currently stuck on Fuchsia weirdness.

if (HasExtension(extensions, "EGL_ANDROID_presentation_time")) {
presentation_time_proc_ =
reinterpret_cast<PFNEGLPRESENTATIONTIMEANDROIDPROC>(
eglGetProcAddress("eglPresentationTimeANDROID"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future us: this was the big part of what was missing last time.

When I tested this locally, I hacked in a defintiion of this method and saw improvements. I then refactored things to actually do the proc lookup and put the extension name instead of the method name here, which resulted in no improvements (and slight regressions!).

Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nit

@dnfield
Copy link
Contributor

dnfield commented Jun 8, 2022

/cc @ds84182 @MxSoul FYI

@iskakaushik iskakaushik merged commit 10ff302 into flutter:main Jun 8, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 8, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 8, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 8, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 8, 2022
houhuayong pushed a commit to houhuayong/engine that referenced this pull request Jun 21, 2022
@zanderso
Copy link
Member

zanderso commented Aug 2, 2022

Could this change have been responsible for the improvement to 99%-ile raster times in backdrop_filter_perf?
https://flutter-flutter-perf.skia.org/e/?begin=1653514394&end=1659451447&keys=X29da4c759a0ed692aa4ac443fa2cfbb3&requestType=0&xbaroffset=30147

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

Successfully merging this pull request may close these issues.

3 participants