-
Notifications
You must be signed in to change notification settings - Fork 6k
Use eglPresentationTimeANDROID to avoid bogging down the GPU #29727
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -536,60 +536,60 @@ RasterStatus Rasterizer::DrawToSurfaceUnsafe( | |
| .supports_readback, // surface supports pixel reads | ||
| raster_thread_merger_ // thread merger | ||
| ); | ||
| if (compositor_frame) { | ||
| compositor_context_->raster_cache().PrepareNewFrame(); | ||
| frame_timings_recorder.RecordRasterStart(fml::TimePoint::Now()); | ||
|
|
||
| // Disable partial repaint if external_view_embedder_ SubmitFrame is | ||
| // involved - ExternalViewEmbedder unconditionally clears the entire | ||
| // surface and also partial repaint with platform view present is something | ||
| // that still need to be figured out. | ||
| bool disable_partial_repaint = | ||
| external_view_embedder_ && | ||
| (!raster_thread_merger_ || raster_thread_merger_->IsMerged()); | ||
|
|
||
| FrameDamage damage; | ||
| if (!disable_partial_repaint && frame->framebuffer_info().existing_damage) { | ||
| damage.SetPreviousLayerTree(last_layer_tree_.get()); | ||
| damage.AddAdditonalDamage(*frame->framebuffer_info().existing_damage); | ||
| } | ||
| if (!compositor_frame) { | ||
| return RasterStatus::kFailed; | ||
| } | ||
|
|
||
| RasterStatus raster_status = | ||
| compositor_frame->Raster(layer_tree, false, &damage); | ||
| if (raster_status == RasterStatus::kFailed || | ||
| raster_status == RasterStatus::kSkipAndRetry) { | ||
| return raster_status; | ||
| } | ||
| compositor_context_->raster_cache().PrepareNewFrame(); | ||
| frame_timings_recorder.RecordRasterStart(fml::TimePoint::Now()); | ||
|
|
||
| SurfaceFrame::SubmitInfo submit_info; | ||
| submit_info.frame_damage = damage.GetFrameDamage(); | ||
| submit_info.buffer_damage = damage.GetBufferDamage(); | ||
| // Disable partial repaint if external_view_embedder_ SubmitFrame is | ||
| // involved - ExternalViewEmbedder unconditionally clears the entire | ||
| // surface and also partial repaint with platform view present is something | ||
| // that still need to be figured out. | ||
| bool disable_partial_repaint = | ||
| external_view_embedder_ && | ||
| (!raster_thread_merger_ || raster_thread_merger_->IsMerged()); | ||
|
|
||
| frame->set_submit_info(submit_info); | ||
| FrameDamage damage; | ||
| if (!disable_partial_repaint && frame->framebuffer_info().existing_damage) { | ||
| damage.SetPreviousLayerTree(last_layer_tree_.get()); | ||
| damage.AddAdditonalDamage(*frame->framebuffer_info().existing_damage); | ||
| } | ||
|
|
||
| if (external_view_embedder_ && | ||
| (!raster_thread_merger_ || raster_thread_merger_->IsMerged())) { | ||
| FML_DCHECK(!frame->IsSubmitted()); | ||
| external_view_embedder_->SubmitFrame(surface_->GetContext(), | ||
| std::move(frame)); | ||
| } else { | ||
| frame->Submit(); | ||
| } | ||
| RasterStatus raster_status = | ||
| compositor_frame->Raster(layer_tree, false, &damage); | ||
| if (raster_status == RasterStatus::kFailed || | ||
| raster_status == RasterStatus::kSkipAndRetry) { | ||
| return raster_status; | ||
| } | ||
|
|
||
| compositor_context_->raster_cache().CleanupAfterFrame(); | ||
| frame_timings_recorder.RecordRasterEnd( | ||
| &compositor_context_->raster_cache()); | ||
| FireNextFrameCallbackIfPresent(); | ||
| SurfaceFrame::SubmitInfo submit_info; | ||
| submit_info.frame_damage = damage.GetFrameDamage(); | ||
| submit_info.buffer_damage = damage.GetBufferDamage(); | ||
| submit_info.target_time = frame_timings_recorder.GetVsyncTargetTime(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we're now depending on GetVsyncTargetTime for something other than metrics, I think we'll need to update VsyncWaiter to always get the current Display refresh rate instead of caching it. https://github.com/flutter/engine/blob/main/shell/platform/android/io/flutter/view/VsyncWaiter.java#L39 On Android S and later,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jason-simmons FYI - since I think you recently changed this to not do that.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The call to Reintroducing that call may be risky if it needs to be done on every frame.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we know if those devices were susceptible when running on Android S? I guess the problem here is that some devices will scale the refresh rate automatically/dynamically. It might also be interesting to see if the same delays exist when using the NDK API instead.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Huawei device referenced in flutter/flutter#90883 (comment) was running Android P I don't know if Android S ensures better performance for getRefreshRate
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #29800 Should resolve this. |
||
|
|
||
| if (surface_->GetContext()) { | ||
| TRACE_EVENT0("flutter", "PerformDeferredSkiaCleanup"); | ||
| surface_->GetContext()->performDeferredCleanup(kSkiaCleanupExpiration); | ||
| } | ||
| frame->set_submit_info(submit_info); | ||
|
|
||
| return raster_status; | ||
| if (external_view_embedder_ && | ||
| (!raster_thread_merger_ || raster_thread_merger_->IsMerged())) { | ||
| FML_DCHECK(!frame->IsSubmitted()); | ||
| external_view_embedder_->SubmitFrame(surface_->GetContext(), | ||
| std::move(frame)); | ||
| } else { | ||
| frame->Submit(); | ||
| } | ||
|
|
||
| return RasterStatus::kFailed; | ||
| compositor_context_->raster_cache().CleanupAfterFrame(); | ||
| frame_timings_recorder.RecordRasterEnd(&compositor_context_->raster_cache()); | ||
| FireNextFrameCallbackIfPresent(); | ||
|
|
||
| if (surface_->GetContext()) { | ||
| TRACE_EVENT0("flutter", "PerformDeferredSkiaCleanup"); | ||
| surface_->GetContext()->performDeferredCleanup(kSkiaCleanupExpiration); | ||
| } | ||
|
|
||
| return raster_status; | ||
| } | ||
|
|
||
| static sk_sp<SkData> ScreenshotLayerTreeAsPicture( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is much easier to review if you choose the hide whitespace option in GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After googling it, an easy way to do this is to just add
?w=1to the URL of this page and it will disable it for just this one visit.