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

Commit f73877a

Browse files
jmagmanluckysmg
andauthored
[iOS] Ensure FlutterView's background color is not nil to avoid CAMetalLayer nextDrawable being time-consuming (#39436)
Co-authored-by: luckysmg <2539699336@qq.com>
1 parent 3b5c7a1 commit f73877a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

shell/platform/darwin/ios/framework/Source/FlutterView.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ - (instancetype)initWithDelegate:(id<FlutterViewEngineDelegate>)delegate opaque:
4747
if (self) {
4848
_delegate = delegate;
4949
self.layer.opaque = opaque;
50+
51+
// This line is necessary. CoreAnimation(or UIKit) may take this to do
52+
// something to compute the final frame presented on screen, if we don't set this,
53+
// it will make it take long time for us to take next CAMetalDrawable and will
54+
// cause constant junk during rendering.
55+
self.backgroundColor = UIColor.clearColor;
5056
}
5157

5258
return self;

shell/platform/darwin/ios/framework/Source/FlutterViewTest.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,10 @@ - (void)testFlutterViewEnableSemanticsWhenIsAccessibilityElementIsCalled {
4949
XCTAssertTrue(delegate.callbackCalled);
5050
}
5151

52+
- (void)testFlutterViewBackgroundColorIsNotNil {
53+
FakeDelegate* delegate = [[FakeDelegate alloc] init];
54+
FlutterView* view = [[FlutterView alloc] initWithDelegate:delegate opaque:NO];
55+
XCTAssertNotNil(view.backgroundColor);
56+
}
57+
5258
@end

0 commit comments

Comments
 (0)