Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit eca079f

Browse files
committed
FlutterCompositor should not call present callback if there are no layers
1 parent 7dc8eba commit eca079f

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

shell/platform/darwin/macos/framework/Source/FlutterCompositor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class FlutterCompositor {
7373

7474
// Calls the present callback and ensures the frame status is updated
7575
// to frame ended, returning whether the present was successful or not.
76-
bool EndFrame();
76+
bool EndFrame(bool have_layers);
7777

7878
// Creates a CALayer object which is backed by the supplied IOSurface, and
7979
// adds it to the root CALayer for this FlutterViewController's view.

shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
SetFrameStatus(FrameStatus::kStarted);
3030
}
3131

32-
bool FlutterCompositor::EndFrame() {
33-
bool status = present_callback_();
32+
bool FlutterCompositor::EndFrame(bool have_layers) {
33+
bool status = have_layers ? present_callback_() : true;
3434
SetFrameStatus(FrameStatus::kEnded);
3535
return status;
3636
}

shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
};
103103
}
104104

105-
return EndFrame();
105+
return EndFrame(layers_count > 0);
106106
}
107107

108108
} // namespace flutter

shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
};
9898
}
9999

100-
return EndFrame();
100+
return EndFrame(layers_count > 0);
101101
}
102102

103103
} // namespace flutter

shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.mm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ - (void)ensureSurfaceSize:(CGSize)size {
5858
}
5959

6060
- (void)swapBuffers {
61+
#ifndef NDEBUG
62+
// swapBuffers should not be called unless a frame was drawn
63+
@synchronized(self) {
64+
assert(_frameInProgress);
65+
}
66+
#endif
67+
6168
_contentLayer.frame = _containingLayer.bounds;
6269
_contentLayer.transform = _contentTransform;
6370
IOSurfaceRef contentIOSurface = [_ioSurfaces[kFlutterSurfaceManagerBackBuffer] ioSurface];

0 commit comments

Comments
 (0)