Skip to content

Commit 8c83c97

Browse files
committed
revert: 7bb3df6 ~ just now, about the NotRespectVsync feature flutter#6010
1 parent 297a8b7 commit 8c83c97

12 files changed

Lines changed: 42 additions & 114 deletions

lib/ui/dart_ui.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ typedef CanvasPath Path;
9393
V(NativeStringAttribute::initSpellOutStringAttribute, 3) \
9494
V(PlatformConfigurationNativeApi::DefaultRouteName, 0) \
9595
V(PlatformConfigurationNativeApi::ScheduleFrame, 0) \
96-
V(PlatformConfigurationNativeApi::LastVsyncInfo, 0) \
96+
/*V(LastVsyncInfo::ReadToDart, 0)*/ \
9797
V(PlatformConfigurationNativeApi::PointerDataPacketStorageReadPendingAndClear, 0) \
9898
V(PlatformConfigurationNativeApi::Render, 1) \
9999
V(PlatformConfigurationNativeApi::UpdateSemantics, 1) \

lib/ui/platform_dispatcher.dart

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -720,16 +720,17 @@ class PlatformDispatcher {
720720
external static void _scheduleFrame();
721721

722722
LastVsyncInfo lastVsyncInfo() {
723-
final List<int> raw = _lastVsyncInfo();
724-
return LastVsyncInfo(
725-
vsyncTargetTime: Duration(microseconds: raw[0]),
726-
diffDateTimeTimePoint: raw[1],
727-
);
723+
// final List<int> raw = _lastVsyncInfo();
724+
// return LastVsyncInfo(
725+
// vsyncTargetTime: Duration(microseconds: raw[0]),
726+
// diffDateTimeTimePoint: raw[1],
727+
// );
728+
throw Exception('temporarily removed');
728729
}
729730

730-
// prototype, should not really name/place here
731-
@FfiNative<Handle Function()>('PlatformConfigurationNativeApi::LastVsyncInfo')
732-
external static List<int> _lastVsyncInfo();
731+
// // prototype, should not really name/place here
732+
// @FfiNative<Handle Function()>('LastVsyncInfo::ReadToDart')
733+
// external static List<int> _lastVsyncInfo();
733734

734735
static PointerDataPacket pointerDataPacketStorageReadPendingAndClear() {
735736
final raw = _pointerDataPacketStorageReadPendingAndClearStatic();

lib/ui/window/platform_configuration.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -412,14 +412,6 @@ void PlatformConfigurationNativeApi::ScheduleFrame() {
412412
UIDartState::Current()->platform_configuration()->client()->ScheduleFrame();
413413
}
414414

415-
Dart_Handle PlatformConfigurationNativeApi::LastVsyncInfo() {
416-
UIDartState::ThrowIfUIOperationsProhibited();
417-
return UIDartState::Current()
418-
->platform_configuration()
419-
->client()
420-
->LastVsyncInfo();
421-
}
422-
423415
Dart_Handle
424416
PlatformConfigurationNativeApi::PointerDataPacketStorageReadPendingAndClear() {
425417
UIDartState::ThrowIfUIOperationsProhibited();

lib/ui/window/platform_configuration.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ class PlatformConfigurationClient {
6464
///
6565
virtual void ScheduleFrame() = 0;
6666

67-
virtual Dart_Handle LastVsyncInfo() = 0;
68-
6967
virtual Dart_Handle PointerDataPacketStorageReadPendingAndClear() = 0;
7068

7169
//--------------------------------------------------------------------------
@@ -477,8 +475,6 @@ class PlatformConfigurationNativeApi {
477475

478476
static void ScheduleFrame();
479477

480-
static Dart_Handle LastVsyncInfo();
481-
482478
static Dart_Handle PointerDataPacketStorageReadPendingAndClear();
483479

484480
static void Render(Scene* scene);

runtime/runtime_controller.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,6 @@ void RuntimeController::ScheduleFrame() {
279279
client_.ScheduleFrame();
280280
}
281281

282-
Dart_Handle RuntimeController::LastVsyncInfo() {
283-
return client_.LastVsyncInfo();
284-
}
285-
286282
Dart_Handle RuntimeController::PointerDataPacketStorageReadPendingAndClear() {
287283
return client_.PointerDataPacketStorageReadPendingAndClear();
288284
}

runtime/runtime_controller.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,8 +604,6 @@ class RuntimeController : public PlatformConfigurationClient {
604604
// |PlatformConfigurationClient|
605605
void ScheduleFrame() override;
606606

607-
Dart_Handle LastVsyncInfo() override;
608-
609607
Dart_Handle PointerDataPacketStorageReadPendingAndClear() override;
610608

611609
// |PlatformConfigurationClient|

runtime/runtime_delegate.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ class RuntimeDelegate {
2525

2626
virtual void ScheduleFrame(bool regenerate_layer_tree = true) = 0;
2727

28-
virtual Dart_Handle LastVsyncInfo() = 0;
29-
3028
virtual Dart_Handle PointerDataPacketStorageReadPendingAndClear() = 0;
3129

3230
virtual void Render(std::shared_ptr<flutter::LayerTree> layer_tree) = 0;

shell/common/animator.cc

Lines changed: 19 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "flutter/shell/common/animator.h"
66

77
#include "flutter/flow/frame_timings.h"
8-
#include "flutter/fml/backtrace.h"
98
#include "flutter/fml/time/time_point.h"
109
#include "flutter/fml/trace_event.h"
1110
#include "third_party/dart/runtime/include/dart_tools_api.h"
@@ -80,7 +79,6 @@ void Animator::BeginFrame(
8079
frame_request_number_);
8180
frame_request_number_++;
8281

83-
FML_DLOG(INFO) << "hi Animator::BeginFrame set frame_timings_recorder_";
8482
frame_timings_recorder_ = std::move(frame_timings_recorder);
8583
frame_timings_recorder_->RecordBuildStart(fml::TimePoint::Now());
8684

@@ -172,7 +170,6 @@ void Animator::Render(std::shared_ptr<flutter::LayerTree> layer_tree) {
172170
last_layer_tree_size_ = layer_tree->frame_size();
173171

174172
if (!frame_timings_recorder_) {
175-
FML_DLOG(INFO) << "hi Animator::Render set frame_timings_recorder_";
176173
// Framework can directly call render with a built scene.
177174
frame_timings_recorder_ = std::make_unique<FrameTimingsRecorder>();
178175
const fml::TimePoint placeholder_time = fml::TimePoint::Now();
@@ -201,7 +198,6 @@ void Animator::Render(std::shared_ptr<flutter::LayerTree> layer_tree) {
201198
FML_DLOG(INFO) << "hi Animator::Render call producer_continuation_.Complete"
202199
<< " produce producer_continuation_="
203200
<< static_cast<bool>(producer_continuation_);
204-
FML_DLOG(INFO) << "hi Animator::Render remove frame_timings_recorder_";
205201
auto layer_tree_item = std::make_unique<LayerTreeItem>(
206202
std::move(layer_tree), std::move(frame_timings_recorder_));
207203
// Commit the pending continuation.
@@ -290,62 +286,25 @@ void Animator::RequestFrame(bool regenerate_layer_tree) {
290286

291287
void Animator::AwaitVSync() {
292288
FML_DLOG(INFO) << "hi Animator::AwaitVSync start";
293-
294-
// #5982
295-
const LastVsyncInfo& lastVsyncInfo = LastVsyncInfo::Instance();
296-
// to do: use one lock, currently two reads use two lockings.
297-
auto frame_start_time = lastVsyncInfo.GetVsyncStartTime();
298-
auto frame_target_time = lastVsyncInfo.GetVsyncTargetTime();
299-
300-
bool curr_vsync_has_already_called_begin_frame =
301-
frame_timings_recorder_ &&
302-
frame_timings_recorder_->GetVsyncTargetTime() == frame_target_time;
303-
FML_DLOG(INFO)
304-
<< "hi Animator::AwaitVSync curr_vsync_has_already_called_begin_frame="
305-
<< curr_vsync_has_already_called_begin_frame << " frame_target_time="
306-
<< frame_target_time.ToEpochDelta().ToMicroseconds()
307-
<< " frame_timings_recorder_->GetVsyncTargetTime="
308-
<< (frame_timings_recorder_
309-
? frame_timings_recorder_->GetVsyncTargetTime()
310-
.ToEpochDelta()
311-
.ToMicroseconds()
312-
: -1)
313-
<< " backtrace=" << fml::BacktraceHere();
314-
315-
// NotRespectVsync, see #5982
316-
if (curr_vsync_has_already_called_begin_frame) {
317-
waiter_
318-
->AsyncWaitForVsync(
319-
[self = weak_factory_.GetWeakPtr()](
320-
std::unique_ptr<FrameTimingsRecorder> frame_timings_recorder) {
321-
FML_DLOG(INFO)
322-
<< "hi Animator::AwaitVSync AsyncWaitForVsync callback start";
323-
if (self) {
324-
if (self->CanReuseLastLayerTree()) {
325-
FML_DLOG(INFO) << "hi Animator::AwaitVSync AsyncWaitForVsync "
326-
"callback call DrawLastLayerTree";
327-
self->DrawLastLayerTree(std::move(frame_timings_recorder));
328-
} else {
329-
FML_DLOG(INFO) << "hi Animator::AwaitVSync AsyncWaitForVsync "
330-
"callback call BeginFrame";
331-
self->BeginFrame(std::move(frame_timings_recorder));
332-
}
333-
}
334-
FML_DLOG(INFO)
335-
<< "hi Animator::AwaitVSync AsyncWaitForVsync callback end";
336-
});
337-
} else {
338-
FML_DLOG(INFO) << "hi Animator::AwaitVSync directly call BeginFrame";
339-
340-
// ref: vsync_waiter.cc
341-
std::unique_ptr<FrameTimingsRecorder> frame_timings_recorder =
342-
std::make_unique<FrameTimingsRecorder>();
343-
frame_timings_recorder->RecordVsync(frame_start_time, frame_target_time);
344-
345-
// hack: not consider `CanReuseLastLayerTree` yet
346-
BeginFrame(std::move(frame_timings_recorder));
347-
}
348-
289+
waiter_->AsyncWaitForVsync(
290+
[self = weak_factory_.GetWeakPtr()](
291+
std::unique_ptr<FrameTimingsRecorder> frame_timings_recorder) {
292+
FML_DLOG(INFO)
293+
<< "hi Animator::AwaitVSync AsyncWaitForVsync callback start";
294+
if (self) {
295+
if (self->CanReuseLastLayerTree()) {
296+
FML_DLOG(INFO) << "hi Animator::AwaitVSync AsyncWaitForVsync "
297+
"callback call DrawLastLayerTree";
298+
self->DrawLastLayerTree(std::move(frame_timings_recorder));
299+
} else {
300+
FML_DLOG(INFO) << "hi Animator::AwaitVSync AsyncWaitForVsync "
301+
"callback call BeginFrame";
302+
self->BeginFrame(std::move(frame_timings_recorder));
303+
}
304+
}
305+
FML_DLOG(INFO)
306+
<< "hi Animator::AwaitVSync AsyncWaitForVsync callback end";
307+
});
349308
if (has_rendered_) {
350309
delegate_.OnAnimatorNotifyIdle(dart_frame_deadline_);
351310
}

shell/common/engine.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,10 +439,6 @@ void Engine::ScheduleFrame(bool regenerate_layer_tree) {
439439
animator_->RequestFrame(regenerate_layer_tree);
440440
}
441441

442-
Dart_Handle Engine::LastVsyncInfo() {
443-
return LastVsyncInfo::ReadToDart();
444-
}
445-
446442
Dart_Handle Engine::PointerDataPacketStorageReadPendingAndClear() {
447443
return PointerDataPacketStorage::ReadPendingAndClearStatic();
448444
}

shell/common/engine.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -755,9 +755,6 @@ class Engine final : public RuntimeDelegate, PointerDataDispatcher::Delegate {
755755
// |RuntimeDelegate|
756756
void ScheduleFrame(bool regenerate_layer_tree) override;
757757

758-
// |RuntimeDelegate|
759-
Dart_Handle LastVsyncInfo() override;
760-
761758
// |RuntimeDelegate|
762759
Dart_Handle PointerDataPacketStorageReadPendingAndClear() override;
763760

0 commit comments

Comments
 (0)