Skip to content

Instantly share code, notes, and snippets.

@yrom
Last active May 9, 2020 03:01
Show Gist options
  • Save yrom/3b3d95b500933efd4a5a7791d252a920 to your computer and use it in GitHub Desktop.
Save yrom/3b3d95b500933efd4a5a7791d252a920 to your computer and use it in GitHub Desktop.
patch for flutter 1.12.13 shell/common/shell.cc
diff --git a/shell/common/shell.cc b/shell/common/shell.cc
index bef72617c..b73018a61 100644
--- a/shell/common/shell.cc
+++ b/shell/common/shell.cc
@@ -908,15 +908,28 @@ void Shell::OnAnimatorDraw(fml::RefPtr<Pipeline<flutter::LayerTree>> pipeline) {
[& waiting_for_first_frame = waiting_for_first_frame_,
&waiting_for_first_frame_condition = waiting_for_first_frame_condition_,
rasterizer = rasterizer_->GetWeakPtr(),
- pipeline = std::move(pipeline)]() {
- if (rasterizer) {
- rasterizer->Draw(pipeline);
-
- if (waiting_for_first_frame.load()) {
- waiting_for_first_frame.store(false);
- waiting_for_first_frame_condition.notify_all();
+ pipeline = std::move(pipeline),
+ is_backgrounded_sync_switch = is_gpu_disabled_sync_switch_]() {
+ if (rasterizer) {
+ is_backgrounded_sync_switch->Execute(
+ fml::SyncSwitch::Handlers().SetIfFalse([&] {
+ rasterizer->Draw(pipeline);
+ if (waiting_for_first_frame.load()) {
+ waiting_for_first_frame.store(false);
+ waiting_for_first_frame_condition.notify_all();
+ }
+ }).SetIfTrue([&] {
+ // drop pipeline
+ Pipeline<flutter::LayerTree>::Consumer consumer =[&](std::unique_ptr<LayerTree> layer_tree) {};
+ (void)pipeline->Consume(consumer);
+
+ if (waiting_for_first_frame.load()) {
+ waiting_for_first_frame.store(false);
+ waiting_for_first_frame_condition.notify_all();
+ }
+ })
+ );
}
- }
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment