From 4af02c9f4967109aac9f4c1047e42e25709ae6bc Mon Sep 17 00:00:00 2001 From: skia-flutter-autoroll Date: Wed, 6 Sep 2023 15:35:49 -0400 Subject: [PATCH 01/15] Roll Fuchsia Mac SDK from dFe-t1SosqZwU5lZR... to hHwU6r12A0sy5Bq-0... (#45505) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/fuchsia-mac-sdk-flutter-engine Please CC rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index f997d65d631e2..50fd1fe2091a3 100644 --- a/DEPS +++ b/DEPS @@ -914,7 +914,7 @@ deps = { 'packages': [ { 'package': 'fuchsia/sdk/core/mac-amd64', - 'version': 'dFe-t1SosqZwU5lZRJfhlmiQNzNSKCiUmS_h3uirntsC' + 'version': 'hHwU6r12A0sy5Bq-0EiKQzK-Mv4l3N9k7MroYgVJExQC' } ], 'condition': 'host_os == "mac" and not download_fuchsia_sdk', From 375b614c5e93da7ffa847f1c2f4e9f477a2b094f Mon Sep 17 00:00:00 2001 From: skia-flutter-autoroll Date: Wed, 6 Sep 2023 15:38:07 -0400 Subject: [PATCH 02/15] Roll Skia from 59e54ccf25a4 to e5ed4ffaaaa4 (4 revisions) (#45506) https://skia.googlesource.com/skia.git/+log/59e54ccf25a4..e5ed4ffaaaa4 2023-09-06 kjlubick@google.com Remove unnecessary gni groups 2023-09-06 kjlubick@google.com Move buffet rules to their respective packages 2023-09-06 bungeman@google.com [paragraph] Allow multiple unicode implementations 2023-09-06 jamesgk@google.com [graphite] Consider "need dst read" equivalent to "do in-shader blend" If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/skia-flutter-autoroll Please CC armansito@google.com,brianosman@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Skia: https://bugs.chromium.org/p/skia/issues/entry To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md --- DEPS | 2 +- ci/licenses_golden/licenses_skia | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DEPS b/DEPS index 50fd1fe2091a3..c29058d7b9548 100644 --- a/DEPS +++ b/DEPS @@ -18,7 +18,7 @@ vars = { 'llvm_git': 'https://llvm.googlesource.com', # OCMock is for testing only so there is no google clone 'ocmock_git': 'https://github.com/erikdoe/ocmock.git', - 'skia_revision': '59e54ccf25a42768e4c078cad90b7e9f5c69b33c', + 'skia_revision': 'e5ed4ffaaaa4c7d108423f44bddc35ac1fc549df', # WARNING: DO NOT EDIT canvaskit_cipd_instance MANUALLY # See `lib/web_ui/README.md` for how to roll CanvasKit to a new version. diff --git a/ci/licenses_golden/licenses_skia b/ci/licenses_golden/licenses_skia index 65e449464696e..dec4b5df8a3df 100644 --- a/ci/licenses_golden/licenses_skia +++ b/ci/licenses_golden/licenses_skia @@ -1,4 +1,4 @@ -Signature: c91abc77e50dc3e4d6183c7dd1874c02 +Signature: c5688dce472c766fb3aa99eedf88592a ==================================================================================================== LIBRARY: etc1 From be04bf38dafd81210f8dcbf902644077bd42ceff Mon Sep 17 00:00:00 2001 From: skia-flutter-autoroll Date: Wed, 6 Sep 2023 15:41:54 -0400 Subject: [PATCH 03/15] Roll ANGLE from 7b0bb0f6e785 to 00daa451320c (1 revision) (#45507) https://chromium.googlesource.com/angle/angle.git/+log/7b0bb0f6e785..00daa451320c 2023-09-06 cnorthrop@google.com Vulkan: Include minImageCount in swapchain check If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/angle-flutter-engine Please CC flutter-engine@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in ANGLE: http://anglebug.com/new To file a bug in Flutter Engine: https://github.com/flutter/flutter/issues/new To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md --- DEPS | 2 +- ci/licenses_golden/licenses_third_party | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DEPS b/DEPS index c29058d7b9548..c409e88c0d281 100644 --- a/DEPS +++ b/DEPS @@ -631,7 +631,7 @@ deps = { Var('swiftshader_git') + '/SwiftShader.git' + '@' + '5f9ed9b16931c7155171d31f75004f73f0a3abc8', 'src/third_party/angle': - Var('chromium_git') + '/angle/angle.git' + '@' + '7b0bb0f6e785ec810761984c0fc09f603a1c4bde', + Var('chromium_git') + '/angle/angle.git' + '@' + '00daa451320c3edf8dc8add9eb0f3cfcf2aca70d', 'src/third_party/vulkan_memory_allocator': Var('chromium_git') + '/external/github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator' + '@' + '7de5cc00de50e71a3aab22dea52fbb7ff4efceb6', diff --git a/ci/licenses_golden/licenses_third_party b/ci/licenses_golden/licenses_third_party index 4532c28f79bbc..8c1a1f1633e1c 100644 --- a/ci/licenses_golden/licenses_third_party +++ b/ci/licenses_golden/licenses_third_party @@ -1,4 +1,4 @@ -Signature: 6710d89decb9aa08a5507129f15dc523 +Signature: 3a1d9f7353c9a77bca16f1d2b42b35fa ==================================================================================================== LIBRARY: angle From 70fe4594d47d52a6254d114a93e5838620672a11 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Wed, 6 Sep 2023 12:56:42 -0700 Subject: [PATCH 04/15] Enforce the rule of calling `FlutterView.Render` (#45300) This PR enforces the rules as documented in `FlutterView.Render`, where calls in illegal situations should be ignored - but have never been enforced. ``` /// This function must be called within the scope of the /// [PlatformDispatcher.onBeginFrame] or [PlatformDispatcher.onDrawFrame] /// callbacks being invoked. /// /// If this function is called a second time during a single /// [PlatformDispatcher.onBeginFrame]/[PlatformDispatcher.onDrawFrame] /// callback sequence or called outside the scope of those callbacks, the call /// will be ignored. ``` This rule is very important to implementing multi-view without having to introduce new APIs. However, currently these illegal calls are not ignored, and historically many tests (especially integration tests) were unknowingly running based on this fact. @goderbauer did great work by eliminating these cases in g3, and it's time for us to make sure these calls are ignored. Most effort of this PR goes to unit testing the changes. Some part of `Shell::Create` is extracted into a static function to avoid duplicate code. ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on writing and running engine tests. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I signed the [CLA]. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat --- lib/ui/fixtures/ui_test.dart | 42 +++ lib/ui/platform_dispatcher.dart | 33 +++ lib/ui/window.dart | 9 +- .../platform_configuration_unittests.cc | 240 ++++++++++++++++++ shell/common/shell.cc | 31 ++- shell/common/shell.h | 10 + 6 files changed, 351 insertions(+), 14 deletions(-) diff --git a/lib/ui/fixtures/ui_test.dart b/lib/ui/fixtures/ui_test.dart index 0aff1775688b7..3cc93a746921a 100644 --- a/lib/ui/fixtures/ui_test.dart +++ b/lib/ui/fixtures/ui_test.dart @@ -1076,3 +1076,45 @@ external void _callHook( Object? arg20, Object? arg21, ]); + +Scene _createRedBoxScene(Size size) { + final SceneBuilder builder = SceneBuilder(); + builder.pushOffset(0.0, 0.0); + final Paint paint = Paint() + ..color = Color.fromARGB(255, 255, 0, 0) + ..style = PaintingStyle.fill; + final PictureRecorder baseRecorder = PictureRecorder(); + final Canvas canvas = Canvas(baseRecorder); + canvas.drawRect(Rect.fromLTRB(0.0, 0.0, size.width, size.height), paint); + final Picture picture = baseRecorder.endRecording(); + builder.addPicture(Offset(0.0, 0.0), picture); + builder.pop(); + return builder.build(); +} + +@pragma('vm:entry-point') +void incorrectImmediateRender() { + PlatformDispatcher.instance.views.first.render(_createRedBoxScene(Size(2, 2))); + _finish(); + // Don't schedule a frame here. This test only checks if the + // [FlutterView.render] call is propagated to PlatformConfiguration.render + // and thus doesn't need anything from `Animator` or `Engine`, which, + // besides, are not even created in the native side at all. +} + +@pragma('vm:entry-point') +void incorrectDoubleRender() { + PlatformDispatcher.instance.onBeginFrame = (Duration value) { + PlatformDispatcher.instance.views.first.render(_createRedBoxScene(Size(2, 2))); + PlatformDispatcher.instance.views.first.render(_createRedBoxScene(Size(3, 3))); + }; + PlatformDispatcher.instance.onDrawFrame = () { + PlatformDispatcher.instance.views.first.render(_createRedBoxScene(Size(4, 4))); + PlatformDispatcher.instance.views.first.render(_createRedBoxScene(Size(5, 5))); + }; + _finish(); + // Don't schedule a frame here. This test only checks if the + // [FlutterView.render] call is propagated to PlatformConfiguration.render + // and thus doesn't need anything from `Animator` or `Engine`, which, + // besides, are not even created in the native side at all. +} diff --git a/lib/ui/platform_dispatcher.dart b/lib/ui/platform_dispatcher.dart index 6d86cc6270315..7432c96a74c51 100644 --- a/lib/ui/platform_dispatcher.dart +++ b/lib/ui/platform_dispatcher.dart @@ -308,6 +308,21 @@ class PlatformDispatcher { _invoke(onMetricsChanged, _onMetricsChangedZone); } + // [FlutterView]s for which [FlutterView.render] has already been called + // during the current [onBeginFrame]/[onDrawFrame] callback sequence. + // + // The field is null outside the scope of those callbacks indicating that + // calls to [FlutterView.render] must be ignored. Furthermore, if a given + // [FlutterView] is already present in this set when its [FlutterView.render] + // is called again, that call must be ignored as a duplicate. + // + // Between [onBeginFrame] and [onDrawFrame] the properties value is + // temporarily stored in `_renderedViewsBetweenCallbacks` so that it survives + // the gap between the two callbacks. + Set? _renderedViews; + // Temporary storage of the `_renderedViews` value between `_beginFrame` and + // `_drawFrame`. + Set? _renderedViewsBetweenCallbacks; /// A callback invoked when any view begins a frame. /// @@ -329,11 +344,20 @@ class PlatformDispatcher { // Called from the engine, via hooks.dart void _beginFrame(int microseconds) { + assert(_renderedViews == null); + assert(_renderedViewsBetweenCallbacks == null); + + _renderedViews = {}; _invoke1( onBeginFrame, _onBeginFrameZone, Duration(microseconds: microseconds), ); + _renderedViewsBetweenCallbacks = _renderedViews; + _renderedViews = null; + + assert(_renderedViews == null); + assert(_renderedViewsBetweenCallbacks != null); } /// A callback that is invoked for each frame after [onBeginFrame] has @@ -351,7 +375,16 @@ class PlatformDispatcher { // Called from the engine, via hooks.dart void _drawFrame() { + assert(_renderedViews == null); + assert(_renderedViewsBetweenCallbacks != null); + + _renderedViews = _renderedViewsBetweenCallbacks; + _renderedViewsBetweenCallbacks = null; _invoke(onDrawFrame, _onDrawFrameZone); + _renderedViews = null; + + assert(_renderedViews == null); + assert(_renderedViewsBetweenCallbacks == null); } /// A callback that is invoked when pointer data is available. diff --git a/lib/ui/window.dart b/lib/ui/window.dart index d86781ef2567f..4c5df1874fed4 100644 --- a/lib/ui/window.dart +++ b/lib/ui/window.dart @@ -353,7 +353,14 @@ class FlutterView { /// scheduling of frames. /// * [RendererBinding], the Flutter framework class which manages layout and /// painting. - void render(Scene scene) => _render(scene as _NativeScene); + void render(Scene scene) { + if (platformDispatcher._renderedViews?.add(this) != true) { + // Duplicated calls or calls outside of onBeginFrame/onDrawFrame + // (indicated by _renderedViews being null) are ignored, as documented. + return; + } + _render(scene as _NativeScene); + } @Native)>(symbol: 'PlatformConfigurationNativeApi::Render') external static void _render(_NativeScene scene); diff --git a/lib/ui/window/platform_configuration_unittests.cc b/lib/ui/window/platform_configuration_unittests.cc index 7410caeb66d6c..50a9bd102164f 100644 --- a/lib/ui/window/platform_configuration_unittests.cc +++ b/lib/ui/window/platform_configuration_unittests.cc @@ -15,10 +15,171 @@ #include "flutter/shell/common/shell_test.h" #include "flutter/shell/common/thread_host.h" #include "flutter/testing/testing.h" +#include "gmock/gmock.h" namespace flutter { + +namespace { + +static constexpr int64_t kImplicitViewId = 0; + +static void PostSync(const fml::RefPtr& task_runner, + const fml::closure& task) { + fml::AutoResetWaitableEvent latch; + fml::TaskRunner::RunNowOrPostTask(task_runner, [&latch, &task] { + task(); + latch.Signal(); + }); + latch.Wait(); +} + +class MockRuntimeDelegate : public RuntimeDelegate { + public: + MOCK_METHOD(std::string, DefaultRouteName, (), (override)); + MOCK_METHOD(void, ScheduleFrame, (bool), (override)); + MOCK_METHOD(void, + Render, + (std::unique_ptr, float), + (override)); + MOCK_METHOD(void, + UpdateSemantics, + (SemanticsNodeUpdates, CustomAccessibilityActionUpdates), + (override)); + MOCK_METHOD(void, + HandlePlatformMessage, + (std::unique_ptr), + (override)); + MOCK_METHOD(FontCollection&, GetFontCollection, (), (override)); + MOCK_METHOD(std::shared_ptr, GetAssetManager, (), (override)); + MOCK_METHOD(void, OnRootIsolateCreated, (), (override)); + MOCK_METHOD(void, + UpdateIsolateDescription, + (const std::string, int64_t), + (override)); + MOCK_METHOD(void, SetNeedsReportTimings, (bool), (override)); + MOCK_METHOD(std::unique_ptr>, + ComputePlatformResolvedLocale, + (const std::vector&), + (override)); + MOCK_METHOD(void, RequestDartDeferredLibrary, (intptr_t), (override)); + MOCK_METHOD(std::weak_ptr, + GetPlatformMessageHandler, + (), + (const, override)); + MOCK_METHOD(void, SendChannelUpdate, (std::string, bool), (override)); + MOCK_METHOD(double, + GetScaledFontSize, + (double font_size, int configuration_id), + (const, override)); +}; + +class MockPlatformMessageHandler : public PlatformMessageHandler { + public: + MOCK_METHOD(void, + HandlePlatformMessage, + (std::unique_ptr message), + (override)); + MOCK_METHOD(bool, + DoesHandlePlatformMessageOnPlatformThread, + (), + (const, override)); + MOCK_METHOD(void, + InvokePlatformMessageResponseCallback, + (int response_id, std::unique_ptr mapping), + (override)); + MOCK_METHOD(void, + InvokePlatformMessageEmptyResponseCallback, + (int response_id), + (override)); +}; + +// A class that can launch a RuntimeController with the specified +// RuntimeDelegate. +// +// To use this class, contruct this class with Create, call LaunchRootIsolate, +// and use the controller with ControllerTaskSync(). +class RuntimeControllerContext { + public: + using ControllerCallback = std::function; + + [[nodiscard]] static std::unique_ptr Create( + Settings settings, // + const TaskRunners& task_runners, // + RuntimeDelegate& client) { + auto [vm, isolate_snapshot] = Shell::InferVmInitDataFromSettings(settings); + FML_CHECK(vm) << "Must be able to initialize the VM."; + // Construct the class with `new` because `make_unique` has no access to the + // private constructor. + RuntimeControllerContext* raw_pointer = new RuntimeControllerContext( + settings, task_runners, client, std::move(vm), isolate_snapshot); + return std::unique_ptr(raw_pointer); + } + + ~RuntimeControllerContext() { + PostSync(task_runners_.GetUITaskRunner(), + [&]() { runtime_controller_.reset(); }); + } + + // Launch the root isolate. The post_launch callback will be executed in the + // same UI task, which can be used to create initial views. + void LaunchRootIsolate(RunConfiguration& configuration, + ControllerCallback post_launch) { + PostSync(task_runners_.GetUITaskRunner(), [&]() { + bool launch_success = runtime_controller_->LaunchRootIsolate( + settings_, // + []() {}, // + configuration.GetEntrypoint(), // + configuration.GetEntrypointLibrary(), // + configuration.GetEntrypointArgs(), // + configuration.TakeIsolateConfiguration()); // + ASSERT_TRUE(launch_success); + post_launch(*runtime_controller_); + }); + } + + // Run a task that operates the RuntimeController on the UI thread, and wait + // for the task to end. + void ControllerTaskSync(ControllerCallback task) { + ASSERT_TRUE(runtime_controller_); + ASSERT_TRUE(task); + PostSync(task_runners_.GetUITaskRunner(), + [&]() { task(*runtime_controller_); }); + } + + private: + RuntimeControllerContext(const Settings& settings, + const TaskRunners& task_runners, + RuntimeDelegate& client, + DartVMRef vm, + fml::RefPtr isolate_snapshot) + : settings_(settings), + task_runners_(task_runners), + isolate_snapshot_(std::move(isolate_snapshot)), + vm_(std::move(vm)), + runtime_controller_(std::make_unique( + client, + &vm_, + std::move(isolate_snapshot_), + settings.idle_notification_callback, // idle notification callback + flutter::PlatformData(), // platform data + settings.isolate_create_callback, // isolate create callback + settings.isolate_shutdown_callback, // isolate shutdown callback + settings.persistent_isolate_data, // persistent isolate data + UIDartState::Context{task_runners})) {} + + Settings settings_; + TaskRunners task_runners_; + fml::RefPtr isolate_snapshot_; + DartVMRef vm_; + std::unique_ptr runtime_controller_; +}; +} // namespace + namespace testing { +using ::testing::_; +using ::testing::Return; + class PlatformConfigurationTest : public ShellTest {}; TEST_F(PlatformConfigurationTest, Initialization) { @@ -332,5 +493,84 @@ TEST_F(PlatformConfigurationTest, SetDartPerformanceMode) { DestroyShell(std::move(shell), task_runners); } +TEST_F(PlatformConfigurationTest, OutOfScopeRenderCallsAreIgnored) { + Settings settings = CreateSettingsForFixture(); + TaskRunners task_runners = GetTaskRunnersForFixture(); + + MockRuntimeDelegate client; + auto platform_message_handler = + std::make_shared(); + EXPECT_CALL(client, GetPlatformMessageHandler) + .WillOnce(Return(platform_message_handler)); + // Render should not be called. + EXPECT_CALL(client, Render).Times(0); + + auto message_latch = std::make_shared(); + auto finish = [message_latch](Dart_NativeArguments args) { + message_latch->Signal(); + }; + AddNativeCallback("Finish", CREATE_NATIVE_ENTRY(finish)); + + auto runtime_controller_context = + RuntimeControllerContext::Create(settings, task_runners, client); + + auto configuration = RunConfiguration::InferFromSettings(settings); + configuration.SetEntrypoint("incorrectImmediateRender"); + runtime_controller_context->LaunchRootIsolate( + configuration, [](RuntimeController& runtime_controller) { + runtime_controller.AddView( + kImplicitViewId, + ViewportMetrics( + /*pixel_ratio=*/1.0, /*width=*/20, /*height=*/20, + /*touch_slop=*/2, /*display_id=*/0)); + }); + + // Wait for the Dart main function to end. + message_latch->Wait(); +} + +TEST_F(PlatformConfigurationTest, DuplicateRenderCallsAreIgnored) { + Settings settings = CreateSettingsForFixture(); + TaskRunners task_runners = GetTaskRunnersForFixture(); + + MockRuntimeDelegate client; + auto platform_message_handler = + std::make_shared(); + EXPECT_CALL(client, GetPlatformMessageHandler) + .WillOnce(Return(platform_message_handler)); + // Render should only be called once, because the second call is ignored. + EXPECT_CALL(client, Render).Times(1); + + auto message_latch = std::make_shared(); + auto finish = [message_latch](Dart_NativeArguments args) { + message_latch->Signal(); + }; + AddNativeCallback("Finish", CREATE_NATIVE_ENTRY(finish)); + + auto runtime_controller_context = + RuntimeControllerContext::Create(settings, task_runners, client); + + auto configuration = RunConfiguration::InferFromSettings(settings); + configuration.SetEntrypoint("incorrectDoubleRender"); + runtime_controller_context->LaunchRootIsolate( + configuration, [](RuntimeController& runtime_controller) { + runtime_controller.AddView( + kImplicitViewId, + ViewportMetrics( + /*pixel_ratio=*/1.0, /*width=*/20, /*height=*/20, + /*touch_slop=*/2, /*display_id=*/0)); + }); + + // Wait for the Dart main function to end. + message_latch->Wait(); + + runtime_controller_context->ControllerTaskSync( + [](RuntimeController& runtime_controller) { + // This BeginFrame calls PlatformDispatcher's handleBeginFrame and + // handleDrawFrame synchronously. Therefore don't wait after it. + runtime_controller.BeginFrame(fml::TimePoint::Now(), 0); + }); +} + } // namespace testing } // namespace flutter diff --git a/shell/common/shell.cc b/shell/common/shell.cc index 261a41fff2767..4d0bec79af2c5 100644 --- a/shell/common/shell.cc +++ b/shell/common/shell.cc @@ -144,31 +144,36 @@ void PerformInitializationTasks(Settings& settings) { } // namespace -std::unique_ptr Shell::Create( - const PlatformData& platform_data, - const TaskRunners& task_runners, - Settings settings, - const Shell::CreateCallback& on_create_platform_view, - const Shell::CreateCallback& on_create_rasterizer, - bool is_gpu_disabled) { - // This must come first as it initializes tracing. - PerformInitializationTasks(settings); - - TRACE_EVENT0("flutter", "Shell::Create"); - +std::pair> +Shell::InferVmInitDataFromSettings(Settings& settings) { // Always use the `vm_snapshot` and `isolate_snapshot` provided by the // settings to launch the VM. If the VM is already running, the snapshot // arguments are ignored. auto vm_snapshot = DartSnapshot::VMSnapshotFromSettings(settings); auto isolate_snapshot = DartSnapshot::IsolateSnapshotFromSettings(settings); auto vm = DartVMRef::Create(settings, vm_snapshot, isolate_snapshot); - FML_CHECK(vm) << "Must be able to initialize the VM."; // If the settings did not specify an `isolate_snapshot`, fall back to the // one the VM was launched with. if (!isolate_snapshot) { isolate_snapshot = vm->GetVMData()->GetIsolateSnapshot(); } + return {std::move(vm), isolate_snapshot}; +} + +std::unique_ptr Shell::Create( + const PlatformData& platform_data, + const TaskRunners& task_runners, + Settings settings, + const Shell::CreateCallback& on_create_platform_view, + const Shell::CreateCallback& on_create_rasterizer, + bool is_gpu_disabled) { + // This must come first as it initializes tracing. + PerformInitializationTasks(settings); + + TRACE_EVENT0("flutter", "Shell::Create"); + + auto [vm, isolate_snapshot] = InferVmInitDataFromSettings(settings); auto resource_cache_limit_calculator = std::make_shared( settings.resource_cache_max_bytes_threshold); diff --git a/shell/common/shell.h b/shell/common/shell.h index b8c9c31052df6..d3bb7f0bd620c 100644 --- a/shell/common/shell.h +++ b/shell/common/shell.h @@ -438,6 +438,16 @@ class Shell final : public PlatformView::Delegate, const std::shared_ptr GetConcurrentWorkerTaskRunner() const; + // Infer the VM ref and the isolate snapshot based on the settings. + // + // If the VM is already running, the settings are ignored, but the returned + // isolate snapshot always prioritize what is specified by the settings, and + // falls back to the one VM was launched with. + // + // This function is what Shell::Create uses to infer snapshot settings. + static std::pair> + InferVmInitDataFromSettings(Settings& settings); + private: using ServiceProtocolHandler = std::function Date: Wed, 6 Sep 2023 12:57:58 -0700 Subject: [PATCH 05/15] Roll Fuchsia with license script fix (#45498) For https://github.com/flutter/flutter/issues/134042 --- DEPS | 2 +- ci/licenses_golden/excluded_files | 2 ++ ci/licenses_golden/licenses_fuchsia | 22 +++++++++++++++++++++- ci/licenses_golden/tool_signature | 2 +- tools/licenses/lib/paths.dart | 1 + 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/DEPS b/DEPS index c409e88c0d281..e346ebc9d9fa3 100644 --- a/DEPS +++ b/DEPS @@ -924,7 +924,7 @@ deps = { 'packages': [ { 'package': 'fuchsia/sdk/core/linux-amd64', - 'version': 'z9uQ0mXwjKFQF05XlBv-X8Em1QvkefyGcIJWrSZEm-sC' + 'version': '8dgICHnG28wNHzoz33qFF_nQu52I3PVTfNbXzV6PWTQC' } ], 'condition': 'host_os == "linux" and not download_fuchsia_sdk', diff --git a/ci/licenses_golden/excluded_files b/ci/licenses_golden/excluded_files index 6313f5fba1325..dd7a5cb1cbf97 100644 --- a/ci/licenses_golden/excluded_files +++ b/ci/licenses_golden/excluded_files @@ -624,6 +624,8 @@ ../../../fuchsia/sdk/linux/fidl/fuchsia.wlan.softmac/meta.json ../../../fuchsia/sdk/linux/fidl/zx/meta.json ../../../fuchsia/sdk/linux/meta +../../../fuchsia/sdk/linux/packages/blobs +../../../fuchsia/sdk/linux/packages/realm_builder_server/meta.json ../../../fuchsia/sdk/linux/pkg/async-cpp/meta.json ../../../fuchsia/sdk/linux/pkg/async-default/meta.json ../../../fuchsia/sdk/linux/pkg/async-loop-cpp/meta.json diff --git a/ci/licenses_golden/licenses_fuchsia b/ci/licenses_golden/licenses_fuchsia index b8d60381fc554..fbffcba766086 100644 --- a/ci/licenses_golden/licenses_fuchsia +++ b/ci/licenses_golden/licenses_fuchsia @@ -1,4 +1,4 @@ -Signature: 9a31319fc49dcb0a9eed7caba8bc94aa +Signature: ba6463628187613a22cdde62a73696f0 ==================================================================================================== LIBRARY: fuchsia_sdk @@ -536,6 +536,12 @@ FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/libpthread.so FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/librt.so FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/libzircon.so FILE: ../../../fuchsia/sdk/linux/data/config/symbol_index/config.json +FILE: ../../../fuchsia/sdk/linux/packages/realm_builder_server/arm64/release/content_checklist_path +FILE: ../../../fuchsia/sdk/linux/packages/realm_builder_server/arm64/release/package_manifest.json +FILE: ../../../fuchsia/sdk/linux/packages/realm_builder_server/riscv64/release/content_checklist_path +FILE: ../../../fuchsia/sdk/linux/packages/realm_builder_server/riscv64/release/package_manifest.json +FILE: ../../../fuchsia/sdk/linux/packages/realm_builder_server/x64/release/content_checklist_path +FILE: ../../../fuchsia/sdk/linux/packages/realm_builder_server/x64/release/package_manifest.json FILE: ../../../fuchsia/sdk/linux/pkg/async-default/async-default.ifs FILE: ../../../fuchsia/sdk/linux/pkg/driver_runtime_shared_lib/driver_runtime.ifs FILE: ../../../fuchsia/sdk/linux/pkg/fdio/fdio.ifs @@ -2340,6 +2346,12 @@ FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/libpthread.so FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/librt.so FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/libzircon.so FILE: ../../../fuchsia/sdk/linux/data/config/symbol_index/config.json +FILE: ../../../fuchsia/sdk/linux/packages/realm_builder_server/arm64/release/content_checklist_path +FILE: ../../../fuchsia/sdk/linux/packages/realm_builder_server/arm64/release/package_manifest.json +FILE: ../../../fuchsia/sdk/linux/packages/realm_builder_server/riscv64/release/content_checklist_path +FILE: ../../../fuchsia/sdk/linux/packages/realm_builder_server/riscv64/release/package_manifest.json +FILE: ../../../fuchsia/sdk/linux/packages/realm_builder_server/x64/release/content_checklist_path +FILE: ../../../fuchsia/sdk/linux/packages/realm_builder_server/x64/release/package_manifest.json FILE: ../../../fuchsia/sdk/linux/pkg/async-default/async-default.ifs FILE: ../../../fuchsia/sdk/linux/pkg/driver_runtime_shared_lib/driver_runtime.ifs FILE: ../../../fuchsia/sdk/linux/pkg/fdio/fdio.ifs @@ -4242,6 +4254,7 @@ ORIGIN: ../../../fuchsia/sdk/linux/fidl/fuchsia.hardware.audio/clock.fidl + ../. ORIGIN: ../../../fuchsia/sdk/linux/fidl/fuchsia.hardware.audio/common.fidl + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/fidl/fuchsia.hardware.audio/composite.fidl + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/fidl/fuchsia.hardware.audio/composite_connector.fidl + ../../../fuchsia/sdk/linux/LICENSE +ORIGIN: ../../../fuchsia/sdk/linux/fidl/fuchsia.hardware.audio/device_type.fidl + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/fidl/fuchsia.hardware.audio/plug.fidl + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/fidl/fuchsia.hardware.audio/ring_buffer_format.fidl + ../../../fuchsia/sdk/linux/LICENSE ORIGIN: ../../../fuchsia/sdk/linux/fidl/fuchsia.hardware.network/history.fidl + ../../../fuchsia/sdk/linux/LICENSE @@ -4299,6 +4312,7 @@ FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.hardware.audio/clock.fidl FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.hardware.audio/common.fidl FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.hardware.audio/composite.fidl FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.hardware.audio/composite_connector.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.hardware.audio/device_type.fidl FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.hardware.audio/plug.fidl FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.hardware.audio/ring_buffer_format.fidl FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.hardware.network/history.fidl @@ -4908,6 +4922,12 @@ FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/libpthread.so FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/librt.so FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/lib/libzircon.so FILE: ../../../fuchsia/sdk/linux/data/config/symbol_index/config.json +FILE: ../../../fuchsia/sdk/linux/packages/realm_builder_server/arm64/release/content_checklist_path +FILE: ../../../fuchsia/sdk/linux/packages/realm_builder_server/arm64/release/package_manifest.json +FILE: ../../../fuchsia/sdk/linux/packages/realm_builder_server/riscv64/release/content_checklist_path +FILE: ../../../fuchsia/sdk/linux/packages/realm_builder_server/riscv64/release/package_manifest.json +FILE: ../../../fuchsia/sdk/linux/packages/realm_builder_server/x64/release/content_checklist_path +FILE: ../../../fuchsia/sdk/linux/packages/realm_builder_server/x64/release/package_manifest.json FILE: ../../../fuchsia/sdk/linux/pkg/async-default/async-default.ifs FILE: ../../../fuchsia/sdk/linux/pkg/driver_runtime_shared_lib/driver_runtime.ifs FILE: ../../../fuchsia/sdk/linux/pkg/fdio/fdio.ifs diff --git a/ci/licenses_golden/tool_signature b/ci/licenses_golden/tool_signature index c6a8bbffb78fd..bb1142c385e9a 100644 --- a/ci/licenses_golden/tool_signature +++ b/ci/licenses_golden/tool_signature @@ -1,2 +1,2 @@ -Signature: 996bda987bb421e5aecf9238c247c296 +Signature: 575f2a41ff152394b7e539742fa248e6 diff --git a/tools/licenses/lib/paths.dart b/tools/licenses/lib/paths.dart index ca5b8f6689030..4118cecee57eb 100644 --- a/tools/licenses/lib/paths.dart +++ b/tools/licenses/lib/paths.dart @@ -38,6 +38,7 @@ final Set skippedPaths = { r'fuchsia/sdk/linux/docs', r'fuchsia/sdk/linux/meta', r'fuchsia/sdk/linux/NOTICE.fuchsia', // covers things that contribute to the Fuchsia SDK; see fxb/94240 + r'fuchsia/sdk/linux/packages/blobs', // See https://github.com/flutter/flutter/issues/134042. r'fuchsia/sdk/linux/tools', r'fuchsia/sdk/mac/docs', r'fuchsia/sdk/mac/meta', From fa14d337449b1736dfec71cdc5f916de353008ef Mon Sep 17 00:00:00 2001 From: skia-flutter-autoroll Date: Wed, 6 Sep 2023 16:20:51 -0400 Subject: [PATCH 06/15] Roll Skia from e5ed4ffaaaa4 to a274609c442c (2 revisions) (#45510) https://skia.googlesource.com/skia.git/+log/e5ed4ffaaaa4..a274609c442c 2023-09-06 herb@google.com Reland "Int96 intro and basic operations" 2023-09-06 robertphillips@google.com [graphite] Use kPremul alpha type when blurring If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/skia-flutter-autoroll Please CC armansito@google.com,brianosman@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Skia: https://bugs.chromium.org/p/skia/issues/entry To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md --- DEPS | 2 +- ci/licenses_golden/licenses_skia | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/DEPS b/DEPS index e346ebc9d9fa3..4de42ae7f38fd 100644 --- a/DEPS +++ b/DEPS @@ -18,7 +18,7 @@ vars = { 'llvm_git': 'https://llvm.googlesource.com', # OCMock is for testing only so there is no google clone 'ocmock_git': 'https://github.com/erikdoe/ocmock.git', - 'skia_revision': 'e5ed4ffaaaa4c7d108423f44bddc35ac1fc549df', + 'skia_revision': 'a274609c442cacaf4e13b6a88ca4990b07b86133', # WARNING: DO NOT EDIT canvaskit_cipd_instance MANUALLY # See `lib/web_ui/README.md` for how to roll CanvasKit to a new version. diff --git a/ci/licenses_golden/licenses_skia b/ci/licenses_golden/licenses_skia index dec4b5df8a3df..5d95ea5defeb6 100644 --- a/ci/licenses_golden/licenses_skia +++ b/ci/licenses_golden/licenses_skia @@ -1,4 +1,4 @@ -Signature: c5688dce472c766fb3aa99eedf88592a +Signature: 43237b600ca1059f6b20efcc90247ac8 ==================================================================================================== LIBRARY: etc1 @@ -8829,10 +8829,12 @@ ORIGIN: ../../../third_party/skia/include/private/chromium/SkImageChromium.h + . ORIGIN: ../../../third_party/skia/include/private/gpu/ganesh/GrTextureGenerator.h + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/bentleyottmann/include/BentleyOttmann1.h + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/bentleyottmann/include/EventQueue.h + ../../../third_party/skia/LICENSE +ORIGIN: ../../../third_party/skia/modules/bentleyottmann/include/Int96.h + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/bentleyottmann/include/Point.h + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/bentleyottmann/include/Segment.h + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/bentleyottmann/src/BentleyOttmann1.cpp + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/bentleyottmann/src/EventQueue.cpp + ../../../third_party/skia/LICENSE +ORIGIN: ../../../third_party/skia/modules/bentleyottmann/src/Int96.cpp + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/bentleyottmann/src/Point.cpp + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/bentleyottmann/src/Segment.cpp + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/src/base/SkBezierCurves.h + ../../../third_party/skia/LICENSE @@ -9084,10 +9086,12 @@ FILE: ../../../third_party/skia/include/private/chromium/SkImageChromium.h FILE: ../../../third_party/skia/include/private/gpu/ganesh/GrTextureGenerator.h FILE: ../../../third_party/skia/modules/bentleyottmann/include/BentleyOttmann1.h FILE: ../../../third_party/skia/modules/bentleyottmann/include/EventQueue.h +FILE: ../../../third_party/skia/modules/bentleyottmann/include/Int96.h FILE: ../../../third_party/skia/modules/bentleyottmann/include/Point.h FILE: ../../../third_party/skia/modules/bentleyottmann/include/Segment.h FILE: ../../../third_party/skia/modules/bentleyottmann/src/BentleyOttmann1.cpp FILE: ../../../third_party/skia/modules/bentleyottmann/src/EventQueue.cpp +FILE: ../../../third_party/skia/modules/bentleyottmann/src/Int96.cpp FILE: ../../../third_party/skia/modules/bentleyottmann/src/Point.cpp FILE: ../../../third_party/skia/modules/bentleyottmann/src/Segment.cpp FILE: ../../../third_party/skia/src/base/SkBezierCurves.h From 59c95058eb87ccd36cca4a5c0a3b4d90fcb40819 Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Wed, 6 Sep 2023 13:44:02 -0700 Subject: [PATCH 07/15] Add macOS support for plugin value publishing (#45502) These directly copy the iOS APIs, to minimize the branching needed in plugins with shared implementation code, and to facilitate the long-term goal of merging the iOS and macOS plugin headers. This does mean replicating the unfortunately non-idiomatic behavior of having `valuePublishedByPlugin:` sometimes return `nil` and sometimes return `NSNull`, instead of distinguishing between `nil` cases (if that's actually even necessary here) via a more specific API. In isolation I would definitely not design the API with this behavior, but consistency with iOS is the more important factor. (Eventually I think we'll need a sort of "v2" of iOS plugin APIs since there are a number of strange behaviors that we're currently stuck with, but migrating iOS and macOS together to a new set of APIs won't be any harder than doing just iOS, and in the short to medium term consistency will help the ecosystem more that trying to pre-create better APIs as macOS-only.) Also fixes `FlutterEngineRegistrar` to have a weak pointer to the engine. This should really already have been the case since plugins can retain the registrar, creating a likely cycle; it's now a guaranteed cycle (and failed unit tests designed to find cycles) without that since the engine itself is now keeping references to them. Fixes https://github.com/flutter/flutter/issues/124721 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- .../Headers/FlutterPluginRegistrarMacOS.h | 24 +++++++++ .../macos/framework/Source/FlutterEngine.mm | 43 ++++++++++++++-- .../framework/Source/FlutterEngineTest.mm | 50 +++++++++++++++++++ .../framework/Source/FlutterViewController.mm | 4 ++ 4 files changed, 118 insertions(+), 3 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h b/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h index 5affc8d0fe9da..16768776afb0c 100644 --- a/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h +++ b/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h @@ -71,6 +71,20 @@ FLUTTER_DARWIN_EXPORT - (void)registerViewFactory:(nonnull NSObject*)factory withId:(nonnull NSString*)factoryId; +/** + * Publishes a value for external use of the plugin. + * + * Plugins may publish a single value, such as an instance of the + * plugin's main class, for situations where external control or + * interaction is needed. + * + * The published value will be available from the `FlutterPluginRegistry`. + * Repeated calls overwrite any previous publication. + * + * @param value The value to be published. + */ +- (void)publish:(nonnull NSObject*)value; + /** * Returns the file name for the given asset. * The returned file name can be used to access the asset in the application's main bundle. @@ -119,4 +133,14 @@ FLUTTER_DARWIN_EXPORT */ - (nonnull id)registrarForPlugin:(nonnull NSString*)pluginKey; +/** + * Returns a value published by the specified plugin. + * + * @param pluginKey The unique key identifying the plugin. + * @return An object published by the plugin, if any. Will be `NSNull` if + * nothing has been published. Will be `nil` if the plugin has not been + * registered. + */ +- (nullable NSObject*)valuePublishedByPlugin:(nonnull NSString*)pluginKey; + @end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index 7d4a6e6e0670c..ac808395c0c05 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -25,6 +25,8 @@ #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewEngineProvider.h" +@class FlutterEngineRegistrar; + NSString* const kFlutterPlatformChannel = @"flutter/platform"; NSString* const kFlutterSettingsChannel = @"flutter/settings"; NSString* const kFlutterLifecycleChannel = @"flutter/lifecycle"; @@ -95,6 +97,12 @@ @interface FlutterEngine () */ @property(nonatomic, strong) NSPointerArray* pluginAppDelegates; +/** + * All registrars returned from registrarForPlugin: + */ +@property(nonatomic, readonly) + NSMutableDictionary* pluginRegistrars; + - (nullable FlutterViewController*)viewControllerForId:(FlutterViewId)viewId; /** @@ -274,12 +282,19 @@ @interface FlutterEngineRegistrar : NSObject - (instancetype)initWithPlugin:(nonnull NSString*)pluginKey flutterEngine:(nonnull FlutterEngine*)flutterEngine; -- (NSView*)viewForId:(FlutterViewId)viewId; +- (nullable NSView*)viewForId:(FlutterViewId)viewId; + +/** + * The value published by this plugin, or NSNull if nothing has been published. + * + * The unusual NSNull is for the documented behavior of valuePublishedByPlugin:. + */ +@property(nonatomic, readonly, nonnull) NSObject* publishedValue; @end @implementation FlutterEngineRegistrar { NSString* _pluginKey; - FlutterEngine* _flutterEngine; + __weak FlutterEngine* _flutterEngine; } @dynamic view; @@ -289,6 +304,7 @@ - (instancetype)initWithPlugin:(NSString*)pluginKey flutterEngine:(FlutterEngine if (self) { _pluginKey = [pluginKey copy]; _flutterEngine = flutterEngine; + _publishedValue = [NSNull null]; } return self; } @@ -340,6 +356,10 @@ - (void)registerViewFactory:(nonnull NSObject*)facto [[_flutterEngine platformViewController] registerViewFactory:factory withId:factoryId]; } +- (void)publish:(NSObject*)value { + _publishedValue = value; +} + - (NSString*)lookupKeyForAsset:(NSString*)asset { return [FlutterDartProject lookupKeyForAsset:asset]; } @@ -438,6 +458,7 @@ - (instancetype)initWithName:(NSString*)labelPrefix _messengerHandlers = [[NSMutableDictionary alloc] init]; _binaryMessenger = [[FlutterBinaryMessengerRelay alloc] initWithParent:self]; _pluginAppDelegates = [NSPointerArray weakObjectsPointerArray]; + _pluginRegistrars = [[NSMutableDictionary alloc] init]; _currentMessengerConnection = 1; _allowHeadlessExecution = allowHeadlessExecution; _semanticsEnabled = NO; @@ -494,6 +515,11 @@ - (void)dealloc { } } } + // Clear any published values, just in case a plugin has created a retain cycle with the + // registrar. + for (NSString* pluginName in _pluginRegistrars) { + [_pluginRegistrars[pluginName] publish:[NSNull null]]; + } @synchronized(_isResponseValid) { [_isResponseValid removeAllObjects]; [_isResponseValid addObject:@NO]; @@ -1334,7 +1360,18 @@ - (void)cleanUpConnection:(FlutterBinaryMessengerConnection)connection { #pragma mark - FlutterPluginRegistry - (id)registrarForPlugin:(NSString*)pluginName { - return [[FlutterEngineRegistrar alloc] initWithPlugin:pluginName flutterEngine:self]; + id registrar = self.pluginRegistrars[pluginName]; + if (!registrar) { + FlutterEngineRegistrar* registrarImpl = + [[FlutterEngineRegistrar alloc] initWithPlugin:pluginName flutterEngine:self]; + self.pluginRegistrars[pluginName] = registrarImpl; + registrar = registrarImpl; + } + return registrar; +} + +- (nullable NSObject*)valuePublishedByPlugin:(NSString*)pluginName { + return self.pluginRegistrars[pluginName].publishedValue; } #pragma mark - FlutterTextureRegistrar diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm index fee6cdefadb51..4aa073de93506 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm @@ -608,6 +608,56 @@ + (void)registerWithRegistrar:(id)registrar { EXPECT_EQ(weakEngine, nil); } +TEST_F(FlutterEngineTest, PublishedValueNilForUnknownPlugin) { + NSString* fixtures = @(flutter::testing::GetFixturesPath()); + FlutterDartProject* project = [[FlutterDartProject alloc] + initWithAssetsPath:fixtures + ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]]; + FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test" + project:project + allowHeadlessExecution:YES]; + + EXPECT_EQ([engine valuePublishedByPlugin:@"NoSuchPlugin"], nil); +} + +TEST_F(FlutterEngineTest, PublishedValueNSNullIfNoPublishedValue) { + NSString* fixtures = @(flutter::testing::GetFixturesPath()); + FlutterDartProject* project = [[FlutterDartProject alloc] + initWithAssetsPath:fixtures + ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]]; + FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test" + project:project + allowHeadlessExecution:YES]; + NSString* pluginName = @"MyPlugin"; + // Request the registarar to register the plugin as existing. + [engine registrarForPlugin:pluginName]; + + // The documented behavior is that a plugin that exists but hasn't published + // anything returns NSNull, rather than nil, as on iOS. + EXPECT_EQ([engine valuePublishedByPlugin:pluginName], [NSNull null]); +} + +TEST_F(FlutterEngineTest, PublishedValueReturnsLastPublished) { + NSString* fixtures = @(flutter::testing::GetFixturesPath()); + FlutterDartProject* project = [[FlutterDartProject alloc] + initWithAssetsPath:fixtures + ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]]; + FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test" + project:project + allowHeadlessExecution:YES]; + NSString* pluginName = @"MyPlugin"; + id registrar = [engine registrarForPlugin:pluginName]; + + NSString* firstValue = @"A published value"; + NSArray* secondValue = @[ @"A different published value" ]; + + [registrar publish:firstValue]; + EXPECT_EQ([engine valuePublishedByPlugin:pluginName], firstValue); + + [registrar publish:secondValue]; + EXPECT_EQ([engine valuePublishedByPlugin:pluginName], secondValue); +} + // If a channel overrides a previous channel with the same name, cleaning // the previous channel should not affect the new channel. // diff --git a/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm b/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm index c86403d1a1390..62d81dbaa43bd 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm @@ -903,6 +903,10 @@ - (void)viewDidReshape:(NSView*)view { return [_engine registrarForPlugin:pluginName]; } +- (NSObject*)valuePublishedByPlugin:(NSString*)pluginKey { + return [_engine valuePublishedByPlugin:pluginKey]; +} + #pragma mark - FlutterKeyboardViewDelegate - (void)sendKeyEvent:(const FlutterKeyEvent&)event From b91d1aafe506307134b85cb043def799757dc7c8 Mon Sep 17 00:00:00 2001 From: skia-flutter-autoroll Date: Wed, 6 Sep 2023 17:07:04 -0400 Subject: [PATCH 08/15] Roll Skia from a274609c442c to 0039caadd635 (2 revisions) (#45513) https://skia.googlesource.com/skia.git/+log/a274609c442c..0039caadd635 2023-09-06 johnstiles@google.com Remove injection of sk_FragCoord in golden output shaders. 2023-09-06 jamesgk@google.com [graphite] Use LCD blend logic from Ganesh If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/skia-flutter-autoroll Please CC armansito@google.com,brianosman@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Skia: https://bugs.chromium.org/p/skia/issues/entry To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md --- DEPS | 2 +- ci/licenses_golden/licenses_skia | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DEPS b/DEPS index 4de42ae7f38fd..91ed8de6e69e1 100644 --- a/DEPS +++ b/DEPS @@ -18,7 +18,7 @@ vars = { 'llvm_git': 'https://llvm.googlesource.com', # OCMock is for testing only so there is no google clone 'ocmock_git': 'https://github.com/erikdoe/ocmock.git', - 'skia_revision': 'a274609c442cacaf4e13b6a88ca4990b07b86133', + 'skia_revision': '0039caadd63538ea5e85b782d0f190775d5fd58f', # WARNING: DO NOT EDIT canvaskit_cipd_instance MANUALLY # See `lib/web_ui/README.md` for how to roll CanvasKit to a new version. diff --git a/ci/licenses_golden/licenses_skia b/ci/licenses_golden/licenses_skia index 5d95ea5defeb6..c32856c9bb50a 100644 --- a/ci/licenses_golden/licenses_skia +++ b/ci/licenses_golden/licenses_skia @@ -1,4 +1,4 @@ -Signature: 43237b600ca1059f6b20efcc90247ac8 +Signature: 4aa47856082884f7d54611b40f501be0 ==================================================================================================== LIBRARY: etc1 From 84c6f14ffc58aae4c08acbac4739fdf22f20b330 Mon Sep 17 00:00:00 2001 From: skia-flutter-autoroll Date: Wed, 6 Sep 2023 17:21:59 -0400 Subject: [PATCH 09/15] Roll Fuchsia Linux SDK from 8dgICHnG28wNHzoz3... to SCoDb2m_zQDLrMhwT... (#45514) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/fuchsia-linux-sdk-flutter-engine Please CC rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md --- DEPS | 2 +- ci/licenses_golden/licenses_fuchsia | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DEPS b/DEPS index 91ed8de6e69e1..5d608f86045b6 100644 --- a/DEPS +++ b/DEPS @@ -924,7 +924,7 @@ deps = { 'packages': [ { 'package': 'fuchsia/sdk/core/linux-amd64', - 'version': '8dgICHnG28wNHzoz33qFF_nQu52I3PVTfNbXzV6PWTQC' + 'version': 'SCoDb2m_zQDLrMhwTwp5WCNL_BjAwYCPHfEbuLUUIZgC' } ], 'condition': 'host_os == "linux" and not download_fuchsia_sdk', diff --git a/ci/licenses_golden/licenses_fuchsia b/ci/licenses_golden/licenses_fuchsia index fbffcba766086..732e8e526a2f0 100644 --- a/ci/licenses_golden/licenses_fuchsia +++ b/ci/licenses_golden/licenses_fuchsia @@ -1,4 +1,4 @@ -Signature: ba6463628187613a22cdde62a73696f0 +Signature: 5f6bfda83516701984a518888a4f8c38 ==================================================================================================== LIBRARY: fuchsia_sdk From 1f3cc35ba692fd88b2ed9857e226de4cdad2c531 Mon Sep 17 00:00:00 2001 From: skia-flutter-autoroll Date: Wed, 6 Sep 2023 17:51:33 -0400 Subject: [PATCH 10/15] Roll ANGLE from 00daa451320c to 60b56591dee5 (1 revision) (#45517) https://chromium.googlesource.com/angle/angle.git/+log/00daa451320c..60b56591dee5 2023-09-06 syoussefi@chromium.org Verify shader link correctness after looking up in program cache If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/angle-flutter-engine Please CC flutter-engine@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in ANGLE: http://anglebug.com/new To file a bug in Flutter Engine: https://github.com/flutter/flutter/issues/new To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md --- DEPS | 2 +- ci/licenses_golden/licenses_third_party | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DEPS b/DEPS index 5d608f86045b6..9459683f263d3 100644 --- a/DEPS +++ b/DEPS @@ -631,7 +631,7 @@ deps = { Var('swiftshader_git') + '/SwiftShader.git' + '@' + '5f9ed9b16931c7155171d31f75004f73f0a3abc8', 'src/third_party/angle': - Var('chromium_git') + '/angle/angle.git' + '@' + '00daa451320c3edf8dc8add9eb0f3cfcf2aca70d', + Var('chromium_git') + '/angle/angle.git' + '@' + '60b56591dee59bc0bc770577f43d90be4b18863c', 'src/third_party/vulkan_memory_allocator': Var('chromium_git') + '/external/github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator' + '@' + '7de5cc00de50e71a3aab22dea52fbb7ff4efceb6', diff --git a/ci/licenses_golden/licenses_third_party b/ci/licenses_golden/licenses_third_party index 8c1a1f1633e1c..692f495881bf7 100644 --- a/ci/licenses_golden/licenses_third_party +++ b/ci/licenses_golden/licenses_third_party @@ -1,4 +1,4 @@ -Signature: 3a1d9f7353c9a77bca16f1d2b42b35fa +Signature: 770aab7700bb355756e69020ee8592a3 ==================================================================================================== LIBRARY: angle From aa911807ed9d88b73aea5b1a84f3f20e3662f6f2 Mon Sep 17 00:00:00 2001 From: skia-flutter-autoroll Date: Wed, 6 Sep 2023 17:56:06 -0400 Subject: [PATCH 11/15] Roll Skia from 0039caadd635 to 9c9757c5d17d (1 revision) (#45516) https://skia.googlesource.com/skia.git/+log/0039caadd635..9c9757c5d17d 2023-09-06 bungeman@google.com [paragraph] Publicly depend on skia and skunicode If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/skia-flutter-autoroll Please CC armansito@google.com,brianosman@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Skia: https://bugs.chromium.org/p/skia/issues/entry To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index 9459683f263d3..1c2d481adcbad 100644 --- a/DEPS +++ b/DEPS @@ -18,7 +18,7 @@ vars = { 'llvm_git': 'https://llvm.googlesource.com', # OCMock is for testing only so there is no google clone 'ocmock_git': 'https://github.com/erikdoe/ocmock.git', - 'skia_revision': '0039caadd63538ea5e85b782d0f190775d5fd58f', + 'skia_revision': '9c9757c5d17d2e0a13461f7343116a530a7ca404', # WARNING: DO NOT EDIT canvaskit_cipd_instance MANUALLY # See `lib/web_ui/README.md` for how to roll CanvasKit to a new version. From ff2f710df4ed554477eceb9d24b9d1b69e9f12b4 Mon Sep 17 00:00:00 2001 From: skia-flutter-autoroll Date: Wed, 6 Sep 2023 18:45:57 -0400 Subject: [PATCH 12/15] Roll Skia from 9c9757c5d17d to 2b76d1113497 (2 revisions) (#45518) https://skia.googlesource.com/skia.git/+log/9c9757c5d17d..2b76d1113497 2023-09-06 nicolettep@google.com [graphite] Add VulkanRenderPass wrapper class 2023-09-06 herb@google.com Basic comparison for two segments on sweepline If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/skia-flutter-autoroll Please CC armansito@google.com,brianosman@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Skia: https://bugs.chromium.org/p/skia/issues/entry To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md --- DEPS | 2 +- ci/licenses_golden/licenses_skia | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/DEPS b/DEPS index 1c2d481adcbad..faf15a9deb80d 100644 --- a/DEPS +++ b/DEPS @@ -18,7 +18,7 @@ vars = { 'llvm_git': 'https://llvm.googlesource.com', # OCMock is for testing only so there is no google clone 'ocmock_git': 'https://github.com/erikdoe/ocmock.git', - 'skia_revision': '9c9757c5d17d2e0a13461f7343116a530a7ca404', + 'skia_revision': '2b76d1113497e51caa819efc29a4d0aa4c85b725', # WARNING: DO NOT EDIT canvaskit_cipd_instance MANUALLY # See `lib/web_ui/README.md` for how to roll CanvasKit to a new version. diff --git a/ci/licenses_golden/licenses_skia b/ci/licenses_golden/licenses_skia index c32856c9bb50a..d3adc606d42c2 100644 --- a/ci/licenses_golden/licenses_skia +++ b/ci/licenses_golden/licenses_skia @@ -1,4 +1,4 @@ -Signature: 4aa47856082884f7d54611b40f501be0 +Signature: 1c29498dd42162a6e735496b20bf7bfc ==================================================================================================== LIBRARY: etc1 @@ -8978,6 +8978,8 @@ ORIGIN: ../../../third_party/skia/src/gpu/graphite/vk/VulkanDescriptorSet.cpp + ORIGIN: ../../../third_party/skia/src/gpu/graphite/vk/VulkanDescriptorSet.h + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/src/gpu/graphite/vk/VulkanGraphicsPipeline.cpp + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/src/gpu/graphite/vk/VulkanGraphicsPipeline.h + ../../../third_party/skia/LICENSE +ORIGIN: ../../../third_party/skia/src/gpu/graphite/vk/VulkanRenderPass.cpp + ../../../third_party/skia/LICENSE +ORIGIN: ../../../third_party/skia/src/gpu/graphite/vk/VulkanRenderPass.h + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/src/gpu/graphite/vk/VulkanSampler.cpp + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/src/gpu/graphite/vk/VulkanSampler.h + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/src/image/SkImageGeneratorPriv.h + ../../../third_party/skia/LICENSE @@ -9235,6 +9237,8 @@ FILE: ../../../third_party/skia/src/gpu/graphite/vk/VulkanDescriptorSet.cpp FILE: ../../../third_party/skia/src/gpu/graphite/vk/VulkanDescriptorSet.h FILE: ../../../third_party/skia/src/gpu/graphite/vk/VulkanGraphicsPipeline.cpp FILE: ../../../third_party/skia/src/gpu/graphite/vk/VulkanGraphicsPipeline.h +FILE: ../../../third_party/skia/src/gpu/graphite/vk/VulkanRenderPass.cpp +FILE: ../../../third_party/skia/src/gpu/graphite/vk/VulkanRenderPass.h FILE: ../../../third_party/skia/src/gpu/graphite/vk/VulkanSampler.cpp FILE: ../../../third_party/skia/src/gpu/graphite/vk/VulkanSampler.h FILE: ../../../third_party/skia/src/image/SkImageGeneratorPriv.h From 02ea040b54df145816d28b1a519a0b6e48edc02d Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Wed, 6 Sep 2023 17:42:13 -0700 Subject: [PATCH 13/15] [Impeller] Gaussian blur: Remove the current blur style implementation. (#45520) Resolves https://github.com/flutter/flutter/issues/122658. Resolves remaining blur issues visible in: https://github.com/flutter/flutter/issues/132839 The current blur style implementation hasn't been working since we added the downscaling optimization, and it will continue not working after we switch to https://github.com/flutter/flutter/issues/131580. In it's current state, it at best causes awful looking undesirable results that users are forced to work around anyhow. We should just remove it in the meantime. Before: ![image](https://github.com/flutter/engine/assets/919017/fee57875-bd56-4a97-b8c7-353328935298) After: ![image](https://github.com/flutter/engine/assets/919017/03d6a6dd-3789-4629-bae2-61cf6f5bb054) --- ci/licenses_golden/licenses_flutter | 4 - impeller/entity/BUILD.gn | 2 - impeller/entity/contents/content_context.cc | 4 - impeller/entity/contents/content_context.h | 22 - .../contents/filters/filter_contents.cc | 8 +- .../entity/contents/filters/filter_contents.h | 2 +- .../filters/gaussian_blur_filter_contents.cc | 100 +---- .../filters/gaussian_blur_filter_contents.h | 7 +- .../shaders/gaussian_blur/gaussian_blur.glsl | 26 -- .../gaussian_blur_alpha_decal.frag | 10 - .../gaussian_blur_alpha_nodecal.frag | 10 - .../gaussian_blur_noalpha_decal.frag | 1 - .../gaussian_blur_noalpha_nodecal.frag | 1 - impeller/tools/malioc.json | 380 ------------------ 14 files changed, 24 insertions(+), 553 deletions(-) delete mode 100644 impeller/entity/shaders/gaussian_blur/gaussian_blur_alpha_decal.frag delete mode 100644 impeller/entity/shaders/gaussian_blur/gaussian_blur_alpha_nodecal.frag diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index b14618b5e2e92..3af68bf8a344d 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -1329,8 +1329,6 @@ ORIGIN: ../../../flutter/impeller/entity/shaders/debug/checkerboard.frag + ../.. ORIGIN: ../../../flutter/impeller/entity/shaders/debug/checkerboard.vert + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur.glsl + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur.vert + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur_alpha_decal.frag + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur_alpha_nodecal.frag + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_decal.frag + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_nodecal.frag + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/entity/shaders/geometry/points.comp + ../../../flutter/LICENSE @@ -4075,8 +4073,6 @@ FILE: ../../../flutter/impeller/entity/shaders/debug/checkerboard.frag FILE: ../../../flutter/impeller/entity/shaders/debug/checkerboard.vert FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur.glsl FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur.vert -FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur_alpha_decal.frag -FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur_alpha_nodecal.frag FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_decal.frag FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_nodecal.frag FILE: ../../../flutter/impeller/entity/shaders/geometry/points.comp diff --git a/impeller/entity/BUILD.gn b/impeller/entity/BUILD.gn index e4c76f9c9ffec..cf26434a97fb2 100644 --- a/impeller/entity/BUILD.gn +++ b/impeller/entity/BUILD.gn @@ -40,8 +40,6 @@ impeller_shaders("entity_shaders") { "shaders/color_matrix_color_filter.vert", "shaders/conical_gradient_fill.frag", "shaders/gaussian_blur/gaussian_blur.vert", - "shaders/gaussian_blur/gaussian_blur_alpha_decal.frag", - "shaders/gaussian_blur/gaussian_blur_alpha_nodecal.frag", "shaders/gaussian_blur/gaussian_blur_noalpha_decal.frag", "shaders/gaussian_blur/gaussian_blur_noalpha_nodecal.frag", "shaders/glyph_atlas.frag", diff --git a/impeller/entity/contents/content_context.cc b/impeller/entity/contents/content_context.cc index 010caac049458..65ef43e095403 100644 --- a/impeller/entity/contents/content_context.cc +++ b/impeller/entity/contents/content_context.cc @@ -282,10 +282,6 @@ ContentContext::ContentContext( CreateDefaultPipeline(*context_); tiled_texture_pipelines_[default_options_] = CreateDefaultPipeline(*context_); - gaussian_blur_alpha_decal_pipelines_[default_options_] = - CreateDefaultPipeline(*context_); - gaussian_blur_alpha_nodecal_pipelines_[default_options_] = - CreateDefaultPipeline(*context_); gaussian_blur_noalpha_decal_pipelines_[default_options_] = CreateDefaultPipeline(*context_); gaussian_blur_noalpha_nodecal_pipelines_[default_options_] = diff --git a/impeller/entity/contents/content_context.h b/impeller/entity/contents/content_context.h index c7ba78dfd7981..3c72798623758 100644 --- a/impeller/entity/contents/content_context.h +++ b/impeller/entity/contents/content_context.h @@ -63,8 +63,6 @@ #include "impeller/entity/yuv_to_rgb_filter.vert.h" #include "impeller/entity/gaussian_blur.vert.h" -#include "impeller/entity/gaussian_blur_alpha_decal.frag.h" -#include "impeller/entity/gaussian_blur_alpha_nodecal.frag.h" #include "impeller/entity/gaussian_blur_noalpha_decal.frag.h" #include "impeller/entity/gaussian_blur_noalpha_nodecal.frag.h" @@ -158,12 +156,6 @@ using PositionUVPipeline = RenderPipelineT; using TiledTexturePipeline = RenderPipelineT; -using GaussianBlurAlphaDecalPipeline = - RenderPipelineT; -using GaussianBlurAlphaPipeline = - RenderPipelineT; using GaussianBlurDecalPipeline = RenderPipelineT; @@ -453,16 +445,6 @@ class ContentContext { return GetPipeline(tiled_texture_pipelines_, opts); } - std::shared_ptr> - GetGaussianBlurAlphaDecalPipeline(ContentContextOptions opts) const { - return GetPipeline(gaussian_blur_alpha_decal_pipelines_, opts); - } - - std::shared_ptr> GetGaussianBlurAlphaPipeline( - ContentContextOptions opts) const { - return GetPipeline(gaussian_blur_alpha_nodecal_pipelines_, opts); - } - std::shared_ptr> GetGaussianBlurDecalPipeline( ContentContextOptions opts) const { return GetPipeline(gaussian_blur_noalpha_decal_pipelines_, opts); @@ -772,10 +754,6 @@ class ContentContext { #endif // IMPELLER_ENABLE_OPENGLES mutable Variants position_uv_pipelines_; mutable Variants tiled_texture_pipelines_; - mutable Variants - gaussian_blur_alpha_decal_pipelines_; - mutable Variants - gaussian_blur_alpha_nodecal_pipelines_; mutable Variants gaussian_blur_noalpha_decal_pipelines_; mutable Variants diff --git a/impeller/entity/contents/filters/filter_contents.cc b/impeller/entity/contents/filters/filter_contents.cc index 91ef1f0aaffc8..02ba98f022439 100644 --- a/impeller/entity/contents/filters/filter_contents.cc +++ b/impeller/entity/contents/filters/filter_contents.cc @@ -36,7 +36,7 @@ std::shared_ptr FilterContents::MakeDirectionalGaussianBlur( Vector2 direction, BlurStyle blur_style, Entity::TileMode tile_mode, - FilterInput::Ref source_override, + bool is_second_pass, Sigma secondary_sigma, const Matrix& effect_transform) { auto blur = std::make_shared(); @@ -45,7 +45,7 @@ std::shared_ptr FilterContents::MakeDirectionalGaussianBlur( blur->SetDirection(direction); blur->SetBlurStyle(blur_style); blur->SetTileMode(tile_mode); - blur->SetSourceOverride(std::move(source_override)); + blur->SetIsSecondPass(is_second_pass); blur->SetSecondarySigma(secondary_sigma); blur->SetEffectTransform(effect_transform); return blur; @@ -60,10 +60,10 @@ std::shared_ptr FilterContents::MakeGaussianBlur( const Matrix& effect_transform) { auto x_blur = MakeDirectionalGaussianBlur(input, sigma_x, Point(1, 0), BlurStyle::kNormal, tile_mode, - nullptr, {}, effect_transform); + false, {}, effect_transform); auto y_blur = MakeDirectionalGaussianBlur(FilterInput::Make(x_blur), sigma_y, Point(0, 1), blur_style, tile_mode, - input, sigma_x, effect_transform); + true, sigma_x, effect_transform); return y_blur; } diff --git a/impeller/entity/contents/filters/filter_contents.h b/impeller/entity/contents/filters/filter_contents.h index 739f6531207a6..35d135ab9da23 100644 --- a/impeller/entity/contents/filters/filter_contents.h +++ b/impeller/entity/contents/filters/filter_contents.h @@ -37,7 +37,7 @@ class FilterContents : public Contents { Vector2 direction, BlurStyle blur_style = BlurStyle::kNormal, Entity::TileMode tile_mode = Entity::TileMode::kDecal, - FilterInput::Ref alpha_mask = nullptr, + bool is_second_pass = false, Sigma secondary_sigma = {}, const Matrix& effect_transform = Matrix()); diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc index 16552f0f8fdc3..8e3c9569305bf 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc @@ -46,29 +46,6 @@ void DirectionalGaussianBlurFilterContents::SetDirection(Vector2 direction) { void DirectionalGaussianBlurFilterContents::SetBlurStyle(BlurStyle blur_style) { blur_style_ = blur_style; - - switch (blur_style) { - case FilterContents::BlurStyle::kNormal: - src_color_factor_ = false; - inner_blur_factor_ = true; - outer_blur_factor_ = true; - break; - case FilterContents::BlurStyle::kSolid: - src_color_factor_ = true; - inner_blur_factor_ = false; - outer_blur_factor_ = true; - break; - case FilterContents::BlurStyle::kOuter: - src_color_factor_ = false; - inner_blur_factor_ = false; - outer_blur_factor_ = true; - break; - case FilterContents::BlurStyle::kInner: - src_color_factor_ = false; - inner_blur_factor_ = true; - outer_blur_factor_ = false; - break; - } } void DirectionalGaussianBlurFilterContents::SetTileMode( @@ -76,9 +53,9 @@ void DirectionalGaussianBlurFilterContents::SetTileMode( tile_mode_ = tile_mode; } -void DirectionalGaussianBlurFilterContents::SetSourceOverride( - FilterInput::Ref source_override) { - source_override_ = std::move(source_override); +void DirectionalGaussianBlurFilterContents::SetIsSecondPass( + bool is_second_pass) { + is_second_pass_ = is_second_pass; } std::optional DirectionalGaussianBlurFilterContents::RenderFilter( @@ -88,10 +65,8 @@ std::optional DirectionalGaussianBlurFilterContents::RenderFilter( const Matrix& effect_transform, const Rect& coverage, const std::optional& coverage_hint) const { - using VS = GaussianBlurAlphaDecalPipeline::VertexShader; - using FS = GaussianBlurAlphaDecalPipeline::FragmentShader; - - bool is_first_pass = !source_override_; + using VS = GaussianBlurPipeline::VertexShader; + using FS = GaussianBlurPipeline::FragmentShader; //---------------------------------------------------------------------------- /// Handle inputs. @@ -118,9 +93,9 @@ std::optional DirectionalGaussianBlurFilterContents::RenderFilter( Size(transformed_blur_radius_length, transformed_blur_radius_length) .Abs(); expanded_coverage_hint = - is_first_pass ? Rect(coverage_hint.value().origin - r, - Size(coverage_hint.value().size + r * 2)) - : coverage_hint; + is_second_pass_ ? coverage_hint + : Rect(coverage_hint.value().origin - r, + Size(coverage_hint.value().size + r * 2)); } auto input_snapshot = inputs[0]->GetSnapshot("GaussianBlur", renderer, entity, expanded_coverage_hint); @@ -160,15 +135,6 @@ std::optional DirectionalGaussianBlurFilterContents::RenderFilter( pass_texture_rect.origin.x -= transformed_blur_radius_length; pass_texture_rect.size.width += transformed_blur_radius_length * 2; - // Source override snapshot. - - auto source = source_override_ ? source_override_ : inputs[0]; - auto source_snapshot = source->GetSnapshot("GaussianBlur(Override)", renderer, - entity, GetCoverageHint()); - if (!source_snapshot.has_value()) { - return std::nullopt; - } - // UV mapping. auto pass_uv_project = [&texture_rotate, @@ -180,8 +146,6 @@ std::optional DirectionalGaussianBlurFilterContents::RenderFilter( auto input_uvs = pass_uv_project(input_snapshot.value()); - auto source_uvs = pass_uv_project(source_snapshot.value()); - //---------------------------------------------------------------------------- /// Render to texture. /// @@ -193,12 +157,12 @@ std::optional DirectionalGaussianBlurFilterContents::RenderFilter( VertexBufferBuilder vtx_builder; vtx_builder.AddVertices({ - {Point(0, 0), input_uvs[0], source_uvs[0]}, - {Point(1, 0), input_uvs[1], source_uvs[1]}, - {Point(1, 1), input_uvs[3], source_uvs[3]}, - {Point(0, 0), input_uvs[0], source_uvs[0]}, - {Point(1, 1), input_uvs[3], source_uvs[3]}, - {Point(0, 1), input_uvs[2], source_uvs[2]}, + {Point(0, 0), input_uvs[0]}, + {Point(1, 0), input_uvs[1]}, + {Point(1, 1), input_uvs[3]}, + {Point(0, 0), input_uvs[0]}, + {Point(1, 1), input_uvs[3]}, + {Point(0, 1), input_uvs[2]}, }); auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer); @@ -206,8 +170,6 @@ std::optional DirectionalGaussianBlurFilterContents::RenderFilter( frame_info.mvp = Matrix::MakeOrthographic(ISize(1, 1)); frame_info.texture_sampler_y_coord_scale = input_snapshot->texture->GetYCoordScale(); - frame_info.alpha_mask_sampler_y_coord_scale = - source_snapshot->texture->GetYCoordScale(); FS::BlurInfo frag_info; auto r = Radius{transformed_blur_radius_length}; @@ -227,50 +189,35 @@ std::optional DirectionalGaussianBlurFilterContents::RenderFilter( auto options = OptionsFromPass(pass); options.blend_mode = BlendMode::kSource; auto input_descriptor = input_snapshot->sampler_descriptor; - auto source_descriptor = source_snapshot->sampler_descriptor; switch (tile_mode_) { case Entity::TileMode::kDecal: if (renderer.GetDeviceCapabilities() .SupportsDecalSamplerAddressMode()) { input_descriptor.width_address_mode = SamplerAddressMode::kDecal; input_descriptor.height_address_mode = SamplerAddressMode::kDecal; - source_descriptor.width_address_mode = SamplerAddressMode::kDecal; - source_descriptor.height_address_mode = SamplerAddressMode::kDecal; } break; case Entity::TileMode::kClamp: input_descriptor.width_address_mode = SamplerAddressMode::kClampToEdge; input_descriptor.height_address_mode = SamplerAddressMode::kClampToEdge; - source_descriptor.width_address_mode = SamplerAddressMode::kClampToEdge; - source_descriptor.height_address_mode = - SamplerAddressMode::kClampToEdge; break; case Entity::TileMode::kMirror: input_descriptor.width_address_mode = SamplerAddressMode::kMirror; input_descriptor.height_address_mode = SamplerAddressMode::kMirror; - source_descriptor.width_address_mode = SamplerAddressMode::kMirror; - source_descriptor.height_address_mode = SamplerAddressMode::kMirror; break; case Entity::TileMode::kRepeat: input_descriptor.width_address_mode = SamplerAddressMode::kRepeat; input_descriptor.height_address_mode = SamplerAddressMode::kRepeat; - source_descriptor.width_address_mode = SamplerAddressMode::kRepeat; - source_descriptor.height_address_mode = SamplerAddressMode::kRepeat; break; } input_descriptor.mag_filter = MinMagFilter::kLinear; input_descriptor.min_filter = MinMagFilter::kLinear; - bool has_alpha_mask = blur_style_ != BlurStyle::kNormal; bool has_decal_specialization = tile_mode_ == Entity::TileMode::kDecal && !renderer.GetDeviceCapabilities().SupportsDecalSamplerAddressMode(); - if (has_alpha_mask && has_decal_specialization) { - cmd.pipeline = renderer.GetGaussianBlurAlphaDecalPipeline(options); - } else if (has_alpha_mask) { - cmd.pipeline = renderer.GetGaussianBlurAlphaPipeline(options); - } else if (has_decal_specialization) { + if (has_decal_specialization) { cmd.pipeline = renderer.GetGaussianBlurDecalPipeline(options); } else { cmd.pipeline = renderer.GetGaussianBlurPipeline(options); @@ -283,19 +230,6 @@ std::optional DirectionalGaussianBlurFilterContents::RenderFilter( VS::BindFrameInfo(cmd, host_buffer.EmplaceUniform(frame_info)); FS::BindBlurInfo(cmd, host_buffer.EmplaceUniform(frag_info)); - if (has_alpha_mask) { - FS::MaskInfo mask_info; - mask_info.src_factor = src_color_factor_; - mask_info.inner_blur_factor = inner_blur_factor_; - mask_info.outer_blur_factor = outer_blur_factor_; - - FS::BindAlphaMaskSampler( - cmd, source_snapshot->texture, - renderer.GetContext()->GetSamplerLibrary()->GetSampler( - source_descriptor)); - FS::BindMaskInfo(cmd, host_buffer.EmplaceUniform(mask_info)); - } - return pass.AddCommand(std::move(cmd)); }; @@ -310,8 +244,8 @@ std::optional DirectionalGaussianBlurFilterContents::RenderFilter( { scale.x = scale_curve(transformed_blur_radius_length); - Scalar y_radius = std::abs(pass_transform.GetDirectionScale( - Vector2(0, !is_first_pass ? Radius{secondary_blur_sigma_}.radius : 1))); + Scalar y_radius = std::abs(pass_transform.GetDirectionScale(Vector2( + 0, !is_second_pass_ ? 1 : Radius{secondary_blur_sigma_}.radius))); scale.y = scale_curve(y_radius); } diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.h b/impeller/entity/contents/filters/gaussian_blur_filter_contents.h index 1f4ef1f450605..f65ad914cfb4c 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.h +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.h @@ -27,7 +27,7 @@ class DirectionalGaussianBlurFilterContents final : public FilterContents { void SetTileMode(Entity::TileMode tile_mode); - void SetSourceOverride(FilterInput::Ref alpha_mask); + void SetIsSecondPass(bool is_second_pass); // |FilterContents| std::optional GetFilterCoverage( @@ -49,10 +49,7 @@ class DirectionalGaussianBlurFilterContents final : public FilterContents { Vector2 blur_direction_; BlurStyle blur_style_ = BlurStyle::kNormal; Entity::TileMode tile_mode_ = Entity::TileMode::kDecal; - bool src_color_factor_ = false; - bool inner_blur_factor_ = true; - bool outer_blur_factor_ = true; - FilterInput::Ref source_override_; + bool is_second_pass_ = false; FML_DISALLOW_COPY_AND_ASSIGN(DirectionalGaussianBlurFilterContents); }; diff --git a/impeller/entity/shaders/gaussian_blur/gaussian_blur.glsl b/impeller/entity/shaders/gaussian_blur/gaussian_blur.glsl index 61724020d4445..d18bf6c3d1ae7 100644 --- a/impeller/entity/shaders/gaussian_blur/gaussian_blur.glsl +++ b/impeller/entity/shaders/gaussian_blur/gaussian_blur.glsl @@ -32,17 +32,6 @@ uniform BlurInfo { } blur_info; -#if ENABLE_ALPHA_MASK -uniform f16sampler2D alpha_mask_sampler; - -uniform MaskInfo { - float16_t src_factor; - float16_t inner_blur_factor; - float16_t outer_blur_factor; -} -mask_info; -#endif - f16vec4 Sample(f16sampler2D tex, vec2 coords) { #if ENABLE_DECAL_SPECIALIZATION return IPHalfSampleDecal(tex, coords); @@ -76,19 +65,4 @@ void main() { } frag_color = total_color / gaussian_integral; - -#if ENABLE_ALPHA_MASK - f16vec4 src_color = Sample(alpha_mask_sampler, // sampler - v_src_texture_coords // texture coordinates - ); - - float16_t blur_factor; - if (src_color.a > 0.0hf) { - blur_factor = mask_info.inner_blur_factor; - } else if (src_color.a == 0.0hf) { - blur_factor = mask_info.outer_blur_factor; - } - - frag_color = frag_color * blur_factor + src_color * mask_info.src_factor; -#endif } diff --git a/impeller/entity/shaders/gaussian_blur/gaussian_blur_alpha_decal.frag b/impeller/entity/shaders/gaussian_blur/gaussian_blur_alpha_decal.frag deleted file mode 100644 index 265b1b972875c..0000000000000 --- a/impeller/entity/shaders/gaussian_blur/gaussian_blur_alpha_decal.frag +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -precision mediump float; - -#define ENABLE_ALPHA_MASK 1 -#define ENABLE_DECAL_SPECIALIZATION 1 - -#include "gaussian_blur.glsl" diff --git a/impeller/entity/shaders/gaussian_blur/gaussian_blur_alpha_nodecal.frag b/impeller/entity/shaders/gaussian_blur/gaussian_blur_alpha_nodecal.frag deleted file mode 100644 index 0d955ce49ab5c..0000000000000 --- a/impeller/entity/shaders/gaussian_blur/gaussian_blur_alpha_nodecal.frag +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -precision mediump float; - -#define ENABLE_ALPHA_MASK 1 -#define ENABLE_DECAL_SPECIALIZATION 0 - -#include "gaussian_blur.glsl" diff --git a/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_decal.frag b/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_decal.frag index 9d70d09a228f8..7bb1045e19dbc 100644 --- a/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_decal.frag +++ b/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_decal.frag @@ -4,7 +4,6 @@ precision mediump float; -#define ENABLE_ALPHA_MASK 0 #define ENABLE_DECAL_SPECIALIZATION 1 #include "gaussian_blur.glsl" diff --git a/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_nodecal.frag b/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_nodecal.frag index aa1943c0d5456..79d708e1dae36 100644 --- a/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_nodecal.frag +++ b/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_nodecal.frag @@ -4,7 +4,6 @@ precision mediump float; -#define ENABLE_ALPHA_MASK 0 #define ENABLE_DECAL_SPECIALIZATION 0 #include "gaussian_blur.glsl" diff --git a/impeller/tools/malioc.json b/impeller/tools/malioc.json index 3fa01c48f9fbb..4be55a58d025a 100644 --- a/impeller/tools/malioc.json +++ b/impeller/tools/malioc.json @@ -3495,150 +3495,6 @@ } } }, - "flutter/impeller/entity/gaussian_blur_alpha_decal.frag.vkspv": { - "Mali-G78": { - "core": "Mali-G78", - "filename": "flutter/impeller/entity/gaussian_blur_alpha_decal.frag.vkspv", - "has_side_effects": false, - "has_uniform_computation": true, - "modifies_coverage": false, - "reads_color_buffer": false, - "type": "Fragment", - "uses_late_zs_test": false, - "uses_late_zs_update": false, - "variants": { - "Main": { - "fp16_arithmetic": 53, - "has_stack_spilling": false, - "performance": { - "longest_path_bound_pipelines": [ - null - ], - "longest_path_cycles": [ - null, - null, - null, - null, - null, - null, - null - ], - "pipelines": [ - "arith_total", - "arith_fma", - "arith_cvt", - "arith_sfu", - "load_store", - "varying", - "texture" - ], - "shortest_path_bound_pipelines": [ - "arith_total", - "arith_cvt" - ], - "shortest_path_cycles": [ - 0.328125, - 0.078125, - 0.328125, - 0.25, - 0.0, - 0.25, - 0.0 - ], - "total_bound_pipelines": [ - "arith_total", - "arith_cvt" - ], - "total_cycles": [ - 0.609375, - 0.25, - 0.609375, - 0.5, - 0.0, - 0.5, - 0.5 - ] - }, - "stack_spill_bytes": 0, - "thread_occupancy": 100, - "uniform_registers_used": 12, - "work_registers_used": 21 - } - } - } - }, - "flutter/impeller/entity/gaussian_blur_alpha_nodecal.frag.vkspv": { - "Mali-G78": { - "core": "Mali-G78", - "filename": "flutter/impeller/entity/gaussian_blur_alpha_nodecal.frag.vkspv", - "has_side_effects": false, - "has_uniform_computation": true, - "modifies_coverage": false, - "reads_color_buffer": false, - "type": "Fragment", - "uses_late_zs_test": false, - "uses_late_zs_update": false, - "variants": { - "Main": { - "fp16_arithmetic": 45, - "has_stack_spilling": false, - "performance": { - "longest_path_bound_pipelines": [ - null - ], - "longest_path_cycles": [ - null, - null, - null, - null, - null, - null, - null - ], - "pipelines": [ - "arith_total", - "arith_fma", - "arith_cvt", - "arith_sfu", - "load_store", - "varying", - "texture" - ], - "shortest_path_bound_pipelines": [ - "varying", - "texture" - ], - "shortest_path_cycles": [ - 0.1875, - 0.078125, - 0.1875, - 0.0625, - 0.0, - 0.25, - 0.25 - ], - "total_bound_pipelines": [ - "varying", - "texture" - ], - "total_cycles": [ - 0.34375, - 0.25, - 0.34375, - 0.125, - 0.0, - 0.5, - 0.5 - ] - }, - "stack_spill_bytes": 0, - "thread_occupancy": 100, - "uniform_registers_used": 14, - "work_registers_used": 14 - } - } - } - }, "flutter/impeller/entity/gaussian_blur_noalpha_decal.frag.vkspv": { "Mali-G78": { "core": "Mali-G78", @@ -7263,242 +7119,6 @@ } } }, - "flutter/impeller/entity/gles/gaussian_blur_alpha_decal.frag.gles": { - "Mali-G78": { - "core": "Mali-G78", - "filename": "flutter/impeller/entity/gles/gaussian_blur_alpha_decal.frag.gles", - "has_side_effects": false, - "has_uniform_computation": true, - "modifies_coverage": false, - "reads_color_buffer": false, - "type": "Fragment", - "uses_late_zs_test": false, - "uses_late_zs_update": false, - "variants": { - "Main": { - "fp16_arithmetic": 66, - "has_stack_spilling": false, - "performance": { - "longest_path_bound_pipelines": [ - null - ], - "longest_path_cycles": [ - null, - null, - null, - null, - null, - null, - null - ], - "pipelines": [ - "arith_total", - "arith_fma", - "arith_cvt", - "arith_sfu", - "load_store", - "varying", - "texture" - ], - "shortest_path_bound_pipelines": [ - "arith_total", - "arith_cvt", - "arith_sfu", - "varying" - ], - "shortest_path_cycles": [ - 0.25, - 0.125, - 0.25, - 0.25, - 0.0, - 0.25, - 0.0 - ], - "total_bound_pipelines": [ - "arith_total", - "arith_cvt" - ], - "total_cycles": [ - 0.5625, - 0.328125, - 0.5625, - 0.5, - 0.0, - 0.5, - 0.5 - ] - }, - "stack_spill_bytes": 0, - "thread_occupancy": 100, - "uniform_registers_used": 12, - "work_registers_used": 22 - } - } - }, - "Mali-T880": { - "core": "Mali-T880", - "filename": "flutter/impeller/entity/gles/gaussian_blur_alpha_decal.frag.gles", - "has_uniform_computation": false, - "type": "Fragment", - "variants": { - "Main": { - "has_stack_spilling": false, - "performance": { - "longest_path_bound_pipelines": [ - null - ], - "longest_path_cycles": [ - null, - null, - null - ], - "pipelines": [ - "arithmetic", - "load_store", - "texture" - ], - "shortest_path_bound_pipelines": [ - "arithmetic" - ], - "shortest_path_cycles": [ - 3.299999952316284, - 2.0, - 0.0 - ], - "total_bound_pipelines": [ - "arithmetic" - ], - "total_cycles": [ - 7.666666507720947, - 2.0, - 2.0 - ] - }, - "thread_occupancy": 100, - "uniform_registers_used": 1, - "work_registers_used": 4 - } - } - } - }, - "flutter/impeller/entity/gles/gaussian_blur_alpha_nodecal.frag.gles": { - "Mali-G78": { - "core": "Mali-G78", - "filename": "flutter/impeller/entity/gles/gaussian_blur_alpha_nodecal.frag.gles", - "has_side_effects": false, - "has_uniform_computation": true, - "modifies_coverage": false, - "reads_color_buffer": false, - "type": "Fragment", - "uses_late_zs_test": false, - "uses_late_zs_update": false, - "variants": { - "Main": { - "fp16_arithmetic": 61, - "has_stack_spilling": false, - "performance": { - "longest_path_bound_pipelines": [ - null - ], - "longest_path_cycles": [ - null, - null, - null, - null, - null, - null, - null - ], - "pipelines": [ - "arith_total", - "arith_fma", - "arith_cvt", - "arith_sfu", - "load_store", - "varying", - "texture" - ], - "shortest_path_bound_pipelines": [ - "varying", - "texture" - ], - "shortest_path_cycles": [ - 0.140625, - 0.125, - 0.140625, - 0.0625, - 0.0, - 0.25, - 0.25 - ], - "total_bound_pipelines": [ - "varying", - "texture" - ], - "total_cycles": [ - 0.328125, - 0.328125, - 0.328125, - 0.125, - 0.0, - 0.5, - 0.5 - ] - }, - "stack_spill_bytes": 0, - "thread_occupancy": 100, - "uniform_registers_used": 12, - "work_registers_used": 20 - } - } - }, - "Mali-T880": { - "core": "Mali-T880", - "filename": "flutter/impeller/entity/gles/gaussian_blur_alpha_nodecal.frag.gles", - "has_uniform_computation": false, - "type": "Fragment", - "variants": { - "Main": { - "has_stack_spilling": false, - "performance": { - "longest_path_bound_pipelines": [ - null - ], - "longest_path_cycles": [ - null, - null, - null - ], - "pipelines": [ - "arithmetic", - "load_store", - "texture" - ], - "shortest_path_bound_pipelines": [ - "arithmetic" - ], - "shortest_path_cycles": [ - 2.309999942779541, - 2.0, - 1.0 - ], - "total_bound_pipelines": [ - "arithmetic" - ], - "total_cycles": [ - 5.0, - 2.0, - 2.0 - ] - }, - "thread_occupancy": 100, - "uniform_registers_used": 1, - "work_registers_used": 3 - } - } - } - }, "flutter/impeller/entity/gles/gaussian_blur_noalpha_decal.frag.gles": { "Mali-G78": { "core": "Mali-G78", From 8623b886ee955287dadfd6485ada80f6153fe33c Mon Sep 17 00:00:00 2001 From: skia-flutter-autoroll Date: Wed, 6 Sep 2023 20:52:20 -0400 Subject: [PATCH 14/15] Roll Skia from 2b76d1113497 to 9e86d3f6239a (1 revision) (#45521) https://skia.googlesource.com/skia.git/+log/2b76d1113497..9e86d3f6239a 2023-09-07 skia-autoroll@skia-public.iam.gserviceaccount.com Roll vulkan-deps from fcc5a5e242db to 207e6df72c04 (7 revisions) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/skia-flutter-autoroll Please CC armansito@google.com,brianosman@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Skia: https://bugs.chromium.org/p/skia/issues/entry To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index faf15a9deb80d..56321bbc15780 100644 --- a/DEPS +++ b/DEPS @@ -18,7 +18,7 @@ vars = { 'llvm_git': 'https://llvm.googlesource.com', # OCMock is for testing only so there is no google clone 'ocmock_git': 'https://github.com/erikdoe/ocmock.git', - 'skia_revision': '2b76d1113497e51caa819efc29a4d0aa4c85b725', + 'skia_revision': '9e86d3f6239a9f523d164ed5cae7ebbd2ea05aa5', # WARNING: DO NOT EDIT canvaskit_cipd_instance MANUALLY # See `lib/web_ui/README.md` for how to roll CanvasKit to a new version. From 75437a3bd0025e833c33498b8e0c5013b213f726 Mon Sep 17 00:00:00 2001 From: Zachary Anderson Date: Wed, 6 Sep 2023 18:35:09 -0700 Subject: [PATCH 15/15] Revert "Enforce the rule of calling `FlutterView.Render`" (#45525) Reverts flutter/engine#45300 Speculative revert for the post-submit framework CI failure in `windows_startup_test`: https://ci.chromium.org/ui/p/flutter/builders/prod/Windows%20windows_startup_test/6227/overview --- lib/ui/fixtures/ui_test.dart | 42 --- lib/ui/platform_dispatcher.dart | 33 --- lib/ui/window.dart | 9 +- .../platform_configuration_unittests.cc | 240 ------------------ shell/common/shell.cc | 31 +-- shell/common/shell.h | 10 - 6 files changed, 14 insertions(+), 351 deletions(-) diff --git a/lib/ui/fixtures/ui_test.dart b/lib/ui/fixtures/ui_test.dart index 3cc93a746921a..0aff1775688b7 100644 --- a/lib/ui/fixtures/ui_test.dart +++ b/lib/ui/fixtures/ui_test.dart @@ -1076,45 +1076,3 @@ external void _callHook( Object? arg20, Object? arg21, ]); - -Scene _createRedBoxScene(Size size) { - final SceneBuilder builder = SceneBuilder(); - builder.pushOffset(0.0, 0.0); - final Paint paint = Paint() - ..color = Color.fromARGB(255, 255, 0, 0) - ..style = PaintingStyle.fill; - final PictureRecorder baseRecorder = PictureRecorder(); - final Canvas canvas = Canvas(baseRecorder); - canvas.drawRect(Rect.fromLTRB(0.0, 0.0, size.width, size.height), paint); - final Picture picture = baseRecorder.endRecording(); - builder.addPicture(Offset(0.0, 0.0), picture); - builder.pop(); - return builder.build(); -} - -@pragma('vm:entry-point') -void incorrectImmediateRender() { - PlatformDispatcher.instance.views.first.render(_createRedBoxScene(Size(2, 2))); - _finish(); - // Don't schedule a frame here. This test only checks if the - // [FlutterView.render] call is propagated to PlatformConfiguration.render - // and thus doesn't need anything from `Animator` or `Engine`, which, - // besides, are not even created in the native side at all. -} - -@pragma('vm:entry-point') -void incorrectDoubleRender() { - PlatformDispatcher.instance.onBeginFrame = (Duration value) { - PlatformDispatcher.instance.views.first.render(_createRedBoxScene(Size(2, 2))); - PlatformDispatcher.instance.views.first.render(_createRedBoxScene(Size(3, 3))); - }; - PlatformDispatcher.instance.onDrawFrame = () { - PlatformDispatcher.instance.views.first.render(_createRedBoxScene(Size(4, 4))); - PlatformDispatcher.instance.views.first.render(_createRedBoxScene(Size(5, 5))); - }; - _finish(); - // Don't schedule a frame here. This test only checks if the - // [FlutterView.render] call is propagated to PlatformConfiguration.render - // and thus doesn't need anything from `Animator` or `Engine`, which, - // besides, are not even created in the native side at all. -} diff --git a/lib/ui/platform_dispatcher.dart b/lib/ui/platform_dispatcher.dart index 7432c96a74c51..6d86cc6270315 100644 --- a/lib/ui/platform_dispatcher.dart +++ b/lib/ui/platform_dispatcher.dart @@ -308,21 +308,6 @@ class PlatformDispatcher { _invoke(onMetricsChanged, _onMetricsChangedZone); } - // [FlutterView]s for which [FlutterView.render] has already been called - // during the current [onBeginFrame]/[onDrawFrame] callback sequence. - // - // The field is null outside the scope of those callbacks indicating that - // calls to [FlutterView.render] must be ignored. Furthermore, if a given - // [FlutterView] is already present in this set when its [FlutterView.render] - // is called again, that call must be ignored as a duplicate. - // - // Between [onBeginFrame] and [onDrawFrame] the properties value is - // temporarily stored in `_renderedViewsBetweenCallbacks` so that it survives - // the gap between the two callbacks. - Set? _renderedViews; - // Temporary storage of the `_renderedViews` value between `_beginFrame` and - // `_drawFrame`. - Set? _renderedViewsBetweenCallbacks; /// A callback invoked when any view begins a frame. /// @@ -344,20 +329,11 @@ class PlatformDispatcher { // Called from the engine, via hooks.dart void _beginFrame(int microseconds) { - assert(_renderedViews == null); - assert(_renderedViewsBetweenCallbacks == null); - - _renderedViews = {}; _invoke1( onBeginFrame, _onBeginFrameZone, Duration(microseconds: microseconds), ); - _renderedViewsBetweenCallbacks = _renderedViews; - _renderedViews = null; - - assert(_renderedViews == null); - assert(_renderedViewsBetweenCallbacks != null); } /// A callback that is invoked for each frame after [onBeginFrame] has @@ -375,16 +351,7 @@ class PlatformDispatcher { // Called from the engine, via hooks.dart void _drawFrame() { - assert(_renderedViews == null); - assert(_renderedViewsBetweenCallbacks != null); - - _renderedViews = _renderedViewsBetweenCallbacks; - _renderedViewsBetweenCallbacks = null; _invoke(onDrawFrame, _onDrawFrameZone); - _renderedViews = null; - - assert(_renderedViews == null); - assert(_renderedViewsBetweenCallbacks == null); } /// A callback that is invoked when pointer data is available. diff --git a/lib/ui/window.dart b/lib/ui/window.dart index 4c5df1874fed4..d86781ef2567f 100644 --- a/lib/ui/window.dart +++ b/lib/ui/window.dart @@ -353,14 +353,7 @@ class FlutterView { /// scheduling of frames. /// * [RendererBinding], the Flutter framework class which manages layout and /// painting. - void render(Scene scene) { - if (platformDispatcher._renderedViews?.add(this) != true) { - // Duplicated calls or calls outside of onBeginFrame/onDrawFrame - // (indicated by _renderedViews being null) are ignored, as documented. - return; - } - _render(scene as _NativeScene); - } + void render(Scene scene) => _render(scene as _NativeScene); @Native)>(symbol: 'PlatformConfigurationNativeApi::Render') external static void _render(_NativeScene scene); diff --git a/lib/ui/window/platform_configuration_unittests.cc b/lib/ui/window/platform_configuration_unittests.cc index 50a9bd102164f..7410caeb66d6c 100644 --- a/lib/ui/window/platform_configuration_unittests.cc +++ b/lib/ui/window/platform_configuration_unittests.cc @@ -15,171 +15,10 @@ #include "flutter/shell/common/shell_test.h" #include "flutter/shell/common/thread_host.h" #include "flutter/testing/testing.h" -#include "gmock/gmock.h" namespace flutter { - -namespace { - -static constexpr int64_t kImplicitViewId = 0; - -static void PostSync(const fml::RefPtr& task_runner, - const fml::closure& task) { - fml::AutoResetWaitableEvent latch; - fml::TaskRunner::RunNowOrPostTask(task_runner, [&latch, &task] { - task(); - latch.Signal(); - }); - latch.Wait(); -} - -class MockRuntimeDelegate : public RuntimeDelegate { - public: - MOCK_METHOD(std::string, DefaultRouteName, (), (override)); - MOCK_METHOD(void, ScheduleFrame, (bool), (override)); - MOCK_METHOD(void, - Render, - (std::unique_ptr, float), - (override)); - MOCK_METHOD(void, - UpdateSemantics, - (SemanticsNodeUpdates, CustomAccessibilityActionUpdates), - (override)); - MOCK_METHOD(void, - HandlePlatformMessage, - (std::unique_ptr), - (override)); - MOCK_METHOD(FontCollection&, GetFontCollection, (), (override)); - MOCK_METHOD(std::shared_ptr, GetAssetManager, (), (override)); - MOCK_METHOD(void, OnRootIsolateCreated, (), (override)); - MOCK_METHOD(void, - UpdateIsolateDescription, - (const std::string, int64_t), - (override)); - MOCK_METHOD(void, SetNeedsReportTimings, (bool), (override)); - MOCK_METHOD(std::unique_ptr>, - ComputePlatformResolvedLocale, - (const std::vector&), - (override)); - MOCK_METHOD(void, RequestDartDeferredLibrary, (intptr_t), (override)); - MOCK_METHOD(std::weak_ptr, - GetPlatformMessageHandler, - (), - (const, override)); - MOCK_METHOD(void, SendChannelUpdate, (std::string, bool), (override)); - MOCK_METHOD(double, - GetScaledFontSize, - (double font_size, int configuration_id), - (const, override)); -}; - -class MockPlatformMessageHandler : public PlatformMessageHandler { - public: - MOCK_METHOD(void, - HandlePlatformMessage, - (std::unique_ptr message), - (override)); - MOCK_METHOD(bool, - DoesHandlePlatformMessageOnPlatformThread, - (), - (const, override)); - MOCK_METHOD(void, - InvokePlatformMessageResponseCallback, - (int response_id, std::unique_ptr mapping), - (override)); - MOCK_METHOD(void, - InvokePlatformMessageEmptyResponseCallback, - (int response_id), - (override)); -}; - -// A class that can launch a RuntimeController with the specified -// RuntimeDelegate. -// -// To use this class, contruct this class with Create, call LaunchRootIsolate, -// and use the controller with ControllerTaskSync(). -class RuntimeControllerContext { - public: - using ControllerCallback = std::function; - - [[nodiscard]] static std::unique_ptr Create( - Settings settings, // - const TaskRunners& task_runners, // - RuntimeDelegate& client) { - auto [vm, isolate_snapshot] = Shell::InferVmInitDataFromSettings(settings); - FML_CHECK(vm) << "Must be able to initialize the VM."; - // Construct the class with `new` because `make_unique` has no access to the - // private constructor. - RuntimeControllerContext* raw_pointer = new RuntimeControllerContext( - settings, task_runners, client, std::move(vm), isolate_snapshot); - return std::unique_ptr(raw_pointer); - } - - ~RuntimeControllerContext() { - PostSync(task_runners_.GetUITaskRunner(), - [&]() { runtime_controller_.reset(); }); - } - - // Launch the root isolate. The post_launch callback will be executed in the - // same UI task, which can be used to create initial views. - void LaunchRootIsolate(RunConfiguration& configuration, - ControllerCallback post_launch) { - PostSync(task_runners_.GetUITaskRunner(), [&]() { - bool launch_success = runtime_controller_->LaunchRootIsolate( - settings_, // - []() {}, // - configuration.GetEntrypoint(), // - configuration.GetEntrypointLibrary(), // - configuration.GetEntrypointArgs(), // - configuration.TakeIsolateConfiguration()); // - ASSERT_TRUE(launch_success); - post_launch(*runtime_controller_); - }); - } - - // Run a task that operates the RuntimeController on the UI thread, and wait - // for the task to end. - void ControllerTaskSync(ControllerCallback task) { - ASSERT_TRUE(runtime_controller_); - ASSERT_TRUE(task); - PostSync(task_runners_.GetUITaskRunner(), - [&]() { task(*runtime_controller_); }); - } - - private: - RuntimeControllerContext(const Settings& settings, - const TaskRunners& task_runners, - RuntimeDelegate& client, - DartVMRef vm, - fml::RefPtr isolate_snapshot) - : settings_(settings), - task_runners_(task_runners), - isolate_snapshot_(std::move(isolate_snapshot)), - vm_(std::move(vm)), - runtime_controller_(std::make_unique( - client, - &vm_, - std::move(isolate_snapshot_), - settings.idle_notification_callback, // idle notification callback - flutter::PlatformData(), // platform data - settings.isolate_create_callback, // isolate create callback - settings.isolate_shutdown_callback, // isolate shutdown callback - settings.persistent_isolate_data, // persistent isolate data - UIDartState::Context{task_runners})) {} - - Settings settings_; - TaskRunners task_runners_; - fml::RefPtr isolate_snapshot_; - DartVMRef vm_; - std::unique_ptr runtime_controller_; -}; -} // namespace - namespace testing { -using ::testing::_; -using ::testing::Return; - class PlatformConfigurationTest : public ShellTest {}; TEST_F(PlatformConfigurationTest, Initialization) { @@ -493,84 +332,5 @@ TEST_F(PlatformConfigurationTest, SetDartPerformanceMode) { DestroyShell(std::move(shell), task_runners); } -TEST_F(PlatformConfigurationTest, OutOfScopeRenderCallsAreIgnored) { - Settings settings = CreateSettingsForFixture(); - TaskRunners task_runners = GetTaskRunnersForFixture(); - - MockRuntimeDelegate client; - auto platform_message_handler = - std::make_shared(); - EXPECT_CALL(client, GetPlatformMessageHandler) - .WillOnce(Return(platform_message_handler)); - // Render should not be called. - EXPECT_CALL(client, Render).Times(0); - - auto message_latch = std::make_shared(); - auto finish = [message_latch](Dart_NativeArguments args) { - message_latch->Signal(); - }; - AddNativeCallback("Finish", CREATE_NATIVE_ENTRY(finish)); - - auto runtime_controller_context = - RuntimeControllerContext::Create(settings, task_runners, client); - - auto configuration = RunConfiguration::InferFromSettings(settings); - configuration.SetEntrypoint("incorrectImmediateRender"); - runtime_controller_context->LaunchRootIsolate( - configuration, [](RuntimeController& runtime_controller) { - runtime_controller.AddView( - kImplicitViewId, - ViewportMetrics( - /*pixel_ratio=*/1.0, /*width=*/20, /*height=*/20, - /*touch_slop=*/2, /*display_id=*/0)); - }); - - // Wait for the Dart main function to end. - message_latch->Wait(); -} - -TEST_F(PlatformConfigurationTest, DuplicateRenderCallsAreIgnored) { - Settings settings = CreateSettingsForFixture(); - TaskRunners task_runners = GetTaskRunnersForFixture(); - - MockRuntimeDelegate client; - auto platform_message_handler = - std::make_shared(); - EXPECT_CALL(client, GetPlatformMessageHandler) - .WillOnce(Return(platform_message_handler)); - // Render should only be called once, because the second call is ignored. - EXPECT_CALL(client, Render).Times(1); - - auto message_latch = std::make_shared(); - auto finish = [message_latch](Dart_NativeArguments args) { - message_latch->Signal(); - }; - AddNativeCallback("Finish", CREATE_NATIVE_ENTRY(finish)); - - auto runtime_controller_context = - RuntimeControllerContext::Create(settings, task_runners, client); - - auto configuration = RunConfiguration::InferFromSettings(settings); - configuration.SetEntrypoint("incorrectDoubleRender"); - runtime_controller_context->LaunchRootIsolate( - configuration, [](RuntimeController& runtime_controller) { - runtime_controller.AddView( - kImplicitViewId, - ViewportMetrics( - /*pixel_ratio=*/1.0, /*width=*/20, /*height=*/20, - /*touch_slop=*/2, /*display_id=*/0)); - }); - - // Wait for the Dart main function to end. - message_latch->Wait(); - - runtime_controller_context->ControllerTaskSync( - [](RuntimeController& runtime_controller) { - // This BeginFrame calls PlatformDispatcher's handleBeginFrame and - // handleDrawFrame synchronously. Therefore don't wait after it. - runtime_controller.BeginFrame(fml::TimePoint::Now(), 0); - }); -} - } // namespace testing } // namespace flutter diff --git a/shell/common/shell.cc b/shell/common/shell.cc index 4d0bec79af2c5..261a41fff2767 100644 --- a/shell/common/shell.cc +++ b/shell/common/shell.cc @@ -144,23 +144,6 @@ void PerformInitializationTasks(Settings& settings) { } // namespace -std::pair> -Shell::InferVmInitDataFromSettings(Settings& settings) { - // Always use the `vm_snapshot` and `isolate_snapshot` provided by the - // settings to launch the VM. If the VM is already running, the snapshot - // arguments are ignored. - auto vm_snapshot = DartSnapshot::VMSnapshotFromSettings(settings); - auto isolate_snapshot = DartSnapshot::IsolateSnapshotFromSettings(settings); - auto vm = DartVMRef::Create(settings, vm_snapshot, isolate_snapshot); - - // If the settings did not specify an `isolate_snapshot`, fall back to the - // one the VM was launched with. - if (!isolate_snapshot) { - isolate_snapshot = vm->GetVMData()->GetIsolateSnapshot(); - } - return {std::move(vm), isolate_snapshot}; -} - std::unique_ptr Shell::Create( const PlatformData& platform_data, const TaskRunners& task_runners, @@ -173,7 +156,19 @@ std::unique_ptr Shell::Create( TRACE_EVENT0("flutter", "Shell::Create"); - auto [vm, isolate_snapshot] = InferVmInitDataFromSettings(settings); + // Always use the `vm_snapshot` and `isolate_snapshot` provided by the + // settings to launch the VM. If the VM is already running, the snapshot + // arguments are ignored. + auto vm_snapshot = DartSnapshot::VMSnapshotFromSettings(settings); + auto isolate_snapshot = DartSnapshot::IsolateSnapshotFromSettings(settings); + auto vm = DartVMRef::Create(settings, vm_snapshot, isolate_snapshot); + FML_CHECK(vm) << "Must be able to initialize the VM."; + + // If the settings did not specify an `isolate_snapshot`, fall back to the + // one the VM was launched with. + if (!isolate_snapshot) { + isolate_snapshot = vm->GetVMData()->GetIsolateSnapshot(); + } auto resource_cache_limit_calculator = std::make_shared( settings.resource_cache_max_bytes_threshold); diff --git a/shell/common/shell.h b/shell/common/shell.h index d3bb7f0bd620c..b8c9c31052df6 100644 --- a/shell/common/shell.h +++ b/shell/common/shell.h @@ -438,16 +438,6 @@ class Shell final : public PlatformView::Delegate, const std::shared_ptr GetConcurrentWorkerTaskRunner() const; - // Infer the VM ref and the isolate snapshot based on the settings. - // - // If the VM is already running, the settings are ignored, but the returned - // isolate snapshot always prioritize what is specified by the settings, and - // falls back to the one VM was launched with. - // - // This function is what Shell::Create uses to infer snapshot settings. - static std::pair> - InferVmInitDataFromSettings(Settings& settings); - private: using ServiceProtocolHandler = std::function