This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Reland 3: Multiview pipeline #49950
Merged
Merged
Reland 3: Multiview pipeline #49950
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
1950e72
Impl engine
dkwingsmt f55dfdf
Web
dkwingsmt 7f76c5f
Rename to RequestWarmUpFrame and add web time
dkwingsmt 31a5ea3
Change to scheduleWarmUpFrame and EndWarmUpFrame
dkwingsmt 590287d
Comment
dkwingsmt 40b269b
Doc
dkwingsmt 2d70a0f
Simplify web implementation
dkwingsmt 4af9f06
Fix comment
dkwingsmt bfe5570
More doc
dkwingsmt 21439c4
Fix doc
dkwingsmt 1bd21db
More doc
dkwingsmt 4f41658
Fix linter
dkwingsmt eeac064
Fix comment
dkwingsmt 9c5bce4
Add test
dkwingsmt cdcf71a
Fix test
dkwingsmt 7ab7d8e
Better test
dkwingsmt afbcfae
Merge remote-tracking branch 'origin/main' into force-sync-frame
dkwingsmt 7381087
Simplify test and add platformdispatcher test
dkwingsmt 05d3d2d
Better structure
dkwingsmt 06957bb
Better name
dkwingsmt 68953c0
Merge branch 'main' into force-sync-frame
dkwingsmt a9b7511
Merge branch 'main' into force-sync-frame
dkwingsmt 7789d11
Original changes
dkwingsmt 06b4a50
Merge branch 'force-sync-frame' into reland-3-mv-pipeline-base
dkwingsmt 3464c05
Additional changes
dkwingsmt fe14311
Comments
dkwingsmt 5b0719b
Merge branch 'main' into reland-3-mv-pipeline
dkwingsmt 8731e47
Add web platform dispatcher test
dkwingsmt cdeffd9
Merge branch 'main' into force-sync-frame
dkwingsmt 4c91a9e
Merge branch 'force-sync-frame' into reland-3-mv-pipeline
dkwingsmt 34998fa
Fix lint
dkwingsmt 658d5d1
Merge branch 'main' into reland-3-mv-pipeline
dkwingsmt 946ffb5
Merge remote-tracking branch 'origin/main' into reland-3-mv-pipeline
dkwingsmt f9d5ad3
Merge remote-tracking branch 'dkwingsmt/reland-3-mv-pipeline' into re…
dkwingsmt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,10 @@ void Animator::BeginFrame( | |
| std::unique_ptr<FrameTimingsRecorder> frame_timings_recorder) { | ||
| TRACE_EVENT_ASYNC_END0("flutter", "Frame Request Pending", | ||
| frame_request_number_); | ||
| // Clear layer trees rendered out of a frame. Only Animator::Render called | ||
| // within a frame is used. | ||
| layer_trees_tasks_.clear(); | ||
|
|
||
| frame_request_number_++; | ||
|
|
||
| frame_timings_recorder_ = std::move(frame_timings_recorder); | ||
|
|
@@ -112,6 +116,33 @@ void Animator::BeginFrame( | |
| dart_frame_deadline_ = frame_target_time.ToEpochDelta(); | ||
| uint64_t frame_number = frame_timings_recorder_->GetFrameNumber(); | ||
| delegate_.OnAnimatorBeginFrame(frame_target_time, frame_number); | ||
| } | ||
|
|
||
| void Animator::EndFrame() { | ||
| FML_DCHECK(frame_timings_recorder_ != nullptr); | ||
| if (!layer_trees_tasks_.empty()) { | ||
| // The build is completed in OnAnimatorBeginFrame. | ||
| frame_timings_recorder_->RecordBuildEnd(fml::TimePoint::Now()); | ||
|
|
||
| delegate_.OnAnimatorUpdateLatestFrameTargetTime( | ||
| frame_timings_recorder_->GetVsyncTargetTime()); | ||
|
|
||
| // Commit the pending continuation. | ||
| PipelineProduceResult result = | ||
| producer_continuation_.Complete(std::make_unique<FrameItem>( | ||
| std::move(layer_trees_tasks_), std::move(frame_timings_recorder_))); | ||
|
|
||
| if (!result.success) { | ||
| FML_DLOG(INFO) << "Failed to commit to the pipeline"; | ||
| } else if (!result.is_first_item) { | ||
| // Do nothing. It has been successfully pushed to the pipeline but not as | ||
| // the first item. Eventually the 'Rasterizer' will consume it, so we | ||
| // don't need to notify the delegate. | ||
|
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. I'm suspicious that this branch might be cuasing the redness on CI. |
||
| } else { | ||
| delegate_.OnAnimatorDraw(layer_tree_pipeline_); | ||
| } | ||
| } | ||
| frame_timings_recorder_ = nullptr; | ||
|
|
||
| if (!frame_scheduled_ && has_rendered_) { | ||
| // Wait a tad more than 3 60hz frames before reporting a big idle period. | ||
|
|
@@ -139,14 +170,18 @@ void Animator::BeginFrame( | |
| }, | ||
| kNotifyIdleTaskWaitTime); | ||
| } | ||
| FML_DCHECK(layer_trees_tasks_.empty()); | ||
| FML_DCHECK(frame_timings_recorder_ == nullptr); | ||
| } | ||
|
|
||
| void Animator::Render(std::unique_ptr<flutter::LayerTree> layer_tree, | ||
| void Animator::Render(int64_t view_id, | ||
| std::unique_ptr<flutter::LayerTree> layer_tree, | ||
| float device_pixel_ratio) { | ||
| has_rendered_ = true; | ||
|
|
||
| if (!frame_timings_recorder_) { | ||
| // Framework can directly call render with a built scene. | ||
| // Framework can directly call render with a built scene. A major reason is | ||
| // to render warm up frames. | ||
| frame_timings_recorder_ = std::make_unique<FrameTimingsRecorder>(); | ||
| const fml::TimePoint placeholder_time = fml::TimePoint::Now(); | ||
| frame_timings_recorder_->RecordVsync(placeholder_time, placeholder_time); | ||
|
|
@@ -156,35 +191,9 @@ void Animator::Render(std::unique_ptr<flutter::LayerTree> layer_tree, | |
| TRACE_EVENT_WITH_FRAME_NUMBER(frame_timings_recorder_, "flutter", | ||
| "Animator::Render", /*flow_id_count=*/0, | ||
| /*flow_ids=*/nullptr); | ||
| frame_timings_recorder_->RecordBuildEnd(fml::TimePoint::Now()); | ||
|
|
||
| delegate_.OnAnimatorUpdateLatestFrameTargetTime( | ||
| frame_timings_recorder_->GetVsyncTargetTime()); | ||
|
|
||
| // TODO(dkwingsmt): Currently only supports a single window. | ||
| // See https://github.com/flutter/flutter/issues/135530, item 2. | ||
| int64_t view_id = kFlutterImplicitViewId; | ||
| std::vector<std::unique_ptr<LayerTreeTask>> layer_trees_tasks; | ||
| layer_trees_tasks.push_back(std::make_unique<LayerTreeTask>( | ||
| layer_trees_tasks_.push_back(std::make_unique<LayerTreeTask>( | ||
| view_id, std::move(layer_tree), device_pixel_ratio)); | ||
| // Commit the pending continuation. | ||
| PipelineProduceResult result = | ||
| producer_continuation_.Complete(std::make_unique<FrameItem>( | ||
| std::move(layer_trees_tasks), std::move(frame_timings_recorder_))); | ||
|
|
||
| if (!result.success) { | ||
| FML_DLOG(INFO) << "No pending continuation to commit"; | ||
| return; | ||
| } | ||
|
|
||
| if (!result.is_first_item) { | ||
| // It has been successfully pushed to the pipeline but not as the first | ||
| // item. Eventually the 'Rasterizer' will consume it, so we don't need to | ||
| // notify the delegate. | ||
| return; | ||
| } | ||
|
|
||
| delegate_.OnAnimatorDraw(layer_tree_pipeline_); | ||
| } | ||
|
|
||
| const std::weak_ptr<VsyncWaiter> Animator::GetVsyncWaiter() const { | ||
|
|
@@ -256,6 +265,7 @@ void Animator::AwaitVSync() { | |
| self->DrawLastLayerTrees(std::move(frame_timings_recorder)); | ||
| } else { | ||
| self->BeginFrame(std::move(frame_timings_recorder)); | ||
| self->EndFrame(); | ||
| } | ||
| } | ||
| }); | ||
|
|
@@ -265,9 +275,9 @@ void Animator::AwaitVSync() { | |
| } | ||
|
|
||
| void Animator::EndWarmUpFrame() { | ||
| // Do nothing. The warm up frame does not need any additional work to end the | ||
| // frame for now. This will change once the pipeline supports multi-view. | ||
| // https://github.com/flutter/flutter/issues/142851 | ||
| if (!layer_trees_tasks_.empty()) { | ||
| EndFrame(); | ||
| } | ||
| } | ||
|
|
||
| void Animator::ScheduleSecondaryVsyncCallback(uintptr_t id, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.