Skip to content

Commit 0f85e53

Browse files
committed
Revert "Multiview pipeline Pt. 1: Skip illegal render calls (flutter#49266)"
This reverts commit 75f3a9c.
1 parent d2df0d0 commit 0f85e53

File tree

2 files changed

+18
-26
lines changed

2 files changed

+18
-26
lines changed

shell/common/animator.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,16 @@ void Animator::BeginFrame(
143143

144144
void Animator::Render(std::unique_ptr<flutter::LayerTree> layer_tree,
145145
float device_pixel_ratio) {
146-
// Animator::Render should be called after BeginFrame, which is indicated by
147-
// frame_timings_recorder_ being non-null. Otherwise, this call is ignored.
148-
if (frame_timings_recorder_ == nullptr) {
149-
return;
150-
}
151-
152146
has_rendered_ = true;
153147

148+
if (!frame_timings_recorder_) {
149+
// Framework can directly call render with a built scene.
150+
frame_timings_recorder_ = std::make_unique<FrameTimingsRecorder>();
151+
const fml::TimePoint placeholder_time = fml::TimePoint::Now();
152+
frame_timings_recorder_->RecordVsync(placeholder_time, placeholder_time);
153+
frame_timings_recorder_->RecordBuildStart(placeholder_time);
154+
}
155+
154156
TRACE_EVENT_WITH_FRAME_NUMBER(frame_timings_recorder_, "flutter",
155157
"Animator::Render", /*flow_id_count=*/0,
156158
/*flow_ids=*/nullptr);

shell/common/animator_unittests.cc

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -158,30 +158,20 @@ TEST_F(ShellTest, AnimatorDoesNotNotifyIdleBeforeRender) {
158158
latch.Wait();
159159
ASSERT_FALSE(delegate.notify_idle_called_);
160160

161-
fml::AutoResetWaitableEvent render_latch;
162161
// Validate it has not notified idle and try to render.
163162
task_runners.GetUITaskRunner()->PostDelayedTask(
164163
[&] {
165164
ASSERT_FALSE(delegate.notify_idle_called_);
166-
EXPECT_CALL(delegate, OnAnimatorBeginFrame).WillOnce([&] {
167-
auto layer_tree = std::make_unique<LayerTree>(
168-
LayerTree::Config(), SkISize::Make(600, 800));
169-
animator->Render(std::move(layer_tree), 1.0);
170-
render_latch.Signal();
171-
});
172-
// Request a frame that builds a layer tree and renders a frame.
173-
// When the frame is rendered, render_latch will be signaled.
174-
animator->RequestFrame(true);
165+
auto layer_tree = std::make_unique<LayerTree>(LayerTree::Config(),
166+
SkISize::Make(600, 800));
167+
animator->Render(std::move(layer_tree), 1.0);
175168
task_runners.GetPlatformTaskRunner()->PostTask(flush_vsync_task);
176169
},
177170
// See kNotifyIdleTaskWaitTime in animator.cc.
178171
fml::TimeDelta::FromMilliseconds(60));
179172
latch.Wait();
180-
render_latch.Wait();
181173

182-
// A frame has been rendered, and the next frame request will notify idle.
183-
// But at the moment there isn't another frame request, therefore it still
184-
// hasn't notified idle.
174+
// Still hasn't notified idle because there has been no frame request.
185175
task_runners.GetUITaskRunner()->PostTask([&] {
186176
ASSERT_FALSE(delegate.notify_idle_called_);
187177
// False to avoid getting cals to BeginFrame that will request more frames
@@ -249,16 +239,16 @@ TEST_F(ShellTest, AnimatorDoesNotNotifyDelegateIfPipelineIsNotEmpty) {
249239

250240
for (int i = 0; i < 2; i++) {
251241
task_runners.GetUITaskRunner()->PostTask([&] {
252-
EXPECT_CALL(delegate, OnAnimatorBeginFrame).WillOnce([&] {
253-
auto layer_tree = std::make_unique<LayerTree>(LayerTree::Config(),
254-
SkISize::Make(600, 800));
255-
animator->Render(std::move(layer_tree), 1.0);
256-
begin_frame_latch.Signal();
257-
});
258242
animator->RequestFrame();
259243
task_runners.GetPlatformTaskRunner()->PostTask(flush_vsync_task);
260244
});
261245
begin_frame_latch.Wait();
246+
247+
PostTaskSync(task_runners.GetUITaskRunner(), [&] {
248+
auto layer_tree = std::make_unique<LayerTree>(LayerTree::Config(),
249+
SkISize::Make(600, 800));
250+
animator->Render(std::move(layer_tree), 1.0);
251+
});
262252
}
263253

264254
PostTaskSync(task_runners.GetUITaskRunner(), [&] { animator.reset(); });

0 commit comments

Comments
 (0)