From 93b6a9c5b00e9cafd536fdc160534d189c9ee2e2 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Sun, 14 May 2023 13:09:40 -0700 Subject: [PATCH 01/18] Push encoding to worker thread --- impeller/entity/contents/content_context.cc | 6 +-- impeller/entity/inline_pass_context.cc | 12 ++--- .../backend/metal/playground_impl_mtl.h | 2 + .../backend/metal/playground_impl_mtl.mm | 6 ++- .../backend/metal/command_buffer_mtl.h | 3 ++ .../backend/metal/command_buffer_mtl.mm | 52 +++++++++++++++++++ impeller/renderer/backend/metal/context_mtl.h | 12 ++++- .../renderer/backend/metal/context_mtl.mm | 23 +++++--- .../renderer/backend/metal/render_pass_mtl.mm | 2 + .../renderer/backend/metal/surface_mtl.mm | 3 ++ impeller/renderer/command_buffer.cc | 12 +++++ impeller/renderer/command_buffer.h | 15 +++++- impeller/renderer/render_pass.h | 1 + .../FlutterDarwinContextMetalImpeller.h | 9 +++- .../FlutterDarwinContextMetalImpeller.mm | 10 ++-- 15 files changed, 139 insertions(+), 29 deletions(-) diff --git a/impeller/entity/contents/content_context.cc b/impeller/entity/contents/content_context.cc index 4503b40cdbe6f..1643ad47182be 100644 --- a/impeller/entity/contents/content_context.cc +++ b/impeller/entity/contents/content_context.cc @@ -362,11 +362,7 @@ std::shared_ptr ContentContext::MakeSubpass( return nullptr; } - if (!sub_renderpass->EncodeCommands()) { - return nullptr; - } - - if (!sub_command_buffer->SubmitCommands()) { + if (!sub_command_buffer->SubmitCommandsAsync(std::move(sub_renderpass))) { return nullptr; } diff --git a/impeller/entity/inline_pass_context.cc b/impeller/entity/inline_pass_context.cc index fd3afd2d8040d..b04bf025c7dc4 100644 --- a/impeller/entity/inline_pass_context.cc +++ b/impeller/entity/inline_pass_context.cc @@ -54,15 +54,9 @@ bool InlinePassContext::EndPass() { return true; } - if (!pass_->EncodeCommands()) { - VALIDATION_LOG - << "Failed to encode commands while ending the current render pass."; - return false; - } - - if (!command_buffer_->SubmitCommands()) { - VALIDATION_LOG - << "Failed to submit command buffer while ending render pass."; + if (!command_buffer_->SubmitCommandsAsync(std::move(pass_))) { + VALIDATION_LOG << "Failed to encode and submit command buffer while ending " + "render pass."; return false; } diff --git a/impeller/playground/backend/metal/playground_impl_mtl.h b/impeller/playground/backend/metal/playground_impl_mtl.h index d1b1aebd80edb..483dd7b1e37ad 100644 --- a/impeller/playground/backend/metal/playground_impl_mtl.h +++ b/impeller/playground/backend/metal/playground_impl_mtl.h @@ -8,6 +8,7 @@ #include "flutter/fml/macros.h" #include "impeller/playground/playground_impl.h" +#include "flutter/fml/concurrent_message_loop.h" namespace impeller { @@ -27,6 +28,7 @@ class PlaygroundImplMTL final : public PlaygroundImpl { // To ensure that ObjC stuff doesn't leak into C++ TUs. std::unique_ptr data_; std::shared_ptr context_; + std::shared_ptr concurrent_loop_; // |PlaygroundImpl| std::shared_ptr GetContext() const override; diff --git a/impeller/playground/backend/metal/playground_impl_mtl.mm b/impeller/playground/backend/metal/playground_impl_mtl.mm index 033824b11383b..333c712f6bfb7 100644 --- a/impeller/playground/backend/metal/playground_impl_mtl.mm +++ b/impeller/playground/backend/metal/playground_impl_mtl.mm @@ -63,7 +63,8 @@ PlaygroundImplMTL::PlaygroundImplMTL(PlaygroundSwitches switches) : PlaygroundImpl(switches), handle_(nullptr, &DestroyWindowHandle), - data_(std::make_unique()) { + data_(std::make_unique()), + concurrent_loop_(fml::ConcurrentMessageLoop::Create()) { ::glfwDefaultWindowHints(); ::glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); ::glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); @@ -71,8 +72,9 @@ if (!window) { return; } + auto worker_task_runner = concurrent_loop_->GetTaskRunner(); auto context = ContextMTL::Create(ShaderLibraryMappingsForPlayground(), - "Playground Library"); + worker_task_runner, "Playground Library"); if (!context) { return; } diff --git a/impeller/renderer/backend/metal/command_buffer_mtl.h b/impeller/renderer/backend/metal/command_buffer_mtl.h index f6e4f0eb9cb9d..7fb49d1882450 100644 --- a/impeller/renderer/backend/metal/command_buffer_mtl.h +++ b/impeller/renderer/backend/metal/command_buffer_mtl.h @@ -36,6 +36,9 @@ class CommandBufferMTL final : public CommandBuffer { // |CommandBuffer| void OnWaitUntilScheduled() override; + // |CommandBuffer| + bool SubmitCommandsAsync(std::shared_ptr render_pass) override; + // |CommandBuffer| std::shared_ptr OnCreateRenderPass(RenderTarget target) override; diff --git a/impeller/renderer/backend/metal/command_buffer_mtl.mm b/impeller/renderer/backend/metal/command_buffer_mtl.mm index bd1b71f64c03e..48adc229e49f5 100644 --- a/impeller/renderer/backend/metal/command_buffer_mtl.mm +++ b/impeller/renderer/backend/metal/command_buffer_mtl.mm @@ -4,8 +4,13 @@ #include "impeller/renderer/backend/metal/command_buffer_mtl.h" +#include "flutter/fml/make_copyable.h" +#include "flutter/fml/synchronization/semaphore.h" +#include "flutter/fml/trace_event.h" + #include "impeller/renderer/backend/metal/blit_pass_mtl.h" #include "impeller/renderer/backend/metal/compute_pass_mtl.h" +#include "impeller/renderer/backend/metal/context_mtl.h" #include "impeller/renderer/backend/metal/render_pass_mtl.h" namespace impeller { @@ -171,6 +176,53 @@ static bool LogMTLCommandBufferErrorIfPresent(id buffer) { return true; } +bool CommandBufferMTL::SubmitCommandsAsync( + std::shared_ptr render_pass) { + TRACE_EVENT0("impeller", "CommandBufferMTL::SubmitCommandsAsync"); + if (!IsValid() || !render_pass->IsValid()) { + return false; + } + auto context = context_.lock(); + if (!context) { + return false; + } + [buffer_ enqueue]; + auto buffer = buffer_; + buffer_ = nil; + + auto worker_task_runner = ContextMTL::Cast(*context).GetWorkerTaskRunner(); + + auto mtl_render_pass = static_cast(render_pass.get()); + + // Render command encoder creation has been observed to exceed the stack size + // limit for worker threads, and therefore is intentionally constructed on the + // raster thread. + auto render_command_encoder = + [buffer renderCommandEncoderWithDescriptor:mtl_render_pass->desc_]; + if (!render_command_encoder) { + return false; + } + + auto task = fml::MakeCopyable( + [render_pass, buffer, render_command_encoder, context]() { + auto mtl_render_pass = static_cast(render_pass.get()); + if (!mtl_render_pass->label_.empty()) { + [render_command_encoder setLabel:@(mtl_render_pass->label_.c_str())]; + } + + auto result = mtl_render_pass->EncodeCommands( + context->GetResourceAllocator(), render_command_encoder); + [render_command_encoder endEncoding]; + if (result) { + [buffer commit]; + } else { + VALIDATION_LOG << "Failed to encode command buffer"; + } + }); + worker_task_runner->PostTask(task); + return true; +} + void CommandBufferMTL::OnWaitUntilScheduled() {} std::shared_ptr CommandBufferMTL::OnCreateRenderPass( diff --git a/impeller/renderer/backend/metal/context_mtl.h b/impeller/renderer/backend/metal/context_mtl.h index f6a5bfd25232e..ee41df8a53c5f 100644 --- a/impeller/renderer/backend/metal/context_mtl.h +++ b/impeller/renderer/backend/metal/context_mtl.h @@ -9,6 +9,7 @@ #include #include +#include "flutter/fml/concurrent_message_loop.h" #include "flutter/fml/macros.h" #include "impeller/base/backend_cast.h" #include "impeller/core/sampler.h" @@ -26,10 +27,12 @@ class ContextMTL final : public Context, public std::enable_shared_from_this { public: static std::shared_ptr Create( - const std::vector& shader_library_paths); + const std::vector& shader_library_paths, + std::shared_ptr worker_task_runner); static std::shared_ptr Create( const std::vector>& shader_libraries_data, + std::shared_ptr worker_task_runner, const std::string& label); // |Context| @@ -66,6 +69,8 @@ class ContextMTL final : public Context, id CreateMTLCommandBuffer() const; + const std::shared_ptr& GetWorkerTaskRunner() const; + private: id device_ = nullptr; id command_queue_ = nullptr; @@ -74,9 +79,12 @@ class ContextMTL final : public Context, std::shared_ptr sampler_library_; std::shared_ptr resource_allocator_; std::shared_ptr device_capabilities_; + std::shared_ptr worker_task_runner_; bool is_valid_ = false; - ContextMTL(id device, NSArray>* shader_libraries); + ContextMTL(id device, + NSArray>* shader_libraries, + std::shared_ptr worker_task_runner); std::shared_ptr CreateCommandBufferInQueue( id queue) const; diff --git a/impeller/renderer/backend/metal/context_mtl.mm b/impeller/renderer/backend/metal/context_mtl.mm index c83f5b7075c47..75989ea68d695 100644 --- a/impeller/renderer/backend/metal/context_mtl.mm +++ b/impeller/renderer/backend/metal/context_mtl.mm @@ -65,9 +65,11 @@ static bool DeviceSupportsComputeSubgroups(id device) { .Build(); } -ContextMTL::ContextMTL(id device, - NSArray>* shader_libraries) - : device_(device) { +ContextMTL::ContextMTL( + id device, + NSArray>* shader_libraries, + std::shared_ptr worker_task_runner) + : device_(device), worker_task_runner_(std::move(worker_task_runner)) { // Validate device. if (!device_) { VALIDATION_LOG << "Could not setup valid Metal device."; @@ -200,10 +202,12 @@ static bool DeviceSupportsComputeSubgroups(id device) { } std::shared_ptr ContextMTL::Create( - const std::vector& shader_library_paths) { + const std::vector& shader_library_paths, + std::shared_ptr worker_task_runner) { auto device = CreateMetalDevice(); auto context = std::shared_ptr(new ContextMTL( - device, MTLShaderLibraryFromFilePaths(device, shader_library_paths))); + device, MTLShaderLibraryFromFilePaths(device, shader_library_paths), + std::move(worker_task_runner))); if (!context->IsValid()) { FML_LOG(ERROR) << "Could not create Metal context."; return nullptr; @@ -213,11 +217,13 @@ static bool DeviceSupportsComputeSubgroups(id device) { std::shared_ptr ContextMTL::Create( const std::vector>& shader_libraries_data, + std::shared_ptr worker_task_runner, const std::string& label) { auto device = CreateMetalDevice(); auto context = std::shared_ptr(new ContextMTL( device, - MTLShaderLibraryFromFileData(device, shader_libraries_data, label))); + MTLShaderLibraryFromFileData(device, shader_libraries_data, label), + worker_task_runner)); if (!context->IsValid()) { FML_LOG(ERROR) << "Could not create Metal context."; return nullptr; @@ -257,6 +263,11 @@ static bool DeviceSupportsComputeSubgroups(id device) { return CreateCommandBufferInQueue(command_queue_); } +const std::shared_ptr& +ContextMTL::GetWorkerTaskRunner() const { + return worker_task_runner_; +} + std::shared_ptr ContextMTL::CreateCommandBufferInQueue( id queue) const { if (!IsValid()) { diff --git a/impeller/renderer/backend/metal/render_pass_mtl.mm b/impeller/renderer/backend/metal/render_pass_mtl.mm index 1eb63299b23fb..317e46b98ca64 100644 --- a/impeller/renderer/backend/metal/render_pass_mtl.mm +++ b/impeller/renderer/backend/metal/render_pass_mtl.mm @@ -6,11 +6,13 @@ #include "flutter/fml/closure.h" #include "flutter/fml/logging.h" +#include "flutter/fml/make_copyable.h" #include "flutter/fml/trace_event.h" #include "impeller/base/backend_cast.h" #include "impeller/core/formats.h" #include "impeller/core/host_buffer.h" #include "impeller/core/shader_types.h" +#include "impeller/renderer/backend/metal/context_mtl.h" #include "impeller/renderer/backend/metal/device_buffer_mtl.h" #include "impeller/renderer/backend/metal/formats_mtl.h" #include "impeller/renderer/backend/metal/pipeline_mtl.h" diff --git a/impeller/renderer/backend/metal/surface_mtl.mm b/impeller/renderer/backend/metal/surface_mtl.mm index 55e88039f1c51..0731273567d0d 100644 --- a/impeller/renderer/backend/metal/surface_mtl.mm +++ b/impeller/renderer/backend/metal/surface_mtl.mm @@ -179,6 +179,7 @@ } } +#if ((FML_OS_MACOSX && !FML_OS_IOS) || FML_OS_IOS_SIMULATOR) // If a transaction is present, `presentDrawable` will present too early. And // so we wait on an empty command buffer to get scheduled instead, which // forces us to also wait for all of the previous command buffers in the queue @@ -187,6 +188,8 @@ ContextMTL::Cast(context.get())->CreateMTLCommandBuffer(); [command_buffer commit]; [command_buffer waitUntilScheduled]; +#endif // (FML_OS_MACOSX && !FML_OS_IOS) || FML_OS_IOS_SIMULATOR) (not iPhone) + [drawable_ present]; return true; diff --git a/impeller/renderer/command_buffer.cc b/impeller/renderer/command_buffer.cc index 99e6be8ef5cbe..e4dc993e6a510 100644 --- a/impeller/renderer/command_buffer.cc +++ b/impeller/renderer/command_buffer.cc @@ -36,6 +36,18 @@ void CommandBuffer::WaitUntilScheduled() { return OnWaitUntilScheduled(); } +bool CommandBuffer::SubmitCommandsAsync( std::shared_ptr render_pass) { + TRACE_EVENT0("impeller", "CommandBuffer::SubmitCommandsAsync"); + if (!render_pass->IsValid() || !IsValid()) { + return false; + } + if (!render_pass->EncodeCommands()) { + return false; + } + + return SubmitCommands(nullptr); +} + std::shared_ptr CommandBuffer::CreateRenderPass( const RenderTarget& render_target) { auto pass = OnCreateRenderPass(render_target); diff --git a/impeller/renderer/command_buffer.h b/impeller/renderer/command_buffer.h index 71703bb40f41a..958ef792f43d1 100644 --- a/impeller/renderer/command_buffer.h +++ b/impeller/renderer/command_buffer.h @@ -55,7 +55,8 @@ class CommandBuffer { //---------------------------------------------------------------------------- /// @brief Schedule the command encoded by render passes within this - /// command buffer on the GPU. + /// command buffer on the GPU. The encoding of these commnands is + /// performed immediately on the calling thread. /// /// A command buffer may only be committed once. /// @@ -65,6 +66,18 @@ class CommandBuffer { [[nodiscard]] bool SubmitCommands(); + //---------------------------------------------------------------------------- + /// @brief Schedule the command encoded by render passes within this + /// command buffer on the GPU. The enqueing of this buffer is + /// performed immediately but encoding is pushed to a worker + /// thread if possible. + /// + /// A command buffer may only be committed once. + /// + [[nodiscard]] virtual bool SubmitCommandsAsync( + std::shared_ptr render_pass + ); + //---------------------------------------------------------------------------- /// @brief Force execution of pending GPU commands. /// diff --git a/impeller/renderer/render_pass.h b/impeller/renderer/render_pass.h index a75b59b279c54..616e2f3fbc6d0 100644 --- a/impeller/renderer/render_pass.h +++ b/impeller/renderer/render_pass.h @@ -8,6 +8,7 @@ #include "impeller/renderer/command.h" #include "impeller/renderer/render_target.h" +#include "impeller/renderer/command_buffer.h" namespace impeller { diff --git a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h index 55fc5ac9b79c3..85c97322862ee 100644 --- a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h +++ b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h @@ -9,6 +9,7 @@ #import #import +#include "flutter/fml/concurrent_message_loop.h" #include "flutter/fml/platform/darwin/cf_utils.h" #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterTexture.h" #import "flutter/shell/platform/darwin/graphics/FlutterDarwinExternalTextureMetal.h" @@ -34,10 +35,16 @@ NS_ASSUME_NONNULL_BEGIN texture:(NSObject*)texture; /** - * Impeller context; + * Impeller context. */ @property(nonatomic, readonly) std::shared_ptr context; + +/** + * Concurrent message loop. + */ +@property(nonatomic, readonly) std::shared_ptr workers; + /* * Texture cache for external textures. */ diff --git a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm index e84a2e29cb30f..b630fb16ae437 100644 --- a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm +++ b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm @@ -16,7 +16,8 @@ FLUTTER_ASSERT_ARC -static std::shared_ptr CreateImpellerContext() { +static std::shared_ptr CreateImpellerContext( + const std::shared_ptr& concurrent_loop) { std::vector> shader_mappings = { std::make_shared(impeller_entity_shaders_data, impeller_entity_shaders_length), @@ -27,7 +28,9 @@ std::make_shared(impeller_framebuffer_blend_shaders_data, impeller_framebuffer_blend_shaders_length), }; - auto context = impeller::ContextMTL::Create(shader_mappings, "Impeller Library"); + auto worker_task_runner = concurrent_loop->GetTaskRunner(); + auto context = + impeller::ContextMTL::Create(shader_mappings, worker_task_runner, "Impeller Library"); if (!context) { FML_LOG(ERROR) << "Could not create Metal Impeller Context."; return nullptr; @@ -42,7 +45,8 @@ @implementation FlutterDarwinContextMetalImpeller - (instancetype)init { self = [super init]; if (self != nil) { - _context = CreateImpellerContext(); + _workers = fml::ConcurrentMessageLoop::Create(); + _context = CreateImpellerContext(_workers); id device = _context->GetMTLDevice(); if (!device) { FML_DLOG(ERROR) << "Could not acquire Metal device."; From 7c9382ddbaa2364afdd67368791c8b7acb0a9ba4 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Sun, 14 May 2023 13:10:07 -0700 Subject: [PATCH 02/18] ++ --- impeller/playground/backend/metal/playground_impl_mtl.h | 2 +- impeller/renderer/backend/metal/surface_mtl.mm | 2 +- impeller/renderer/command_buffer.cc | 3 ++- impeller/renderer/command_buffer.h | 3 +-- impeller/renderer/render_pass.h | 2 +- .../darwin/graphics/FlutterDarwinContextMetalImpeller.h | 1 - 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/impeller/playground/backend/metal/playground_impl_mtl.h b/impeller/playground/backend/metal/playground_impl_mtl.h index 483dd7b1e37ad..aabbcdad461e7 100644 --- a/impeller/playground/backend/metal/playground_impl_mtl.h +++ b/impeller/playground/backend/metal/playground_impl_mtl.h @@ -6,9 +6,9 @@ #include +#include "flutter/fml/concurrent_message_loop.h" #include "flutter/fml/macros.h" #include "impeller/playground/playground_impl.h" -#include "flutter/fml/concurrent_message_loop.h" namespace impeller { diff --git a/impeller/renderer/backend/metal/surface_mtl.mm b/impeller/renderer/backend/metal/surface_mtl.mm index 0731273567d0d..98c3ba9cc5bd0 100644 --- a/impeller/renderer/backend/metal/surface_mtl.mm +++ b/impeller/renderer/backend/metal/surface_mtl.mm @@ -188,7 +188,7 @@ ContextMTL::Cast(context.get())->CreateMTLCommandBuffer(); [command_buffer commit]; [command_buffer waitUntilScheduled]; -#endif // (FML_OS_MACOSX && !FML_OS_IOS) || FML_OS_IOS_SIMULATOR) (not iPhone) +#endif // (FML_OS_MACOSX && !FML_OS_IOS) || FML_OS_IOS_SIMULATOR) (not iPhone) [drawable_ present]; diff --git a/impeller/renderer/command_buffer.cc b/impeller/renderer/command_buffer.cc index e4dc993e6a510..1df3e7c9cb19c 100644 --- a/impeller/renderer/command_buffer.cc +++ b/impeller/renderer/command_buffer.cc @@ -36,7 +36,8 @@ void CommandBuffer::WaitUntilScheduled() { return OnWaitUntilScheduled(); } -bool CommandBuffer::SubmitCommandsAsync( std::shared_ptr render_pass) { +bool CommandBuffer::SubmitCommandsAsync( + std::shared_ptr render_pass) { TRACE_EVENT0("impeller", "CommandBuffer::SubmitCommandsAsync"); if (!render_pass->IsValid() || !IsValid()) { return false; diff --git a/impeller/renderer/command_buffer.h b/impeller/renderer/command_buffer.h index 958ef792f43d1..3a6abacbb2556 100644 --- a/impeller/renderer/command_buffer.h +++ b/impeller/renderer/command_buffer.h @@ -75,8 +75,7 @@ class CommandBuffer { /// A command buffer may only be committed once. /// [[nodiscard]] virtual bool SubmitCommandsAsync( - std::shared_ptr render_pass - ); + std::shared_ptr render_pass); //---------------------------------------------------------------------------- /// @brief Force execution of pending GPU commands. diff --git a/impeller/renderer/render_pass.h b/impeller/renderer/render_pass.h index 616e2f3fbc6d0..a5fac32292f8c 100644 --- a/impeller/renderer/render_pass.h +++ b/impeller/renderer/render_pass.h @@ -7,8 +7,8 @@ #include #include "impeller/renderer/command.h" -#include "impeller/renderer/render_target.h" #include "impeller/renderer/command_buffer.h" +#include "impeller/renderer/render_target.h" namespace impeller { diff --git a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h index 85c97322862ee..ec549798aaeb2 100644 --- a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h +++ b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h @@ -39,7 +39,6 @@ NS_ASSUME_NONNULL_BEGIN */ @property(nonatomic, readonly) std::shared_ptr context; - /** * Concurrent message loop. */ From e122d329c09041588d1c106d05d173ceae1f426b Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 15 May 2023 10:58:22 -0700 Subject: [PATCH 03/18] ++ --- impeller/renderer/command_buffer.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/impeller/renderer/command_buffer.cc b/impeller/renderer/command_buffer.cc index 1df3e7c9cb19c..0ffad01ff9857 100644 --- a/impeller/renderer/command_buffer.cc +++ b/impeller/renderer/command_buffer.cc @@ -37,7 +37,9 @@ void CommandBuffer::WaitUntilScheduled() { } bool CommandBuffer::SubmitCommandsAsync( - std::shared_ptr render_pass) { + std::shared_ptr + render_pass // NOLINT(performance-unnecessary-value-param) +) { TRACE_EVENT0("impeller", "CommandBuffer::SubmitCommandsAsync"); if (!render_pass->IsValid() || !IsValid()) { return false; From 69ac78994d984d611a34ee5a34bc15a92e1dc5e2 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Thu, 18 May 2023 14:06:56 -0700 Subject: [PATCH 04/18] ++ --- impeller/renderer/backend/metal/command_buffer_mtl.mm | 7 ++++++- impeller/renderer/backend/metal/surface_mtl.mm | 3 --- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/impeller/renderer/backend/metal/command_buffer_mtl.mm b/impeller/renderer/backend/metal/command_buffer_mtl.mm index 48adc229e49f5..3381aa9fa8c0b 100644 --- a/impeller/renderer/backend/metal/command_buffer_mtl.mm +++ b/impeller/renderer/backend/metal/command_buffer_mtl.mm @@ -204,7 +204,12 @@ static bool LogMTLCommandBufferErrorIfPresent(id buffer) { } auto task = fml::MakeCopyable( - [render_pass, buffer, render_command_encoder, context]() { + [render_pass, buffer, render_command_encoder, weak_context = context_]() { + auto context = weak_context.lock(); + if (!context) { + return; + } + auto mtl_render_pass = static_cast(render_pass.get()); if (!mtl_render_pass->label_.empty()) { [render_command_encoder setLabel:@(mtl_render_pass->label_.c_str())]; diff --git a/impeller/renderer/backend/metal/surface_mtl.mm b/impeller/renderer/backend/metal/surface_mtl.mm index 98c3ba9cc5bd0..55e88039f1c51 100644 --- a/impeller/renderer/backend/metal/surface_mtl.mm +++ b/impeller/renderer/backend/metal/surface_mtl.mm @@ -179,7 +179,6 @@ } } -#if ((FML_OS_MACOSX && !FML_OS_IOS) || FML_OS_IOS_SIMULATOR) // If a transaction is present, `presentDrawable` will present too early. And // so we wait on an empty command buffer to get scheduled instead, which // forces us to also wait for all of the previous command buffers in the queue @@ -188,8 +187,6 @@ ContextMTL::Cast(context.get())->CreateMTLCommandBuffer(); [command_buffer commit]; [command_buffer waitUntilScheduled]; -#endif // (FML_OS_MACOSX && !FML_OS_IOS) || FML_OS_IOS_SIMULATOR) (not iPhone) - [drawable_ present]; return true; From 18ef71789b37065fbaf0017a849508d17bcfa1ee Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 22 May 2023 10:16:18 -0700 Subject: [PATCH 05/18] take existing concurrent message loop --- .../graphics/FlutterDarwinContextMetalImpeller.h | 7 +------ .../graphics/FlutterDarwinContextMetalImpeller.mm | 12 +++++------- .../darwin/ios/framework/Source/FlutterEngine.mm | 3 ++- shell/platform/darwin/ios/ios_context.h | 6 +++++- shell/platform/darwin/ios/ios_context.mm | 5 +++-- .../platform/darwin/ios/ios_context_metal_impeller.h | 2 +- .../darwin/ios/ios_context_metal_impeller.mm | 4 ++-- shell/platform/darwin/ios/platform_view_ios.h | 3 ++- shell/platform/darwin/ios/platform_view_ios.mm | 6 ++++-- 9 files changed, 25 insertions(+), 23 deletions(-) diff --git a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h index ec549798aaeb2..b6781aea21b8f 100644 --- a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h +++ b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h @@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Initializes a FlutterDarwinContextMetalImpeller. */ -- (instancetype)init; +- (instancetype)initWithTaskRunner:(std::shared_ptr)task_runner; /** * Creates an external texture with the specified ID and contents. @@ -39,11 +39,6 @@ NS_ASSUME_NONNULL_BEGIN */ @property(nonatomic, readonly) std::shared_ptr context; -/** - * Concurrent message loop. - */ -@property(nonatomic, readonly) std::shared_ptr workers; - /* * Texture cache for external textures. */ diff --git a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm index b630fb16ae437..13bbff8c1d915 100644 --- a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm +++ b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm @@ -17,7 +17,7 @@ FLUTTER_ASSERT_ARC static std::shared_ptr CreateImpellerContext( - const std::shared_ptr& concurrent_loop) { + std::shared_ptr worker_task_runner) { std::vector> shader_mappings = { std::make_shared(impeller_entity_shaders_data, impeller_entity_shaders_length), @@ -28,9 +28,8 @@ std::make_shared(impeller_framebuffer_blend_shaders_data, impeller_framebuffer_blend_shaders_length), }; - auto worker_task_runner = concurrent_loop->GetTaskRunner(); - auto context = - impeller::ContextMTL::Create(shader_mappings, worker_task_runner, "Impeller Library"); + auto context = impeller::ContextMTL::Create(shader_mappings, std::move(worker_task_runner), + "Impeller Library"); if (!context) { FML_LOG(ERROR) << "Could not create Metal Impeller Context."; return nullptr; @@ -42,11 +41,10 @@ @implementation FlutterDarwinContextMetalImpeller -- (instancetype)init { +- (instancetype)initWithTaskRunner:(std::shared_ptr)task_runner { self = [super init]; if (self != nil) { - _workers = fml::ConcurrentMessageLoop::Create(); - _context = CreateImpellerContext(_workers); + _context = CreateImpellerContext(std::move(task_runner)); id device = _context->GetMTLDevice(); if (!device) { FML_DLOG(ERROR) << "Could not acquire Metal device."; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index a124d2b0296a4..c9e6b4a206d33 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm @@ -836,7 +836,8 @@ - (BOOL)createShell:(NSString*)entrypoint [self](flutter::Shell& shell) { [self recreatePlatformViewController]; return std::make_unique( - shell, self->_renderingApi, self->_platformViewsController, shell.GetTaskRunners()); + shell, self->_renderingApi, self->_platformViewsController, shell.GetTaskRunners(), + shell.GetConcurrentWorkerTaskRunner()); }; flutter::Shell::CreateCallback on_create_rasterizer = diff --git a/shell/platform/darwin/ios/ios_context.h b/shell/platform/darwin/ios/ios_context.h index db14fd37e23de..792d818c6b147 100644 --- a/shell/platform/darwin/ios/ios_context.h +++ b/shell/platform/darwin/ios/ios_context.h @@ -10,6 +10,7 @@ #include "flutter/common/graphics/gl_context_switch.h" #include "flutter/common/graphics/msaa_sample_count.h" #include "flutter/common/graphics/texture.h" +#include "flutter/fml/concurrent_message_loop.h" #include "flutter/fml/macros.h" #include "flutter/fml/platform/darwin/scoped_nsobject.h" #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterTexture.h" @@ -51,12 +52,15 @@ class IOSContext { /// @param[in] msaa_samples /// The number of MSAA samples to use. Only supplied to /// Skia, must be either 0, 1, 2, 4, or 8. + /// @param[in] task_runner + /// The engine concurrent task runner. /// /// @return A valid context on success. `nullptr` on failure. /// static std::unique_ptr Create(IOSRenderingAPI api, IOSRenderingBackend backend, - MsaaSampleCount msaa_samples); + MsaaSampleCount msaa_samples, + std::shared_ptr task_runner); //---------------------------------------------------------------------------- /// @brief Collects the context object. This must happen on the thread on diff --git a/shell/platform/darwin/ios/ios_context.mm b/shell/platform/darwin/ios/ios_context.mm index f861e10e3ff6b..686e1a7bd80db 100644 --- a/shell/platform/darwin/ios/ios_context.mm +++ b/shell/platform/darwin/ios/ios_context.mm @@ -20,7 +20,8 @@ std::unique_ptr IOSContext::Create(IOSRenderingAPI api, IOSRenderingBackend backend, - MsaaSampleCount msaa_samples) { + MsaaSampleCount msaa_samples, + std::shared_ptr task_runner) { switch (api) { case IOSRenderingAPI::kSoftware: return std::make_unique(); @@ -30,7 +31,7 @@ case IOSRenderingBackend::kSkia: return std::make_unique(msaa_samples); case IOSRenderingBackend::kImpeller: - return std::make_unique(); + return std::make_unique(std::move(task_runner)); } #endif // SHELL_ENABLE_METAL default: diff --git a/shell/platform/darwin/ios/ios_context_metal_impeller.h b/shell/platform/darwin/ios/ios_context_metal_impeller.h index a46dc81cfed9c..d225d66d8afbd 100644 --- a/shell/platform/darwin/ios/ios_context_metal_impeller.h +++ b/shell/platform/darwin/ios/ios_context_metal_impeller.h @@ -20,7 +20,7 @@ namespace flutter { class IOSContextMetalImpeller final : public IOSContext { public: - IOSContextMetalImpeller(); + IOSContextMetalImpeller(std::shared_ptr task_runner); ~IOSContextMetalImpeller(); diff --git a/shell/platform/darwin/ios/ios_context_metal_impeller.mm b/shell/platform/darwin/ios/ios_context_metal_impeller.mm index fc011f652c4cf..f686809cb1e1b 100644 --- a/shell/platform/darwin/ios/ios_context_metal_impeller.mm +++ b/shell/platform/darwin/ios/ios_context_metal_impeller.mm @@ -8,10 +8,10 @@ namespace flutter { -IOSContextMetalImpeller::IOSContextMetalImpeller() +IOSContextMetalImpeller::IOSContextMetalImpeller(std::shared_ptr task_runner) : IOSContext(MsaaSampleCount::kFour), darwin_context_metal_impeller_(fml::scoped_nsobject{ - [[FlutterDarwinContextMetalImpeller alloc] init]}) {} + [[FlutterDarwinContextMetalImpeller alloc] initWithTaskRunner:task_runner]}) {} IOSContextMetalImpeller::~IOSContextMetalImpeller() = default; diff --git a/shell/platform/darwin/ios/platform_view_ios.h b/shell/platform/darwin/ios/platform_view_ios.h index e9129350a4277..ffe2675e5db1b 100644 --- a/shell/platform/darwin/ios/platform_view_ios.h +++ b/shell/platform/darwin/ios/platform_view_ios.h @@ -49,7 +49,8 @@ class PlatformViewIOS final : public PlatformView { PlatformView::Delegate& delegate, IOSRenderingAPI rendering_api, const std::shared_ptr& platform_views_controller, - const flutter::TaskRunners& task_runners); + const flutter::TaskRunners& task_runners, + const std::shared_ptr& worker_task_runner); ~PlatformViewIOS() override; diff --git a/shell/platform/darwin/ios/platform_view_ios.mm b/shell/platform/darwin/ios/platform_view_ios.mm index 219dab4ec9c98..0f0fab4978815 100644 --- a/shell/platform/darwin/ios/platform_view_ios.mm +++ b/shell/platform/darwin/ios/platform_view_ios.mm @@ -55,14 +55,16 @@ new PlatformMessageHandlerIos(task_runners.GetPlatformTaskRunner())) {} PlatformView::Delegate& delegate, IOSRenderingAPI rendering_api, const std::shared_ptr& platform_views_controller, - const flutter::TaskRunners& task_runners) + const flutter::TaskRunners& task_runners, + const std::shared_ptr& worker_task_runner) : PlatformViewIOS( delegate, IOSContext::Create( rendering_api, delegate.OnPlatformViewGetSettings().enable_impeller ? IOSRenderingBackend::kImpeller : IOSRenderingBackend::kSkia, - static_cast(delegate.OnPlatformViewGetSettings().msaa_samples)), + static_cast(delegate.OnPlatformViewGetSettings().msaa_samples), + worker_task_runner), platform_views_controller, task_runners) {} From 71369e4808200d12f99d6822bfe29ba93e9ec3ed Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 22 May 2023 10:16:47 -0700 Subject: [PATCH 06/18] ++ --- shell/platform/darwin/ios/ios_context.mm | 9 +++++---- shell/platform/darwin/ios/ios_context_metal_impeller.mm | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/shell/platform/darwin/ios/ios_context.mm b/shell/platform/darwin/ios/ios_context.mm index 686e1a7bd80db..82e01b619c1ab 100644 --- a/shell/platform/darwin/ios/ios_context.mm +++ b/shell/platform/darwin/ios/ios_context.mm @@ -18,10 +18,11 @@ IOSContext::~IOSContext() = default; -std::unique_ptr IOSContext::Create(IOSRenderingAPI api, - IOSRenderingBackend backend, - MsaaSampleCount msaa_samples, - std::shared_ptr task_runner) { +std::unique_ptr IOSContext::Create( + IOSRenderingAPI api, + IOSRenderingBackend backend, + MsaaSampleCount msaa_samples, + std::shared_ptr task_runner) { switch (api) { case IOSRenderingAPI::kSoftware: return std::make_unique(); diff --git a/shell/platform/darwin/ios/ios_context_metal_impeller.mm b/shell/platform/darwin/ios/ios_context_metal_impeller.mm index f686809cb1e1b..d6377e523236b 100644 --- a/shell/platform/darwin/ios/ios_context_metal_impeller.mm +++ b/shell/platform/darwin/ios/ios_context_metal_impeller.mm @@ -8,7 +8,8 @@ namespace flutter { -IOSContextMetalImpeller::IOSContextMetalImpeller(std::shared_ptr task_runner) +IOSContextMetalImpeller::IOSContextMetalImpeller( + std::shared_ptr task_runner) : IOSContext(MsaaSampleCount::kFour), darwin_context_metal_impeller_(fml::scoped_nsobject{ [[FlutterDarwinContextMetalImpeller alloc] initWithTaskRunner:task_runner]}) {} From 2648dd2840a0e7c9e29d1927e8af6067c4424838 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 22 May 2023 10:55:36 -0700 Subject: [PATCH 07/18] Tests --- shell/common/animator_unittests.cc | 3 ++- shell/common/shell_test.cc | 13 +++++++------ shell/common/shell_test_platform_view.cc | 5 +++-- shell/common/shell_test_platform_view.h | 3 ++- shell/common/shell_test_platform_view_metal.h | 14 ++++++++------ shell/common/shell_test_platform_view_metal.mm | 13 +++++++++---- shell/common/shell_unittests.cc | 3 ++- 7 files changed, 33 insertions(+), 21 deletions(-) diff --git a/shell/common/animator_unittests.cc b/shell/common/animator_unittests.cc index a3d814e298daa..7b04d75a13dfe 100644 --- a/shell/common/animator_unittests.cc +++ b/shell/common/animator_unittests.cc @@ -81,7 +81,8 @@ TEST_F(ShellTest, VSyncTargetTime) { [vsync_clock, &create_vsync_waiter](Shell& shell) { return ShellTestPlatformView::Create( shell, shell.GetTaskRunners(), vsync_clock, create_vsync_waiter, - ShellTestPlatformView::BackendType::kDefaultBackend, nullptr); + ShellTestPlatformView::BackendType::kDefaultBackend, nullptr, + shell.GetConcurrentWorkerTaskRunner()); }, [](Shell& shell) { return std::make_unique(shell); }); ASSERT_TRUE(DartVMRef::IsInstanceRunning()); diff --git a/shell/common/shell_test.cc b/shell/common/shell_test.cc index a85a58e15b7f5..75d79f5cc995b 100644 --- a/shell/common/shell_test.cc +++ b/shell/common/shell_test.cc @@ -352,12 +352,13 @@ std::unique_ptr ShellTest::CreateShell( shell_test_external_view_embedder, // rendering_backend // ](Shell& shell) { - return ShellTestPlatformView::Create(shell, // - shell.GetTaskRunners(), // - vsync_clock, // - create_vsync_waiter, // - rendering_backend, // - shell_test_external_view_embedder // + return ShellTestPlatformView::Create(shell, // + shell.GetTaskRunners(), // + vsync_clock, // + create_vsync_waiter, // + rendering_backend, // + shell_test_external_view_embedder, // + shell.GetConcurrentWorkerTaskRunner() // ); }; } diff --git a/shell/common/shell_test_platform_view.cc b/shell/common/shell_test_platform_view.cc index 7653b75a4d96a..f7cc88f383016 100644 --- a/shell/common/shell_test_platform_view.cc +++ b/shell/common/shell_test_platform_view.cc @@ -24,7 +24,8 @@ std::unique_ptr ShellTestPlatformView::Create( const CreateVsyncWaiter& create_vsync_waiter, BackendType backend, const std::shared_ptr& - shell_test_external_view_embedder) { + shell_test_external_view_embedder, + std::shared_ptr worker_task_runner) { // TODO(gw280): https://github.com/flutter/flutter/issues/50298 // Make this fully runtime configurable switch (backend) { @@ -45,7 +46,7 @@ std::unique_ptr ShellTestPlatformView::Create( case BackendType::kMetalBackend: return std::make_unique( delegate, task_runners, vsync_clock, create_vsync_waiter, - shell_test_external_view_embedder); + shell_test_external_view_embedder, worker_task_runner); #endif // SHELL_ENABLE_METAL default: diff --git a/shell/common/shell_test_platform_view.h b/shell/common/shell_test_platform_view.h index 08a8baf3b43d6..261ff0348274f 100644 --- a/shell/common/shell_test_platform_view.h +++ b/shell/common/shell_test_platform_view.h @@ -28,7 +28,8 @@ class ShellTestPlatformView : public PlatformView { const CreateVsyncWaiter& create_vsync_waiter, BackendType backend, const std::shared_ptr& - shell_test_external_view_embedder); + shell_test_external_view_embedder, + std::shared_ptr worker_task_runner); virtual void SimulateVSync() = 0; diff --git a/shell/common/shell_test_platform_view_metal.h b/shell/common/shell_test_platform_view_metal.h index 8dd015cd2408d..aeba2cbba806c 100644 --- a/shell/common/shell_test_platform_view_metal.h +++ b/shell/common/shell_test_platform_view_metal.h @@ -17,12 +17,14 @@ class DarwinContextMetal; class ShellTestPlatformViewMetal final : public ShellTestPlatformView, public GPUSurfaceMetalDelegate { public: - ShellTestPlatformViewMetal(PlatformView::Delegate& delegate, - const TaskRunners& task_runners, - std::shared_ptr vsync_clock, - CreateVsyncWaiter create_vsync_waiter, - std::shared_ptr - shell_test_external_view_embedder); + ShellTestPlatformViewMetal( + PlatformView::Delegate& delegate, + const TaskRunners& task_runners, + std::shared_ptr vsync_clock, + CreateVsyncWaiter create_vsync_waiter, + std::shared_ptr + shell_test_external_view_embedder, + std::shared_ptr worker_task_runner); // |ShellTestPlatformView| virtual ~ShellTestPlatformViewMetal() override; diff --git a/shell/common/shell_test_platform_view_metal.mm b/shell/common/shell_test_platform_view_metal.mm index 701bba7737a22..84659ac92d063 100644 --- a/shell/common/shell_test_platform_view_metal.mm +++ b/shell/common/shell_test_platform_view_metal.mm @@ -31,9 +31,12 @@ // non-Objective-C TUs. class DarwinContextMetal { public: - explicit DarwinContextMetal(bool impeller) + explicit DarwinContextMetal(bool impeller, + std::shared_ptr worker_task_runner) : context_(impeller ? nil : [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice]), - impeller_context_(impeller ? [[FlutterDarwinContextMetalImpeller alloc] init] : nil), + impeller_context_(impeller ? [[FlutterDarwinContextMetalImpeller alloc] + initWithTaskRunner:worker_task_runner] + : nil), offscreen_texture_(CreateOffscreenTexture( impeller ? [impeller_context_ context]->GetMTLDevice() : [context_ device])) {} @@ -67,10 +70,12 @@ GPUMTLTextureInfo offscreen_texture_info() const { const TaskRunners& task_runners, std::shared_ptr vsync_clock, CreateVsyncWaiter create_vsync_waiter, - std::shared_ptr shell_test_external_view_embedder) + std::shared_ptr shell_test_external_view_embedder, + std::shared_ptr worker_task_runner) : ShellTestPlatformView(delegate, task_runners), GPUSurfaceMetalDelegate(MTLRenderTargetType::kMTLTexture), - metal_context_(std::make_unique(GetSettings().enable_impeller)), + metal_context_( + std::make_unique(GetSettings().enable_impeller, worker_task_runner)), create_vsync_waiter_(std::move(create_vsync_waiter)), vsync_clock_(std::move(vsync_clock)), shell_test_external_view_embedder_(std::move(shell_test_external_view_embedder)) { diff --git a/shell/common/shell_unittests.cc b/shell/common/shell_unittests.cc index 2584e6cff0e12..c91530ad5b9b4 100644 --- a/shell/common/shell_unittests.cc +++ b/shell/common/shell_unittests.cc @@ -409,7 +409,8 @@ TEST_F(ShellTest, return static_cast>( std::make_unique(task_runners)); }, - ShellTestPlatformView::BackendType::kDefaultBackend, nullptr); + ShellTestPlatformView::BackendType::kDefaultBackend, nullptr, + shell.GetConcurrentWorkerTaskRunner()); }, [](Shell& shell) { return std::make_unique(shell); }); ASSERT_TRUE(ValidateShell(shell.get())); From 282193201b9cd270d5a21abeaa169550266d30d6 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 22 May 2023 10:56:51 -0700 Subject: [PATCH 08/18] ++ --- shell/common/shell_test.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/shell/common/shell_test.cc b/shell/common/shell_test.cc index 75d79f5cc995b..9680b741ebccc 100644 --- a/shell/common/shell_test.cc +++ b/shell/common/shell_test.cc @@ -352,13 +352,14 @@ std::unique_ptr ShellTest::CreateShell( shell_test_external_view_embedder, // rendering_backend // ](Shell& shell) { - return ShellTestPlatformView::Create(shell, // - shell.GetTaskRunners(), // - vsync_clock, // - create_vsync_waiter, // - rendering_backend, // - shell_test_external_view_embedder, // - shell.GetConcurrentWorkerTaskRunner() // + return ShellTestPlatformView::Create( + shell, // + shell.GetTaskRunners(), // + vsync_clock, // + create_vsync_waiter, // + rendering_backend, // + shell_test_external_view_embedder, // + shell.GetConcurrentWorkerTaskRunner() // ); }; } From b2515aff6513219600bad4fb685bd80c1426229d Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 22 May 2023 12:15:40 -0700 Subject: [PATCH 09/18] plumbing for gpu sync switch --- .../backend/metal/playground_impl_mtl.h | 2 + .../backend/metal/playground_impl_mtl.mm | 8 ++-- .../backend/metal/command_buffer_mtl.mm | 48 ++++++++++--------- impeller/renderer/backend/metal/context_mtl.h | 11 ++++- .../renderer/backend/metal/context_mtl.mm | 20 ++++++-- shell/common/animator_unittests.cc | 3 +- shell/common/shell_test.cc | 3 +- shell/common/shell_test_platform_view.cc | 6 ++- shell/common/shell_test_platform_view.h | 3 +- shell/common/shell_test_platform_view_metal.h | 3 +- .../common/shell_test_platform_view_metal.mm | 14 ++++-- shell/common/shell_unittests.cc | 3 +- .../FlutterDarwinContextMetalImpeller.h | 3 +- .../FlutterDarwinContextMetalImpeller.mm | 14 ++++-- .../ios/framework/Source/FlutterEngine.mm | 2 +- shell/platform/darwin/ios/ios_context.h | 11 +++-- shell/platform/darwin/ios/ios_context.mm | 6 ++- .../darwin/ios/ios_context_metal_impeller.h | 3 +- .../darwin/ios/ios_context_metal_impeller.mm | 7 ++- shell/platform/darwin/ios/platform_view_ios.h | 3 +- .../platform/darwin/ios/platform_view_ios.mm | 6 ++- 21 files changed, 116 insertions(+), 63 deletions(-) diff --git a/impeller/playground/backend/metal/playground_impl_mtl.h b/impeller/playground/backend/metal/playground_impl_mtl.h index aabbcdad461e7..9058dbb06c632 100644 --- a/impeller/playground/backend/metal/playground_impl_mtl.h +++ b/impeller/playground/backend/metal/playground_impl_mtl.h @@ -7,6 +7,7 @@ #include #include "flutter/fml/concurrent_message_loop.h" +#include "flutter/fml/synchronization/sync_switch.h" #include "flutter/fml/macros.h" #include "impeller/playground/playground_impl.h" @@ -29,6 +30,7 @@ class PlaygroundImplMTL final : public PlaygroundImpl { std::unique_ptr data_; std::shared_ptr context_; std::shared_ptr concurrent_loop_; + std::shared_ptr is_gpu_disabled_sync_switch_; // |PlaygroundImpl| std::shared_ptr GetContext() const override; diff --git a/impeller/playground/backend/metal/playground_impl_mtl.mm b/impeller/playground/backend/metal/playground_impl_mtl.mm index 333c712f6bfb7..25f108666ebe0 100644 --- a/impeller/playground/backend/metal/playground_impl_mtl.mm +++ b/impeller/playground/backend/metal/playground_impl_mtl.mm @@ -64,7 +64,8 @@ : PlaygroundImpl(switches), handle_(nullptr, &DestroyWindowHandle), data_(std::make_unique()), - concurrent_loop_(fml::ConcurrentMessageLoop::Create()) { + concurrent_loop_(fml::ConcurrentMessageLoop::Create()), + is_gpu_disabled_sync_switch_(new fml::SyncSwitch(false)) { ::glfwDefaultWindowHints(); ::glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); ::glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); @@ -73,8 +74,9 @@ return; } auto worker_task_runner = concurrent_loop_->GetTaskRunner(); - auto context = ContextMTL::Create(ShaderLibraryMappingsForPlayground(), - worker_task_runner, "Playground Library"); + auto context = ContextMTL::Create( + ShaderLibraryMappingsForPlayground(), worker_task_runner, + is_gpu_disabled_sync_switch_, "Playground Library"); if (!context) { return; } diff --git a/impeller/renderer/backend/metal/command_buffer_mtl.mm b/impeller/renderer/backend/metal/command_buffer_mtl.mm index 3381aa9fa8c0b..58aa6b5478148 100644 --- a/impeller/renderer/backend/metal/command_buffer_mtl.mm +++ b/impeller/renderer/backend/metal/command_buffer_mtl.mm @@ -191,7 +191,6 @@ static bool LogMTLCommandBufferErrorIfPresent(id buffer) { buffer_ = nil; auto worker_task_runner = ContextMTL::Cast(*context).GetWorkerTaskRunner(); - auto mtl_render_pass = static_cast(render_pass.get()); // Render command encoder creation has been observed to exceed the stack size @@ -203,27 +202,32 @@ static bool LogMTLCommandBufferErrorIfPresent(id buffer) { return false; } - auto task = fml::MakeCopyable( - [render_pass, buffer, render_command_encoder, weak_context = context_]() { - auto context = weak_context.lock(); - if (!context) { - return; - } - - auto mtl_render_pass = static_cast(render_pass.get()); - if (!mtl_render_pass->label_.empty()) { - [render_command_encoder setLabel:@(mtl_render_pass->label_.c_str())]; - } - - auto result = mtl_render_pass->EncodeCommands( - context->GetResourceAllocator(), render_command_encoder); - [render_command_encoder endEncoding]; - if (result) { - [buffer commit]; - } else { - VALIDATION_LOG << "Failed to encode command buffer"; - } - }); + auto task = fml::MakeCopyable([render_pass, buffer, render_command_encoder, + weak_context = context_]() { + auto context = weak_context.lock(); + if (!context) { + return; + } + auto is_gpu_disabled_sync_switch = + ContextMTL::Cast(*context).GetIsGpuDisabledSyncSwitch(); + is_gpu_disabled_sync_switch->Execute(fml::SyncSwitch::Handlers().SetIfFalse( + [&render_pass, &render_command_encoder, &buffer, &context] { + auto mtl_render_pass = static_cast(render_pass.get()); + if (!mtl_render_pass->label_.empty()) { + [render_command_encoder + setLabel:@(mtl_render_pass->label_.c_str())]; + } + + auto result = mtl_render_pass->EncodeCommands( + context->GetResourceAllocator(), render_command_encoder); + [render_command_encoder endEncoding]; + if (result) { + [buffer commit]; + } else { + VALIDATION_LOG << "Failed to encode command buffer"; + } + })); + }); worker_task_runner->PostTask(task); return true; } diff --git a/impeller/renderer/backend/metal/context_mtl.h b/impeller/renderer/backend/metal/context_mtl.h index ee41df8a53c5f..c737eb23e15af 100644 --- a/impeller/renderer/backend/metal/context_mtl.h +++ b/impeller/renderer/backend/metal/context_mtl.h @@ -11,6 +11,7 @@ #include "flutter/fml/concurrent_message_loop.h" #include "flutter/fml/macros.h" +#include "flutter/fml/synchronization/sync_switch.h" #include "impeller/base/backend_cast.h" #include "impeller/core/sampler.h" #include "impeller/renderer/backend/metal/allocator_mtl.h" @@ -28,11 +29,13 @@ class ContextMTL final : public Context, public: static std::shared_ptr Create( const std::vector& shader_library_paths, - std::shared_ptr worker_task_runner); + std::shared_ptr worker_task_runner, + std::shared_ptr is_gpu_disabled_sync_switch); static std::shared_ptr Create( const std::vector>& shader_libraries_data, std::shared_ptr worker_task_runner, + std::shared_ptr is_gpu_disabled_sync_switch, const std::string& label); // |Context| @@ -71,6 +74,8 @@ class ContextMTL final : public Context, const std::shared_ptr& GetWorkerTaskRunner() const; + std::shared_ptr GetIsGpuDisabledSyncSwitch() const; + private: id device_ = nullptr; id command_queue_ = nullptr; @@ -80,11 +85,13 @@ class ContextMTL final : public Context, std::shared_ptr resource_allocator_; std::shared_ptr device_capabilities_; std::shared_ptr worker_task_runner_; + std::shared_ptr is_gpu_disabled_sync_switch_; bool is_valid_ = false; ContextMTL(id device, NSArray>* shader_libraries, - std::shared_ptr worker_task_runner); + std::shared_ptr worker_task_runner, + std::shared_ptr is_gpu_disabled_sync_switch); std::shared_ptr CreateCommandBufferInQueue( id queue) const; diff --git a/impeller/renderer/backend/metal/context_mtl.mm b/impeller/renderer/backend/metal/context_mtl.mm index 75989ea68d695..20af3b87c7141 100644 --- a/impeller/renderer/backend/metal/context_mtl.mm +++ b/impeller/renderer/backend/metal/context_mtl.mm @@ -68,8 +68,11 @@ static bool DeviceSupportsComputeSubgroups(id device) { ContextMTL::ContextMTL( id device, NSArray>* shader_libraries, - std::shared_ptr worker_task_runner) - : device_(device), worker_task_runner_(std::move(worker_task_runner)) { + std::shared_ptr worker_task_runner, + std::shared_ptr is_gpu_disabled_sync_switch) + : device_(device), + worker_task_runner_(std::move(worker_task_runner)), + is_gpu_disabled_sync_switch_(std::move(is_gpu_disabled_sync_switch)) { // Validate device. if (!device_) { VALIDATION_LOG << "Could not setup valid Metal device."; @@ -203,11 +206,12 @@ static bool DeviceSupportsComputeSubgroups(id device) { std::shared_ptr ContextMTL::Create( const std::vector& shader_library_paths, - std::shared_ptr worker_task_runner) { + std::shared_ptr worker_task_runner, + std::shared_ptr is_gpu_disabled_sync_switch) { auto device = CreateMetalDevice(); auto context = std::shared_ptr(new ContextMTL( device, MTLShaderLibraryFromFilePaths(device, shader_library_paths), - std::move(worker_task_runner))); + std::move(worker_task_runner), std::move(is_gpu_disabled_sync_switch))); if (!context->IsValid()) { FML_LOG(ERROR) << "Could not create Metal context."; return nullptr; @@ -218,12 +222,13 @@ static bool DeviceSupportsComputeSubgroups(id device) { std::shared_ptr ContextMTL::Create( const std::vector>& shader_libraries_data, std::shared_ptr worker_task_runner, + std::shared_ptr is_gpu_disabled_sync_switch, const std::string& label) { auto device = CreateMetalDevice(); auto context = std::shared_ptr(new ContextMTL( device, MTLShaderLibraryFromFileData(device, shader_libraries_data, label), - worker_task_runner)); + worker_task_runner, std::move(is_gpu_disabled_sync_switch))); if (!context->IsValid()) { FML_LOG(ERROR) << "Could not create Metal context."; return nullptr; @@ -268,6 +273,11 @@ static bool DeviceSupportsComputeSubgroups(id device) { return worker_task_runner_; } +std::shared_ptr ContextMTL::GetIsGpuDisabledSyncSwitch() + const { + return is_gpu_disabled_sync_switch_; +} + std::shared_ptr ContextMTL::CreateCommandBufferInQueue( id queue) const { if (!IsValid()) { diff --git a/shell/common/animator_unittests.cc b/shell/common/animator_unittests.cc index 7b04d75a13dfe..cf20635b14203 100644 --- a/shell/common/animator_unittests.cc +++ b/shell/common/animator_unittests.cc @@ -82,7 +82,8 @@ TEST_F(ShellTest, VSyncTargetTime) { return ShellTestPlatformView::Create( shell, shell.GetTaskRunners(), vsync_clock, create_vsync_waiter, ShellTestPlatformView::BackendType::kDefaultBackend, nullptr, - shell.GetConcurrentWorkerTaskRunner()); + shell.GetConcurrentWorkerTaskRunner(), + shell.GetIsGpuDisabledSyncSwitch()); }, [](Shell& shell) { return std::make_unique(shell); }); ASSERT_TRUE(DartVMRef::IsInstanceRunning()); diff --git a/shell/common/shell_test.cc b/shell/common/shell_test.cc index 9680b741ebccc..28b6f2fa0b103 100644 --- a/shell/common/shell_test.cc +++ b/shell/common/shell_test.cc @@ -359,7 +359,8 @@ std::unique_ptr ShellTest::CreateShell( create_vsync_waiter, // rendering_backend, // shell_test_external_view_embedder, // - shell.GetConcurrentWorkerTaskRunner() // + shell.GetConcurrentWorkerTaskRunner(), // + shell.GetIsGpuDisabledSyncSwitch() // ); }; } diff --git a/shell/common/shell_test_platform_view.cc b/shell/common/shell_test_platform_view.cc index f7cc88f383016..ffda83f14a5bc 100644 --- a/shell/common/shell_test_platform_view.cc +++ b/shell/common/shell_test_platform_view.cc @@ -25,7 +25,8 @@ std::unique_ptr ShellTestPlatformView::Create( BackendType backend, const std::shared_ptr& shell_test_external_view_embedder, - std::shared_ptr worker_task_runner) { + std::shared_ptr worker_task_runner, + std::shared_ptr is_gpu_disabled_sync_switch) { // TODO(gw280): https://github.com/flutter/flutter/issues/50298 // Make this fully runtime configurable switch (backend) { @@ -46,7 +47,8 @@ std::unique_ptr ShellTestPlatformView::Create( case BackendType::kMetalBackend: return std::make_unique( delegate, task_runners, vsync_clock, create_vsync_waiter, - shell_test_external_view_embedder, worker_task_runner); + shell_test_external_view_embedder, std::move(worker_task_runner), + std::move(is_gpu_disabled_sync_switch)); #endif // SHELL_ENABLE_METAL default: diff --git a/shell/common/shell_test_platform_view.h b/shell/common/shell_test_platform_view.h index 261ff0348274f..7e42501890681 100644 --- a/shell/common/shell_test_platform_view.h +++ b/shell/common/shell_test_platform_view.h @@ -29,7 +29,8 @@ class ShellTestPlatformView : public PlatformView { BackendType backend, const std::shared_ptr& shell_test_external_view_embedder, - std::shared_ptr worker_task_runner); + std::shared_ptr worker_task_runner, + std::shared_ptr is_gpu_disabled_sync_switch); virtual void SimulateVSync() = 0; diff --git a/shell/common/shell_test_platform_view_metal.h b/shell/common/shell_test_platform_view_metal.h index aeba2cbba806c..0fe6db5ed511b 100644 --- a/shell/common/shell_test_platform_view_metal.h +++ b/shell/common/shell_test_platform_view_metal.h @@ -24,7 +24,8 @@ class ShellTestPlatformViewMetal final : public ShellTestPlatformView, CreateVsyncWaiter create_vsync_waiter, std::shared_ptr shell_test_external_view_embedder, - std::shared_ptr worker_task_runner); + std::shared_ptr worker_task_runner, + std::shared_ptr is_gpu_disabled_sync_switch); // |ShellTestPlatformView| virtual ~ShellTestPlatformViewMetal() override; diff --git a/shell/common/shell_test_platform_view_metal.mm b/shell/common/shell_test_platform_view_metal.mm index 84659ac92d063..2a62781833bfb 100644 --- a/shell/common/shell_test_platform_view_metal.mm +++ b/shell/common/shell_test_platform_view_metal.mm @@ -32,10 +32,12 @@ class DarwinContextMetal { public: explicit DarwinContextMetal(bool impeller, - std::shared_ptr worker_task_runner) + std::shared_ptr worker_task_runner, + std::shared_ptr is_gpu_disabled_sync_switch) : context_(impeller ? nil : [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice]), impeller_context_(impeller ? [[FlutterDarwinContextMetalImpeller alloc] - initWithTaskRunner:worker_task_runner] + initWithTaskRunner:worker_task_runner + is_gpu_disabled_sync_switch:is_gpu_disabled_sync_switch] : nil), offscreen_texture_(CreateOffscreenTexture( impeller ? [impeller_context_ context]->GetMTLDevice() : [context_ device])) {} @@ -71,11 +73,13 @@ GPUMTLTextureInfo offscreen_texture_info() const { std::shared_ptr vsync_clock, CreateVsyncWaiter create_vsync_waiter, std::shared_ptr shell_test_external_view_embedder, - std::shared_ptr worker_task_runner) + std::shared_ptr worker_task_runner, + std::shared_ptr is_gpu_disabled_sync_switch) : ShellTestPlatformView(delegate, task_runners), GPUSurfaceMetalDelegate(MTLRenderTargetType::kMTLTexture), - metal_context_( - std::make_unique(GetSettings().enable_impeller, worker_task_runner)), + metal_context_(std::make_unique(GetSettings().enable_impeller, + worker_task_runner, + is_gpu_disabled_sync_switch)), create_vsync_waiter_(std::move(create_vsync_waiter)), vsync_clock_(std::move(vsync_clock)), shell_test_external_view_embedder_(std::move(shell_test_external_view_embedder)) { diff --git a/shell/common/shell_unittests.cc b/shell/common/shell_unittests.cc index c91530ad5b9b4..2edc3b173d82b 100644 --- a/shell/common/shell_unittests.cc +++ b/shell/common/shell_unittests.cc @@ -410,7 +410,8 @@ TEST_F(ShellTest, std::make_unique(task_runners)); }, ShellTestPlatformView::BackendType::kDefaultBackend, nullptr, - shell.GetConcurrentWorkerTaskRunner()); + shell.GetConcurrentWorkerTaskRunner(), + shell.GetIsGpuDisabledSyncSwitch()); }, [](Shell& shell) { return std::make_unique(shell); }); ASSERT_TRUE(ValidateShell(shell.get())); diff --git a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h index b6781aea21b8f..c6dcb143b9e2b 100644 --- a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h +++ b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h @@ -25,7 +25,8 @@ NS_ASSUME_NONNULL_BEGIN /** * Initializes a FlutterDarwinContextMetalImpeller. */ -- (instancetype)initWithTaskRunner:(std::shared_ptr)task_runner; +- (instancetype)initWithTaskRunner:(std::shared_ptr)task_runner + is_gpu_disabled_sync_switch:(std::shared_ptr)is_gpu_disabled_sync_switch; /** * Creates an external texture with the specified ID and contents. diff --git a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm index 13bbff8c1d915..55230f30812cb 100644 --- a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm +++ b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm @@ -17,7 +17,8 @@ FLUTTER_ASSERT_ARC static std::shared_ptr CreateImpellerContext( - std::shared_ptr worker_task_runner) { + std::shared_ptr worker_task_runner, + std::shared_ptr is_gpu_disabled_sync_switch) { std::vector> shader_mappings = { std::make_shared(impeller_entity_shaders_data, impeller_entity_shaders_length), @@ -28,8 +29,9 @@ std::make_shared(impeller_framebuffer_blend_shaders_data, impeller_framebuffer_blend_shaders_length), }; - auto context = impeller::ContextMTL::Create(shader_mappings, std::move(worker_task_runner), - "Impeller Library"); + auto context = + impeller::ContextMTL::Create(shader_mappings, std::move(worker_task_runner), + std::move(is_gpu_disabled_sync_switch), "Impeller Library"); if (!context) { FML_LOG(ERROR) << "Could not create Metal Impeller Context."; return nullptr; @@ -41,10 +43,12 @@ @implementation FlutterDarwinContextMetalImpeller -- (instancetype)initWithTaskRunner:(std::shared_ptr)task_runner { +- (instancetype)initWithTaskRunner:(std::shared_ptr)task_runner + is_gpu_disabled_sync_switch:(std::shared_ptr)is_gpu_disabled_sync_switch { self = [super init]; if (self != nil) { - _context = CreateImpellerContext(std::move(task_runner)); + _context = + CreateImpellerContext(std::move(task_runner), std::move(is_gpu_disabled_sync_switch)); id device = _context->GetMTLDevice(); if (!device) { FML_DLOG(ERROR) << "Could not acquire Metal device."; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index c9e6b4a206d33..d8adc04c78abd 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm @@ -837,7 +837,7 @@ - (BOOL)createShell:(NSString*)entrypoint [self recreatePlatformViewController]; return std::make_unique( shell, self->_renderingApi, self->_platformViewsController, shell.GetTaskRunners(), - shell.GetConcurrentWorkerTaskRunner()); + shell.GetConcurrentWorkerTaskRunner(), shell.GetIsGpuDisabledSyncSwitch()); }; flutter::Shell::CreateCallback on_create_rasterizer = diff --git a/shell/platform/darwin/ios/ios_context.h b/shell/platform/darwin/ios/ios_context.h index 792d818c6b147..1ddae78afee18 100644 --- a/shell/platform/darwin/ios/ios_context.h +++ b/shell/platform/darwin/ios/ios_context.h @@ -11,6 +11,7 @@ #include "flutter/common/graphics/msaa_sample_count.h" #include "flutter/common/graphics/texture.h" #include "flutter/fml/concurrent_message_loop.h" +#include "flutter/fml/synchronization/sync_switch.h" #include "flutter/fml/macros.h" #include "flutter/fml/platform/darwin/scoped_nsobject.h" #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterTexture.h" @@ -57,10 +58,12 @@ class IOSContext { /// /// @return A valid context on success. `nullptr` on failure. /// - static std::unique_ptr Create(IOSRenderingAPI api, - IOSRenderingBackend backend, - MsaaSampleCount msaa_samples, - std::shared_ptr task_runner); + static std::unique_ptr Create( + IOSRenderingAPI api, + IOSRenderingBackend backend, + MsaaSampleCount msaa_samples, + std::shared_ptr task_runner, + std::shared_ptr is_gpu_disabled_sync_switch); //---------------------------------------------------------------------------- /// @brief Collects the context object. This must happen on the thread on diff --git a/shell/platform/darwin/ios/ios_context.mm b/shell/platform/darwin/ios/ios_context.mm index 82e01b619c1ab..fba7071f6d65f 100644 --- a/shell/platform/darwin/ios/ios_context.mm +++ b/shell/platform/darwin/ios/ios_context.mm @@ -22,7 +22,8 @@ IOSRenderingAPI api, IOSRenderingBackend backend, MsaaSampleCount msaa_samples, - std::shared_ptr task_runner) { + std::shared_ptr task_runner, + std::shared_ptr is_gpu_disabled_sync_switch) { switch (api) { case IOSRenderingAPI::kSoftware: return std::make_unique(); @@ -32,7 +33,8 @@ case IOSRenderingBackend::kSkia: return std::make_unique(msaa_samples); case IOSRenderingBackend::kImpeller: - return std::make_unique(std::move(task_runner)); + return std::make_unique(std::move(task_runner), + std::move(is_gpu_disabled_sync_switch)); } #endif // SHELL_ENABLE_METAL default: diff --git a/shell/platform/darwin/ios/ios_context_metal_impeller.h b/shell/platform/darwin/ios/ios_context_metal_impeller.h index d225d66d8afbd..10136218291fd 100644 --- a/shell/platform/darwin/ios/ios_context_metal_impeller.h +++ b/shell/platform/darwin/ios/ios_context_metal_impeller.h @@ -20,7 +20,8 @@ namespace flutter { class IOSContextMetalImpeller final : public IOSContext { public: - IOSContextMetalImpeller(std::shared_ptr task_runner); + IOSContextMetalImpeller(std::shared_ptr task_runner, + std::shared_ptr is_gpu_disabled_sync_switch); ~IOSContextMetalImpeller(); diff --git a/shell/platform/darwin/ios/ios_context_metal_impeller.mm b/shell/platform/darwin/ios/ios_context_metal_impeller.mm index d6377e523236b..17385c5819e87 100644 --- a/shell/platform/darwin/ios/ios_context_metal_impeller.mm +++ b/shell/platform/darwin/ios/ios_context_metal_impeller.mm @@ -9,10 +9,13 @@ namespace flutter { IOSContextMetalImpeller::IOSContextMetalImpeller( - std::shared_ptr task_runner) + std::shared_ptr task_runner, + std::shared_ptr is_gpu_disabled_sync_switch) : IOSContext(MsaaSampleCount::kFour), darwin_context_metal_impeller_(fml::scoped_nsobject{ - [[FlutterDarwinContextMetalImpeller alloc] initWithTaskRunner:task_runner]}) {} + [[FlutterDarwinContextMetalImpeller alloc] + initWithTaskRunner:task_runner + is_gpu_disabled_sync_switch:is_gpu_disabled_sync_switch]}) {} IOSContextMetalImpeller::~IOSContextMetalImpeller() = default; diff --git a/shell/platform/darwin/ios/platform_view_ios.h b/shell/platform/darwin/ios/platform_view_ios.h index ffe2675e5db1b..fa48ce8ee309b 100644 --- a/shell/platform/darwin/ios/platform_view_ios.h +++ b/shell/platform/darwin/ios/platform_view_ios.h @@ -50,7 +50,8 @@ class PlatformViewIOS final : public PlatformView { IOSRenderingAPI rendering_api, const std::shared_ptr& platform_views_controller, const flutter::TaskRunners& task_runners, - const std::shared_ptr& worker_task_runner); + const std::shared_ptr& worker_task_runner, + std::shared_ptr is_gpu_disabled_sync_switch); ~PlatformViewIOS() override; diff --git a/shell/platform/darwin/ios/platform_view_ios.mm b/shell/platform/darwin/ios/platform_view_ios.mm index 0f0fab4978815..4622d0652ae1f 100644 --- a/shell/platform/darwin/ios/platform_view_ios.mm +++ b/shell/platform/darwin/ios/platform_view_ios.mm @@ -56,7 +56,8 @@ new PlatformMessageHandlerIos(task_runners.GetPlatformTaskRunner())) {} IOSRenderingAPI rendering_api, const std::shared_ptr& platform_views_controller, const flutter::TaskRunners& task_runners, - const std::shared_ptr& worker_task_runner) + const std::shared_ptr& worker_task_runner, + std::shared_ptr is_gpu_disabled_sync_switch) : PlatformViewIOS( delegate, IOSContext::Create( @@ -64,7 +65,8 @@ new PlatformMessageHandlerIos(task_runners.GetPlatformTaskRunner())) {} delegate.OnPlatformViewGetSettings().enable_impeller ? IOSRenderingBackend::kImpeller : IOSRenderingBackend::kSkia, static_cast(delegate.OnPlatformViewGetSettings().msaa_samples), - worker_task_runner), + worker_task_runner, + is_gpu_disabled_sync_switch), platform_views_controller, task_runners) {} From 83b0b9009d61a822b35a97e0eb39a6ab7cf2b275 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 22 May 2023 12:17:29 -0700 Subject: [PATCH 10/18] ++ --- .../backend/metal/playground_impl_mtl.h | 2 +- impeller/renderer/backend/metal/context_mtl.h | 9 +++++---- shell/common/shell_test.cc | 16 ++++++++-------- .../graphics/FlutterDarwinContextMetalImpeller.h | 3 ++- .../FlutterDarwinContextMetalImpeller.mm | 3 ++- shell/platform/darwin/ios/ios_context.h | 2 +- 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/impeller/playground/backend/metal/playground_impl_mtl.h b/impeller/playground/backend/metal/playground_impl_mtl.h index 9058dbb06c632..71e2c6607a72b 100644 --- a/impeller/playground/backend/metal/playground_impl_mtl.h +++ b/impeller/playground/backend/metal/playground_impl_mtl.h @@ -7,8 +7,8 @@ #include #include "flutter/fml/concurrent_message_loop.h" -#include "flutter/fml/synchronization/sync_switch.h" #include "flutter/fml/macros.h" +#include "flutter/fml/synchronization/sync_switch.h" #include "impeller/playground/playground_impl.h" namespace impeller { diff --git a/impeller/renderer/backend/metal/context_mtl.h b/impeller/renderer/backend/metal/context_mtl.h index c737eb23e15af..fe461601daf06 100644 --- a/impeller/renderer/backend/metal/context_mtl.h +++ b/impeller/renderer/backend/metal/context_mtl.h @@ -88,10 +88,11 @@ class ContextMTL final : public Context, std::shared_ptr is_gpu_disabled_sync_switch_; bool is_valid_ = false; - ContextMTL(id device, - NSArray>* shader_libraries, - std::shared_ptr worker_task_runner, - std::shared_ptr is_gpu_disabled_sync_switch); + ContextMTL( + id device, + NSArray>* shader_libraries, + std::shared_ptr worker_task_runner, + std::shared_ptr is_gpu_disabled_sync_switch); std::shared_ptr CreateCommandBufferInQueue( id queue) const; diff --git a/shell/common/shell_test.cc b/shell/common/shell_test.cc index 28b6f2fa0b103..8be076930b11b 100644 --- a/shell/common/shell_test.cc +++ b/shell/common/shell_test.cc @@ -353,14 +353,14 @@ std::unique_ptr ShellTest::CreateShell( rendering_backend // ](Shell& shell) { return ShellTestPlatformView::Create( - shell, // - shell.GetTaskRunners(), // - vsync_clock, // - create_vsync_waiter, // - rendering_backend, // - shell_test_external_view_embedder, // - shell.GetConcurrentWorkerTaskRunner(), // - shell.GetIsGpuDisabledSyncSwitch() // + shell, // + shell.GetTaskRunners(), // + vsync_clock, // + create_vsync_waiter, // + rendering_backend, // + shell_test_external_view_embedder, // + shell.GetConcurrentWorkerTaskRunner(), // + shell.GetIsGpuDisabledSyncSwitch() // ); }; } diff --git a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h index c6dcb143b9e2b..4a09c6d50e0d6 100644 --- a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h +++ b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h @@ -26,7 +26,8 @@ NS_ASSUME_NONNULL_BEGIN * Initializes a FlutterDarwinContextMetalImpeller. */ - (instancetype)initWithTaskRunner:(std::shared_ptr)task_runner - is_gpu_disabled_sync_switch:(std::shared_ptr)is_gpu_disabled_sync_switch; + is_gpu_disabled_sync_switch: + (std::shared_ptr)is_gpu_disabled_sync_switch; /** * Creates an external texture with the specified ID and contents. diff --git a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm index 55230f30812cb..34cc332233cd0 100644 --- a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm +++ b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm @@ -44,7 +44,8 @@ @implementation FlutterDarwinContextMetalImpeller - (instancetype)initWithTaskRunner:(std::shared_ptr)task_runner - is_gpu_disabled_sync_switch:(std::shared_ptr)is_gpu_disabled_sync_switch { + is_gpu_disabled_sync_switch: + (std::shared_ptr)is_gpu_disabled_sync_switch { self = [super init]; if (self != nil) { _context = diff --git a/shell/platform/darwin/ios/ios_context.h b/shell/platform/darwin/ios/ios_context.h index 1ddae78afee18..35065675750b3 100644 --- a/shell/platform/darwin/ios/ios_context.h +++ b/shell/platform/darwin/ios/ios_context.h @@ -11,9 +11,9 @@ #include "flutter/common/graphics/msaa_sample_count.h" #include "flutter/common/graphics/texture.h" #include "flutter/fml/concurrent_message_loop.h" -#include "flutter/fml/synchronization/sync_switch.h" #include "flutter/fml/macros.h" #include "flutter/fml/platform/darwin/scoped_nsobject.h" +#include "flutter/fml/synchronization/sync_switch.h" #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterTexture.h" #import "flutter/shell/platform/darwin/ios/rendering_api_selection.h" #include "third_party/skia/include/gpu/GrDirectContext.h" From 1aed38692ef0f70733d5afbea95ee0513fa3aa6c Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 22 May 2023 12:45:17 -0700 Subject: [PATCH 11/18] update a11y bridge test --- .../Source/accessibility_bridge_test.mm | 120 +++++++++++++----- 1 file changed, 90 insertions(+), 30 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm b/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm index 1965d89ac705c..c51d490bc1199 100644 --- a/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm +++ b/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm @@ -149,7 +149,9 @@ - (void)testCreate { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); auto bridge = std::make_unique(/*view=*/nil, /*platform_view=*/platform_view.get(), @@ -169,7 +171,9 @@ - (void)testUpdateSemanticsEmpty { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); OCMStub([mockFlutterViewController viewIfLoaded]).andReturn(mockFlutterView); @@ -196,7 +200,9 @@ - (void)testUpdateSemanticsOneNode { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -241,7 +247,9 @@ - (void)testIsVoiceOverRunning { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -271,7 +279,9 @@ - (void)testSemanticsDeallocated { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -328,7 +338,9 @@ - (void)testSemanticsDeallocatedWithoutLoadingView { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); MockFlutterPlatformFactory* factory = [[MockFlutterPlatformFactory new] autorelease]; flutterPlatformViewsController->RegisterViewFactory( @@ -371,7 +383,9 @@ - (void)testReplacedSemanticsDoesNotCleanupChildren { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id engine = OCMClassMock([FlutterEngine class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); FlutterView* flutterView = [[FlutterView alloc] initWithDelegate:engine @@ -463,7 +477,9 @@ - (void)testScrollableSemanticsDeallocated { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id engine = OCMClassMock([FlutterEngine class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); FlutterView* flutterView = [[FlutterView alloc] initWithDelegate:engine @@ -533,7 +549,9 @@ - (void)testBridgeReplacesSemanticsNode { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id engine = OCMClassMock([FlutterEngine class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); FlutterView* flutterView = [[FlutterView alloc] initWithDelegate:engine @@ -603,7 +621,9 @@ - (void)testAnnouncesRouteChanges { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -669,7 +689,9 @@ - (void)testRadioButtonIsNotSwitchButton { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id engine = OCMClassMock([FlutterEngine class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); FlutterView* flutterView = [[FlutterView alloc] initWithDelegate:engine @@ -714,7 +736,9 @@ - (void)testLayoutChangeWithNonAccessibilityElement { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -796,7 +820,9 @@ - (void)testLayoutChangeDoesCallNativeAccessibility { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -869,7 +895,9 @@ - (void)testLayoutChangeDoesCallNativeAccessibilityWhenFocusChanged { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -941,7 +969,9 @@ - (void)testScrollableSemanticsContainerReturnsCorrectChildren { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -996,7 +1026,9 @@ - (void)testAnnouncesRouteChangesAndLayoutChangeInOneUpdate { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -1091,7 +1123,9 @@ - (void)testAnnouncesRouteChangesWhenAddAdditionalRoute { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -1175,7 +1209,9 @@ - (void)testAnnouncesRouteChangesRemoveRouteInMiddle { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -1265,7 +1301,9 @@ - (void)testAnnouncesRouteChangesWhenNoNamesRoute { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -1333,7 +1371,9 @@ - (void)testAnnouncesLayoutChangeWithNilIfLastFocusIsRemoved { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); id mockFlutterView = OCMClassMock([FlutterView class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -1400,7 +1440,9 @@ - (void)testAnnouncesLayoutChangeWithTheSameItemFocused { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); id mockFlutterView = OCMClassMock([FlutterView class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -1473,7 +1515,9 @@ - (void)testAnnouncesLayoutChangeWhenFocusMovedOutside { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); id mockFlutterView = OCMClassMock([FlutterView class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -1548,7 +1592,9 @@ - (void)testAnnouncesScrollChangeWithLastFocused { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); id mockFlutterView = OCMClassMock([FlutterView class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -1619,7 +1665,9 @@ - (void)testAnnouncesScrollChangeDoesCallNativeAccessibility { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); id mockFlutterView = OCMClassMock([FlutterView class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -1692,7 +1740,9 @@ - (void)testAnnouncesIgnoresRouteChangesWhenModal { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -1747,7 +1797,9 @@ - (void)testAnnouncesIgnoresLayoutChangeWhenModal { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -1807,7 +1859,9 @@ - (void)testAnnouncesIgnoresScrollChangeWhenModal { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runner, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -1875,7 +1929,9 @@ - (void)testAccessibilityMessageAfterDeletion { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); fml::AutoResetWaitableEvent latch; thread_task_runner->PostTask([&] { auto weakFactory = @@ -1908,7 +1964,9 @@ - (void)testFlutterSemanticsScrollViewManagedObjectLifecycleCorrectly { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); @@ -1956,7 +2014,9 @@ - (void)testPlatformViewDestructorDoesNotCallSemanticsAPIs { /*delegate=*/test_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); auto flutterPlatformViewsController = From 5198c2cbb81c9a1286b46b941f5078f35473c5ab Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 22 May 2023 12:59:19 -0700 Subject: [PATCH 12/18] ++ --- .../darwin/ios/framework/Source/accessibility_bridge_test.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm b/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm index c51d490bc1199..c617284489e73 100644 --- a/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm +++ b/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm @@ -1859,7 +1859,7 @@ - (void)testAnnouncesIgnoresScrollChangeWhenModal { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runner, + /*task_runners=*/runners, /*worker_task_runner=*/nil, /*is_gpu_disabled_sync_switch=*/nil); id mockFlutterView = OCMClassMock([FlutterView class]); From 56c1687672619f2242a7112a4c14cc2ef8852478 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 22 May 2023 13:32:39 -0700 Subject: [PATCH 13/18] ++ --- shell/common/shell_test_platform_view.cc | 8 +- .../Source/FlutterPlatformViewsTest.mm | 120 +++++++++++++----- 2 files changed, 94 insertions(+), 34 deletions(-) diff --git a/shell/common/shell_test_platform_view.cc b/shell/common/shell_test_platform_view.cc index ffda83f14a5bc..a683d372d8d0a 100644 --- a/shell/common/shell_test_platform_view.cc +++ b/shell/common/shell_test_platform_view.cc @@ -25,8 +25,8 @@ std::unique_ptr ShellTestPlatformView::Create( BackendType backend, const std::shared_ptr& shell_test_external_view_embedder, - std::shared_ptr worker_task_runner, - std::shared_ptr is_gpu_disabled_sync_switch) { + const std::shared_ptr& worker_task_runner, + const std::shared_ptr& is_gpu_disabled_sync_switch) { // TODO(gw280): https://github.com/flutter/flutter/issues/50298 // Make this fully runtime configurable switch (backend) { @@ -47,8 +47,8 @@ std::unique_ptr ShellTestPlatformView::Create( case BackendType::kMetalBackend: return std::make_unique( delegate, task_runners, vsync_clock, create_vsync_waiter, - shell_test_external_view_embedder, std::move(worker_task_runner), - std::move(is_gpu_disabled_sync_switch)); + shell_test_external_view_embedder, worker_task_runner, + is_gpu_disabled_sync_switch); #endif // SHELL_ENABLE_METAL default: diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm index fd656a9d1767f..75f62214897d9 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm @@ -150,7 +150,9 @@ - (void)testFlutterViewOnlyCreateOnceInOneFrame { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -204,7 +206,9 @@ - (void)testCanCreatePlatformViewWithoutFlutterView { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -256,7 +260,9 @@ - (void)testApplyBackdropFilter { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -326,7 +332,9 @@ - (void)testApplyBackdropFilterWithCorrectFrame { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -396,7 +404,9 @@ - (void)testApplyMultipleBackdropFilters { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -467,7 +477,9 @@ - (void)testAddBackdropFilters { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -578,7 +590,9 @@ - (void)testRemoveBackdropFilters { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -713,7 +727,9 @@ - (void)testEditBackdropFilters { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -988,7 +1004,9 @@ - (void)testApplyBackdropFilterNotDlBlurImageFilter { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -1286,7 +1304,9 @@ - (void)testCompositePlatformView { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -1340,7 +1360,9 @@ - (void)testBackdropFilterCorrectlyPushedAndReset { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -1432,7 +1454,9 @@ - (void)testChildClippingViewShouldBeTheBoundingRectOfPlatformView { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -1501,7 +1525,9 @@ - (void)testClipsDoNotInterceptWithPlatformViewShouldNotAddMaskView { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -1566,7 +1592,9 @@ - (void)testClipRRectOnlyHasCornersInterceptWithPlatformViewShouldAddMaskView { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -1630,7 +1658,9 @@ - (void)testClipRect { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -1701,7 +1731,9 @@ - (void)testClipRRect { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -1772,7 +1804,9 @@ - (void)testClipPath { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -1844,7 +1878,9 @@ - (void)testSetFlutterViewControllerAfterCreateCanStillDispatchTouchEvents { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -1906,7 +1942,9 @@ - (void)testSetFlutterViewControllerInTheMiddleOfTouchEventShouldStillAllowGestu /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -2025,7 +2063,9 @@ - (void)testSetFlutterViewControllerInTheMiddleOfTouchEventShouldStillAllowGestu /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -2134,7 +2174,9 @@ - (void)testFlutterPlatformViewTouchesCancelledEventAreForcedToBeCancelled { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -2194,7 +2236,9 @@ - (void)testFlutterPlatformViewControllerSubmitFrameWithoutFlutterViewNotCrashin /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -2254,7 +2298,9 @@ - (void)testFlutterPlatformViewControllerSubmitFrameWithoutFlutterViewNotCrashin /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)] autorelease]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); @@ -2302,7 +2348,9 @@ - (void)testFlutterPlatformViewControllerBeginFrameShouldResetCompisitionOrder { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)] autorelease]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); @@ -2356,7 +2404,9 @@ - (void)testFlutterPlatformViewControllerBeginFrameShouldResetCompisitionOrder { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)] autorelease]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); @@ -2452,7 +2502,9 @@ - (void)testFlutterPlatformViewControllerBeginFrameShouldResetCompisitionOrder { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)] autorelease]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); @@ -2548,7 +2600,9 @@ - (void)testThreadMergeAtEndFrame { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)] autorelease]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); @@ -2696,7 +2750,9 @@ - (void)testClipMaskViewIsReused { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -2803,7 +2859,9 @@ - (void)testDisposingViewInCompositionOrderDoNotCrash { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)] autorelease]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); @@ -2909,7 +2967,9 @@ - (void)testOnlyPlatformViewsAreRemovedWhenReset { /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; From 929f0bcf08fc826d70aae461892458b699398247 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 22 May 2023 13:47:03 -0700 Subject: [PATCH 14/18] ++ --- shell/common/shell_test_platform_view.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shell/common/shell_test_platform_view.h b/shell/common/shell_test_platform_view.h index 7e42501890681..ebb96c87dd23e 100644 --- a/shell/common/shell_test_platform_view.h +++ b/shell/common/shell_test_platform_view.h @@ -29,8 +29,9 @@ class ShellTestPlatformView : public PlatformView { BackendType backend, const std::shared_ptr& shell_test_external_view_embedder, - std::shared_ptr worker_task_runner, - std::shared_ptr is_gpu_disabled_sync_switch); + const std::shared_ptr& worker_task_runner, + const std::shared_ptr& + is_gpu_disabled_sync_switch); virtual void SimulateVSync() = 0; From b84386295e4053c40f4a42865deed752ac195c58 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 22 May 2023 15:06:44 -0700 Subject: [PATCH 15/18] ++ --- .../ios/framework/Source/FlutterEnginePlatformViewTest.mm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm index e34a4ffc05af4..e4341a065c2af 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm @@ -74,7 +74,9 @@ - (void)setUp { /*delegate=*/fake_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); weak_factory = std::make_unique>(platform_view.get()); } @@ -105,7 +107,9 @@ - (void)testMsaaSampleCount { /*delegate=*/fake_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kMetal, /*platform_views_controller=*/nil, - /*task_runners=*/runners); + /*task_runners=*/runners, + /*worker_task_runner=*/nil, + /*is_gpu_disabled_sync_switch=*/nil); XCTAssertEqual(msaa_4x_platform_view->GetIosContext()->GetMsaaSampleCount(), MsaaSampleCount::kFour); From 967063901b6e613929efabc9cb1c0306225b01e5 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 22 May 2023 22:24:31 -0700 Subject: [PATCH 16/18] ++ --- shell/platform/darwin/ios/ios_context_metal_impeller.mm | 4 ++-- shell/platform/darwin/ios/platform_view_ios.mm | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/platform/darwin/ios/ios_context_metal_impeller.mm b/shell/platform/darwin/ios/ios_context_metal_impeller.mm index 17385c5819e87..75f3a531fcd69 100644 --- a/shell/platform/darwin/ios/ios_context_metal_impeller.mm +++ b/shell/platform/darwin/ios/ios_context_metal_impeller.mm @@ -14,8 +14,8 @@ : IOSContext(MsaaSampleCount::kFour), darwin_context_metal_impeller_(fml::scoped_nsobject{ [[FlutterDarwinContextMetalImpeller alloc] - initWithTaskRunner:task_runner - is_gpu_disabled_sync_switch:is_gpu_disabled_sync_switch]}) {} + initWithTaskRunner:std::move(task_runner) + is_gpu_disabled_sync_switch:std::move(is_gpu_disabled_sync_switch)]}) {} IOSContextMetalImpeller::~IOSContextMetalImpeller() = default; diff --git a/shell/platform/darwin/ios/platform_view_ios.mm b/shell/platform/darwin/ios/platform_view_ios.mm index 4622d0652ae1f..61095c81d71a9 100644 --- a/shell/platform/darwin/ios/platform_view_ios.mm +++ b/shell/platform/darwin/ios/platform_view_ios.mm @@ -66,7 +66,7 @@ new PlatformMessageHandlerIos(task_runners.GetPlatformTaskRunner())) {} : IOSRenderingBackend::kSkia, static_cast(delegate.OnPlatformViewGetSettings().msaa_samples), worker_task_runner, - is_gpu_disabled_sync_switch), + std::move(is_gpu_disabled_sync_switch)), platform_views_controller, task_runners) {} From 9d1a0cc76147c019208cbc9ff60d9fbb6285615e Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Tue, 23 May 2023 08:46:36 -0700 Subject: [PATCH 17/18] ++ --- shell/common/shell_test_platform_view_metal.mm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/shell/common/shell_test_platform_view_metal.mm b/shell/common/shell_test_platform_view_metal.mm index 2a62781833bfb..598ecd5f87557 100644 --- a/shell/common/shell_test_platform_view_metal.mm +++ b/shell/common/shell_test_platform_view_metal.mm @@ -35,10 +35,11 @@ explicit DarwinContextMetal(bool impeller, std::shared_ptr worker_task_runner, std::shared_ptr is_gpu_disabled_sync_switch) : context_(impeller ? nil : [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice]), - impeller_context_(impeller ? [[FlutterDarwinContextMetalImpeller alloc] - initWithTaskRunner:worker_task_runner - is_gpu_disabled_sync_switch:is_gpu_disabled_sync_switch] - : nil), + impeller_context_( + impeller ? [[FlutterDarwinContextMetalImpeller alloc] + initWithTaskRunner:std::move(worker_task_runner) + is_gpu_disabled_sync_switch:std::move(is_gpu_disabled_sync_switch)] + : nil), offscreen_texture_(CreateOffscreenTexture( impeller ? [impeller_context_ context]->GetMTLDevice() : [context_ device])) {} @@ -73,8 +74,8 @@ GPUMTLTextureInfo offscreen_texture_info() const { std::shared_ptr vsync_clock, CreateVsyncWaiter create_vsync_waiter, std::shared_ptr shell_test_external_view_embedder, - std::shared_ptr worker_task_runner, - std::shared_ptr is_gpu_disabled_sync_switch) + const std::shared_ptr& worker_task_runner, + const std::shared_ptr& is_gpu_disabled_sync_switch) : ShellTestPlatformView(delegate, task_runners), GPUSurfaceMetalDelegate(MTLRenderTargetType::kMTLTexture), metal_context_(std::make_unique(GetSettings().enable_impeller, From ff058f828c27f68c8cbbcb4c70915273d4fa4ce0 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Tue, 23 May 2023 11:17:45 -0700 Subject: [PATCH 18/18] ++ --- shell/common/shell_test_platform_view_metal.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shell/common/shell_test_platform_view_metal.h b/shell/common/shell_test_platform_view_metal.h index 0fe6db5ed511b..a20b9c5f3f929 100644 --- a/shell/common/shell_test_platform_view_metal.h +++ b/shell/common/shell_test_platform_view_metal.h @@ -24,8 +24,9 @@ class ShellTestPlatformViewMetal final : public ShellTestPlatformView, CreateVsyncWaiter create_vsync_waiter, std::shared_ptr shell_test_external_view_embedder, - std::shared_ptr worker_task_runner, - std::shared_ptr is_gpu_disabled_sync_switch); + const std::shared_ptr& worker_task_runner, + const std::shared_ptr& + is_gpu_disabled_sync_switch); // |ShellTestPlatformView| virtual ~ShellTestPlatformViewMetal() override;