Skip to content

Commit 5d3f368

Browse files
Revert: iOS: Eliminate use of IOSContextNoop in platform view tests (flutter#190501)
Reverts: [iOS: Eliminate use of IOSContextNoop in platform view tests](flutter#190419) Initiated by: @cbracken Reason for reverting: This was fine as was the patch that removed GetBackend() but parallelising them was not. Original PR Author: @cbracken Reviewed By: @gaaclarke The original PR description is provided below: `FlutterPlatformViewsTest` used the internal engine class `flutter::IOSContextNoop` in a dozen places purely as a no-op context to hand to `submitFrame:withIosContext:`. This replaces those with a local `FakeIOSContext` that replicates the behaviour the tests rely on so that we can delete `IOSContextNoop` in a follow-up. Like `IOSContextNoop` `FakeIOSContext` reports the Impeller backend and returns no external texture, and inherits the null Impeller/Aiks contexts from the base class. The one place that uses the engine's real context (`GetIosContext`) is left untouched. I suspect we can eventually move this code to use the real Metal backend but for now, this is just refactoring with no semantic change. Back in ancient times, before the simulator required Metal, and when iOS still had a Skia software renderer, we ran that on the Simulator due to some issues with our OpenGL implementation. Later, Flutter on iOS migrated from Skia to Impeller. Skia supports a software backend but Impeller did not, and so when running on Impeller, we stubbed out the software backend to no-op context/surfaces, hence IOSContextNoop and IOSSurfaceNoop. The Simulator now *requires* Metal and Flutter has eliminated Skia support altogether so there's no longer a software mode at all, nor a need for a no-op path in case you're using Impeller and ask for a software backend. This is part of a series of changes to remove the dead no-op fallback. No behavioural change; just a test refactoring. Issue: flutter#190041 <!-- Thanks for filing a pull request! Reviewers are typically assigned within a week of filing a request. To learn more about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md --> ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [X] I signed the [CLA]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I added new tests to check the change I am making, or this PR is [test-exempt]. - [X] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [X] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 352f8ee commit 5d3f368

1 file changed

Lines changed: 29 additions & 42 deletions

File tree

‎engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm‎

Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,11 @@
2626
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTestHelper.h"
2727
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h"
2828
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTouchInterceptingView+Test.h"
29-
#include "flutter/shell/platform/darwin/ios/ios_context.h"
29+
#include "flutter/shell/platform/darwin/ios/ios_context_noop.h"
3030
#include "flutter/shell/platform/darwin/ios/platform_view_ios.h"
3131

3232
FLUTTER_ASSERT_ARC
3333

34-
namespace {
35-
// An IOSContext fake for tests that do not need a real GPU context.
36-
class FakeIOSContext : public flutter::IOSContext {
37-
public:
38-
FakeIOSContext() = default;
39-
~FakeIOSContext() override = default;
40-
41-
// |IOSContext|
42-
flutter::IOSRenderingBackend GetBackend() const override {
43-
return flutter::IOSRenderingBackend::kImpeller;
44-
}
45-
46-
// |IOSContext|
47-
std::unique_ptr<flutter::Texture> CreateExternalTexture(
48-
int64_t texture_id,
49-
NSObject<FlutterTexture>* texture) override {
50-
return nullptr;
51-
}
52-
};
53-
} // namespace
54-
5534
@class FlutterPlatformViewsTestMockPlatformView;
5635
__weak static UIView* gMockPlatformView = nil;
5736
const float kFloatCompareEpsilon = 0.001;
@@ -4246,8 +4225,9 @@ - (void)testFlutterPlatformViewControllerSubmitFrameWithoutFlutterViewNotCrashin
42464225
[](const flutter::SurfaceFrame& surface_frame, flutter::DlCanvas* canvas) { return false; },
42474226
[](const flutter::SurfaceFrame& surface_frame) { return true; },
42484227
/*frame_size=*/flutter::DlISize(800, 600));
4249-
XCTAssertFalse([flutterPlatformViewsController submitFrame:std::move(mock_surface)
4250-
withIosContext:std::make_shared<FakeIOSContext>()]);
4228+
XCTAssertFalse([flutterPlatformViewsController
4229+
submitFrame:std::move(mock_surface)
4230+
withIosContext:std::make_shared<flutter::IOSContextNoop>()]);
42514231

42524232
auto embeddedViewParams_2 =
42534233
std::make_unique<flutter::EmbeddedViewParams>(finalMatrix, flutter::DlSize(300, 300), stack);
@@ -4262,8 +4242,9 @@ - (void)testFlutterPlatformViewControllerSubmitFrameWithoutFlutterViewNotCrashin
42624242
[](const flutter::SurfaceFrame& surface_frame, flutter::DlCanvas* canvas) { return true; },
42634243
[](const flutter::SurfaceFrame& surface_frame) { return true; },
42644244
/*frame_size=*/flutter::DlISize(800, 600));
4265-
XCTAssertTrue([flutterPlatformViewsController submitFrame:std::move(mock_surface_submit_true)
4266-
withIosContext:std::make_shared<FakeIOSContext>()]);
4245+
XCTAssertTrue([flutterPlatformViewsController
4246+
submitFrame:std::move(mock_surface_submit_true)
4247+
withIosContext:std::make_shared<flutter::IOSContextNoop>()]);
42674248
}
42684249

42694250
- (void)
@@ -4450,8 +4431,9 @@ - (void)testFlutterPlatformViewControllerBeginFrameShouldResetCompisitionOrder {
44504431
[](const flutter::SurfaceFrame& surface_frame, flutter::DlCanvas* canvas) { return true; },
44514432
[](const flutter::SurfaceFrame& surface_frame) { return true; },
44524433
/*frame_size=*/flutter::DlISize(800, 600), nullptr, /*display_list_fallback=*/true);
4453-
XCTAssertTrue([flutterPlatformViewsController submitFrame:std::move(mock_surface)
4454-
withIosContext:std::make_shared<FakeIOSContext>()]);
4434+
XCTAssertTrue([flutterPlatformViewsController
4435+
submitFrame:std::move(mock_surface)
4436+
withIosContext:std::make_shared<flutter::IOSContextNoop>()]);
44554437

44564438
// platform view is wrapped by touch interceptor, which itself is wrapped by clipping view.
44574439
UIView* clippingView1 = view1.superview.superview;
@@ -4478,8 +4460,9 @@ - (void)testFlutterPlatformViewControllerBeginFrameShouldResetCompisitionOrder {
44784460
[](const flutter::SurfaceFrame& surface_frame, flutter::DlCanvas* canvas) { return true; },
44794461
[](const flutter::SurfaceFrame& surface_frame) { return true; },
44804462
/*frame_size=*/flutter::DlISize(800, 600), nullptr, /*display_list_fallback=*/true);
4481-
XCTAssertTrue([flutterPlatformViewsController submitFrame:std::move(mock_surface)
4482-
withIosContext:std::make_shared<FakeIOSContext>()]);
4463+
XCTAssertTrue([flutterPlatformViewsController
4464+
submitFrame:std::move(mock_surface)
4465+
withIosContext:std::make_shared<flutter::IOSContextNoop>()]);
44834466

44844467
XCTAssertTrue([flutterView.subviews indexOfObject:clippingView1] >
44854468
[flutterView.subviews indexOfObject:clippingView2],
@@ -4552,8 +4535,9 @@ - (void)testFlutterPlatformViewControllerBeginFrameShouldResetCompisitionOrder {
45524535
[](const flutter::SurfaceFrame& surface_frame, flutter::DlCanvas* canvas) { return true; },
45534536
[](const flutter::SurfaceFrame& surface_frame) { return true; },
45544537
/*frame_size=*/flutter::DlISize(800, 600), nullptr, /*display_list_fallback=*/true);
4555-
XCTAssertTrue([flutterPlatformViewsController submitFrame:std::move(mock_surface)
4556-
withIosContext:std::make_shared<FakeIOSContext>()]);
4538+
XCTAssertTrue([flutterPlatformViewsController
4539+
submitFrame:std::move(mock_surface)
4540+
withIosContext:std::make_shared<flutter::IOSContextNoop>()]);
45574541

45584542
// platform view is wrapped by touch interceptor, which itself is wrapped by clipping view.
45594543
UIView* clippingView1 = view1.superview.superview;
@@ -4580,8 +4564,9 @@ - (void)testFlutterPlatformViewControllerBeginFrameShouldResetCompisitionOrder {
45804564
[](const flutter::SurfaceFrame& surface_frame, flutter::DlCanvas* canvas) { return true; },
45814565
[](const flutter::SurfaceFrame& surface_frame) { return true; },
45824566
/*frame_size=*/flutter::DlISize(800, 600), nullptr, /*display_list_fallback=*/true);
4583-
XCTAssertTrue([flutterPlatformViewsController submitFrame:std::move(mock_surface)
4584-
withIosContext:std::make_shared<FakeIOSContext>()]);
4567+
XCTAssertTrue([flutterPlatformViewsController
4568+
submitFrame:std::move(mock_surface)
4569+
withIosContext:std::make_shared<flutter::IOSContextNoop>()]);
45854570

45864571
XCTAssertTrue([flutterView.subviews indexOfObject:clippingView1] <
45874572
[flutterView.subviews indexOfObject:clippingView2],
@@ -5030,8 +5015,9 @@ - (void)testDisposingViewInCompositionOrderDoNotCrash {
50305015
[](const flutter::SurfaceFrame& surface_frame) { return true; },
50315016
/*frame_size=*/flutter::DlISize(800, 600), nullptr,
50325017
/*display_list_fallback=*/true);
5033-
XCTAssertTrue([flutterPlatformViewsController submitFrame:std::move(mock_surface)
5034-
withIosContext:std::make_shared<FakeIOSContext>()]);
5018+
XCTAssertTrue([flutterPlatformViewsController
5019+
submitFrame:std::move(mock_surface)
5020+
withIosContext:std::make_shared<flutter::IOSContextNoop>()]);
50355021

50365022
// Disposing won't remove embedded views until the view is removed from the composition_order_
50375023
XCTAssertEqual(flutterPlatformViewsController.embeddedViewCount, 2UL);
@@ -5056,8 +5042,9 @@ - (void)testDisposingViewInCompositionOrderDoNotCrash {
50565042
[](const flutter::SurfaceFrame& surface_frame, flutter::DlCanvas* canvas) { return true; },
50575043
[](const flutter::SurfaceFrame& surface_frame) { return true; },
50585044
/*frame_size=*/flutter::DlISize(800, 600), nullptr, /*display_list_fallback=*/true);
5059-
XCTAssertTrue([flutterPlatformViewsController submitFrame:std::move(mock_surface)
5060-
withIosContext:std::make_shared<FakeIOSContext>()]);
5045+
XCTAssertTrue([flutterPlatformViewsController
5046+
submitFrame:std::move(mock_surface)
5047+
withIosContext:std::make_shared<flutter::IOSContextNoop>()]);
50615048

50625049
// Disposing won't remove embedded views until the view is removed from the composition_order_
50635050
XCTAssertEqual(flutterPlatformViewsController.embeddedViewCount, 1UL);
@@ -5121,7 +5108,7 @@ - (void)testOnlyPlatformViewsAreRemovedWhenReset {
51215108
[](const flutter::SurfaceFrame& surface_frame) { return true; },
51225109
/*frame_size=*/flutter::DlISize(800, 600), nullptr, /*display_list_fallback=*/true);
51235110
[flutterPlatformViewsController submitFrame:std::move(mock_surface)
5124-
withIosContext:std::make_shared<FakeIOSContext>()];
5111+
withIosContext:std::make_shared<flutter::IOSContextNoop>()];
51255112

51265113
UIView* someView = [[UIView alloc] init];
51275114
[flutterView addSubview:someView];
@@ -5187,7 +5174,7 @@ - (void)testResetClearsPreviousCompositionOrder {
51875174
[](const flutter::SurfaceFrame& surface_frame) { return true; },
51885175
/*frame_size=*/flutter::DlISize(800, 600), nullptr, /*display_list_fallback=*/true);
51895176
[flutterPlatformViewsController submitFrame:std::move(mock_surface)
5190-
withIosContext:std::make_shared<FakeIOSContext>()];
5177+
withIosContext:std::make_shared<flutter::IOSContextNoop>()];
51915178

51925179
// The above code should result in previousCompositionOrder having one viewId in it
51935180
XCTAssertEqual(flutterPlatformViewsController.previousCompositionOrder.count, 1ul);
@@ -5256,7 +5243,7 @@ - (void)testNilPlatformViewDoesntCrash {
52565243
[](const flutter::SurfaceFrame& surface_frame) { return true; },
52575244
/*frame_size=*/flutter::DlISize(800, 600), nullptr, /*display_list_fallback=*/true);
52585245
[flutterPlatformViewsController submitFrame:std::move(mock_surface)
5259-
withIosContext:std::make_shared<FakeIOSContext>()];
5246+
withIosContext:std::make_shared<flutter::IOSContextNoop>()];
52605247

52615248
XCTAssertEqual(flutterView.subviews.count, 1u);
52625249
}
@@ -5367,7 +5354,7 @@ - (void)testFlutterPlatformViewControllerSubmitFramePreservingFrameDamage {
53675354
});
53685355

53695356
[flutterPlatformViewsController submitFrame:std::move(mock_surface)
5370-
withIosContext:std::make_shared<FakeIOSContext>()];
5357+
withIosContext:std::make_shared<flutter::IOSContextNoop>()];
53715358

53725359
XCTAssertTrue(submit_info.has_value());
53735360
XCTAssertEqual(*submit_info->frame_damage, flutter::DlIRect::MakeWH(800, 600));

0 commit comments

Comments
 (0)