diff --git a/engine/src/flutter/lib/ui/painting/image_decoder.h b/engine/src/flutter/lib/ui/painting/image_decoder.h index e5f2fba6df..74a1ed0a05 100644 --- a/engine/src/flutter/lib/ui/painting/image_decoder.h +++ b/engine/src/flutter/lib/ui/painting/image_decoder.h @@ -57,7 +57,6 @@ class ImageDecoder { std::shared_ptr concurrent_task_runner_; fml::WeakPtr io_manager_; fml::WeakPtrFactory weak_factory_; - FML_DISALLOW_COPY_AND_ASSIGN(ImageDecoder); }; diff --git a/engine/src/flutter/shell/common/engine.h b/engine/src/flutter/shell/common/engine.h index ca73c59143..0b935ba703 100644 --- a/engine/src/flutter/shell/common/engine.h +++ b/engine/src/flutter/shell/common/engine.h @@ -910,29 +910,6 @@ class Engine final : public RuntimeDelegate, PointerDataDispatcher::Delegate { } private: - Engine::Delegate& delegate_; - const Settings settings_; - std::unique_ptr animator_; - std::unique_ptr runtime_controller_; - - // The pointer_data_dispatcher_ depends on animator_ and runtime_controller_. - // So it should be defined after them to ensure that pointer_data_dispatcher_ - // is destructed first. - std::unique_ptr pointer_data_dispatcher_; - - std::string last_entry_point_; - std::string last_entry_point_library_; - std::string initial_route_; - ViewportMetrics viewport_metrics_; - std::shared_ptr asset_manager_; - bool activity_running_; - bool have_surface_; - std::shared_ptr font_collection_; - ImageDecoder image_decoder_; - ImageGeneratorRegistry image_generator_registry_; - TaskRunners task_runners_; - fml::WeakPtrFactory weak_factory_; - // |RuntimeDelegate| std::string DefaultRouteName() override; @@ -981,6 +958,28 @@ class Engine final : public RuntimeDelegate, PointerDataDispatcher::Delegate { friend class testing::ShellTest; + Engine::Delegate& delegate_; + const Settings settings_; + std::unique_ptr animator_; + std::unique_ptr runtime_controller_; + + // The pointer_data_dispatcher_ depends on animator_ and runtime_controller_. + // So it should be defined after them to ensure that pointer_data_dispatcher_ + // is destructed first. + std::unique_ptr pointer_data_dispatcher_; + + std::string last_entry_point_; + std::string last_entry_point_library_; + std::string initial_route_; + ViewportMetrics viewport_metrics_; + std::shared_ptr asset_manager_; + bool activity_running_; + bool have_surface_; + std::shared_ptr font_collection_; + ImageDecoder image_decoder_; + ImageGeneratorRegistry image_generator_registry_; + TaskRunners task_runners_; + fml::WeakPtrFactory weak_factory_; // Must be the last member. FML_DISALLOW_COPY_AND_ASSIGN(Engine); }; diff --git a/engine/src/flutter/shell/common/platform_view.h b/engine/src/flutter/shell/common/platform_view.h index b6555f6c11..83c99a93c0 100644 --- a/engine/src/flutter/shell/common/platform_view.h +++ b/engine/src/flutter/shell/common/platform_view.h @@ -823,16 +823,15 @@ class PlatformView { const; protected: - PlatformView::Delegate& delegate_; - const TaskRunners task_runners_; - - PointerDataPacketConverter pointer_data_packet_converter_; - SkISize size_; - fml::WeakPtrFactory weak_factory_; - // This is the only method called on the raster task runner. virtual std::unique_ptr CreateRenderingSurface(); + PlatformView::Delegate& delegate_; + const TaskRunners task_runners_; + PointerDataPacketConverter pointer_data_packet_converter_; + SkISize size_; + fml::WeakPtrFactory weak_factory_; // Must be the last member. + private: FML_DISALLOW_COPY_AND_ASSIGN(PlatformView); }; diff --git a/engine/src/flutter/shell/common/pointer_data_dispatcher.h b/engine/src/flutter/shell/common/pointer_data_dispatcher.h index 7791292611..567ed5e525 100644 --- a/engine/src/flutter/shell/common/pointer_data_dispatcher.h +++ b/engine/src/flutter/shell/common/pointer_data_dispatcher.h @@ -147,20 +147,18 @@ class SmoothPointerDataDispatcher : public DefaultPointerDataDispatcher { virtual ~SmoothPointerDataDispatcher(); private: + void DispatchPendingPacket(); + void ScheduleSecondaryVsyncCallback(); + // If non-null, this will be a pending pointer data packet for the next frame // to consume. This is used to smooth out the irregular drag events delivery. // See also `DispatchPointerDataPacket` and input_events_unittests.cc. std::unique_ptr pending_packet_; int pending_trace_flow_id_ = -1; - bool is_pointer_data_in_progress_ = false; + // WeakPtrFactory must be the last member. fml::WeakPtrFactory weak_factory_; - - void DispatchPendingPacket(); - - void ScheduleSecondaryVsyncCallback(); - FML_DISALLOW_COPY_AND_ASSIGN(SmoothPointerDataDispatcher); }; diff --git a/engine/src/flutter/shell/common/rasterizer.h b/engine/src/flutter/shell/common/rasterizer.h index b05cabc5c1..4d25d3b16c 100644 --- a/engine/src/flutter/shell/common/rasterizer.h +++ b/engine/src/flutter/shell/common/rasterizer.h @@ -448,22 +448,6 @@ class Rasterizer final : public SnapshotDelegate { void DisableThreadMergerIfNeeded(); private: - Delegate& delegate_; - std::unique_ptr surface_; - std::unique_ptr snapshot_surface_producer_; - std::unique_ptr compositor_context_; - // This is the last successfully rasterized layer tree. - std::unique_ptr last_layer_tree_; - // Set when we need attempt to rasterize the layer tree again. This layer_tree - // has not successfully rasterized. This can happen due to the change in the - // thread configuration. This will be inserted to the front of the pipeline. - std::unique_ptr resubmitted_layer_tree_; - fml::closure next_frame_callback_; - bool user_override_resource_cache_bytes_; - std::optional max_cache_bytes_; - fml::RefPtr raster_thread_merger_; - fml::TaskRunnerAffineWeakPtrFactory weak_factory_; - std::shared_ptr external_view_embedder_; // |SnapshotDelegate| sk_sp MakeRasterSnapshot( std::function draw_callback, @@ -500,6 +484,24 @@ class Rasterizer final : public SnapshotDelegate { static bool NoDiscard(const flutter::LayerTree& layer_tree) { return false; } + Delegate& delegate_; + std::unique_ptr surface_; + std::unique_ptr snapshot_surface_producer_; + std::unique_ptr compositor_context_; + // This is the last successfully rasterized layer tree. + std::unique_ptr last_layer_tree_; + // Set when we need attempt to rasterize the layer tree again. This layer_tree + // has not successfully rasterized. This can happen due to the change in the + // thread configuration. This will be inserted to the front of the pipeline. + std::unique_ptr resubmitted_layer_tree_; + fml::closure next_frame_callback_; + bool user_override_resource_cache_bytes_; + std::optional max_cache_bytes_; + fml::RefPtr raster_thread_merger_; + std::shared_ptr external_view_embedder_; + + // WeakPtrFactory must be the last member. + fml::TaskRunnerAffineWeakPtrFactory weak_factory_; FML_DISALLOW_COPY_AND_ASSIGN(Rasterizer); }; diff --git a/engine/src/flutter/shell/gpu/gpu_surface_gl.h b/engine/src/flutter/shell/gpu/gpu_surface_gl.h index e4b04d31f9..fd641149de 100644 --- a/engine/src/flutter/shell/gpu/gpu_surface_gl.h +++ b/engine/src/flutter/shell/gpu/gpu_surface_gl.h @@ -54,6 +54,14 @@ class GPUSurfaceGL : public Surface { bool AllowsDrawingWhenGpuDisabled() const override; private: + bool CreateOrUpdateSurfaces(const SkISize& size); + + sk_sp AcquireRenderSurface( + const SkISize& untransformed_size, + const SkMatrix& root_surface_transformation); + + bool PresentSurface(SkCanvas* canvas); + GPUSurfaceGLDelegate* delegate_; sk_sp context_; sk_sp onscreen_surface_; @@ -66,16 +74,9 @@ class GPUSurfaceGL : public Surface { // external view embedder is present. const bool render_to_surface_ = true; bool valid_ = false; + + // WeakPtrFactory must be the last member. fml::TaskRunnerAffineWeakPtrFactory weak_factory_; - - bool CreateOrUpdateSurfaces(const SkISize& size); - - sk_sp AcquireRenderSurface( - const SkISize& untransformed_size, - const SkMatrix& root_surface_transformation); - - bool PresentSurface(SkCanvas* canvas); - FML_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceGL); }; diff --git a/engine/src/flutter/shell/gpu/gpu_surface_software.h b/engine/src/flutter/shell/gpu/gpu_surface_software.h index 23d5cdedf8..18bc8d5b41 100644 --- a/engine/src/flutter/shell/gpu/gpu_surface_software.h +++ b/engine/src/flutter/shell/gpu/gpu_surface_software.h @@ -39,7 +39,6 @@ class GPUSurfaceSoftware : public Surface { // external view embedder is present. const bool render_to_surface_; fml::TaskRunnerAffineWeakPtrFactory weak_factory_; - FML_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceSoftware); }; diff --git a/engine/src/flutter/shell/gpu/gpu_surface_vulkan.h b/engine/src/flutter/shell/gpu/gpu_surface_vulkan.h index 242ecef3d3..50c420e387 100644 --- a/engine/src/flutter/shell/gpu/gpu_surface_vulkan.h +++ b/engine/src/flutter/shell/gpu/gpu_surface_vulkan.h @@ -55,7 +55,6 @@ class GPUSurfaceVulkan : public Surface { const bool render_to_surface_; fml::WeakPtrFactory weak_factory_; - FML_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceVulkan); }; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index 46a6ea6f07..e3dfc78d9f 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm @@ -199,6 +199,10 @@ static constexpr int kNumProfilerSamplesPerSec = 5; object:self userInfo:nil]; + // It will be destroyed and invalidate its weak pointers + // before any other members are destroyed. + _weakFactory.reset(); + /// nil out weak references. [_registrars enumerateKeysAndObjectsUsingBlock:^(id key, FlutterEngineRegistrar* registrar, BOOL* stop) { diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManager.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManager.mm index 4d8d7b94e7..78097a20dd 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManager.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManager.mm @@ -49,6 +49,10 @@ static constexpr CFTimeInterval kDistantFuture = 1.0e10; } - (void)dealloc { + // It will be destroyed and invalidate its weak pointers + // before any other members are destroyed. + _weakFactory.reset(); + [_primaryResponders removeAllObjects]; [_secondaryResponders removeAllObjects]; [_primaryResponders release]; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm index c9b124ba4e..c6670450f3 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm @@ -236,6 +236,10 @@ static void DNSSD_API registrationCallback(DNSServiceRef sdRef, } - (void)dealloc { + // It will be destroyed and invalidate its weak pointers + // before any other members are destroyed. + _weakFactory.reset(); + [_delegate stopService]; [_url release]; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h index f886bd0df7..8d42bc8794 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h @@ -182,67 +182,6 @@ class FlutterPlatformViewsController { using LayersMap = std::map>>; - // The pool of reusable view layers. The pool allows to recycle layer in each frame. - std::unique_ptr layer_pool_; - - // The platform view's R-tree keyed off the view id, which contains any subsequent - // draw operation until the next platform view or the last leaf node in the layer tree. - // - // The R-trees are deleted by the FlutterPlatformViewsController.reset(). - std::map> platform_view_rtrees_; - - // The platform view's picture recorder keyed off the view id, which contains any subsequent - // operation until the next platform view or the end of the last leaf node in the layer tree. - std::map> picture_recorders_; - - fml::scoped_nsobject channel_; - fml::scoped_nsobject flutter_view_; - fml::scoped_nsobject flutter_view_controller_; - std::map>> factories_; - std::map>> views_; - std::map> touch_interceptors_; - // Mapping a platform view ID to the top most parent view (root_view) of a platform view. In - // |SubmitFrame|, root_views_ are added to flutter_view_ as child views. - // - // The platform view with the view ID is a child of the root view; If the platform view is not - // clipped, and no clipping view is added, the root view will be the intercepting view. - std::map> root_views_; - // Mapping a platform view ID to its latest composition params. - std::map current_composition_params_; - // Mapping a platform view ID to the count of the clipping operations that were applied to the - // platform view last time it was composited. - std::map clip_count_; - SkISize frame_size_; - - // The number of frames the rasterizer task runner will continue - // to run on the platform thread after no platform view is rendered. - // - // Note: this is an arbitrary number that attempts to account for cases - // where the platform view might be momentarily off the screen. - static const int kDefaultMergedLeaseDuration = 10; - - // Method channel `OnDispose` calls adds the views to be disposed to this set to be disposed on - // the next frame. - std::unordered_set views_to_dispose_; - - // A vector of embedded view IDs according to their composition order. - // The last ID in this vector belond to the that is composited on top of all others. - std::vector composition_order_; - - // The latest composition order that was presented in Present(). - std::vector active_composition_order_; - - // Only compoiste platform views in this set. - std::unordered_set views_to_recomposite_; - - // The FlutterPlatformViewGestureRecognizersBlockingPolicy for each type of platform view. - std::map - gesture_recognizers_blocking_policies; - - std::unique_ptr> weak_factory_; - - bool catransaction_added_ = false; - void OnCreate(FlutterMethodCall* call, FlutterResult& result); void OnDispose(FlutterMethodCall* call, FlutterResult& result); void OnAcceptGesture(FlutterMethodCall* call, FlutterResult& result); @@ -302,6 +241,67 @@ class FlutterPlatformViewsController { // Resets the state of the frame. void ResetFrameState(); + // The pool of reusable view layers. The pool allows to recycle layer in each frame. + std::unique_ptr layer_pool_; + + // The platform view's R-tree keyed off the view id, which contains any subsequent + // draw operation until the next platform view or the last leaf node in the layer tree. + // + // The R-trees are deleted by the FlutterPlatformViewsController.reset(). + std::map> platform_view_rtrees_; + + // The platform view's picture recorder keyed off the view id, which contains any subsequent + // operation until the next platform view or the end of the last leaf node in the layer tree. + std::map> picture_recorders_; + + fml::scoped_nsobject channel_; + fml::scoped_nsobject flutter_view_; + fml::scoped_nsobject flutter_view_controller_; + std::map>> factories_; + std::map>> views_; + std::map> touch_interceptors_; + // Mapping a platform view ID to the top most parent view (root_view) of a platform view. In + // |SubmitFrame|, root_views_ are added to flutter_view_ as child views. + // + // The platform view with the view ID is a child of the root view; If the platform view is not + // clipped, and no clipping view is added, the root view will be the intercepting view. + std::map> root_views_; + // Mapping a platform view ID to its latest composition params. + std::map current_composition_params_; + // Mapping a platform view ID to the count of the clipping operations that were applied to the + // platform view last time it was composited. + std::map clip_count_; + SkISize frame_size_; + + // The number of frames the rasterizer task runner will continue + // to run on the platform thread after no platform view is rendered. + // + // Note: this is an arbitrary number that attempts to account for cases + // where the platform view might be momentarily off the screen. + static const int kDefaultMergedLeaseDuration = 10; + + // Method channel `OnDispose` calls adds the views to be disposed to this set to be disposed on + // the next frame. + std::unordered_set views_to_dispose_; + + // A vector of embedded view IDs according to their composition order. + // The last ID in this vector belond to the that is composited on top of all others. + std::vector composition_order_; + + // The latest composition order that was presented in Present(). + std::vector active_composition_order_; + + // Only compoiste platform views in this set. + std::unordered_set views_to_recomposite_; + + // The FlutterPlatformViewGestureRecognizersBlockingPolicy for each type of platform view. + std::map + gesture_recognizers_blocking_policies; + + bool catransaction_added_ = false; + + // WeakPtrFactory must be the last member. + std::unique_ptr> weak_factory_; FML_DISALLOW_COPY_AND_ASSIGN(FlutterPlatformViewsController); }; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index adc0115d37..5b789d0175 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -784,6 +784,10 @@ static void sendFakeTouchEvent(FlutterEngine* engine, } - (void)dealloc { + // It will be destroyed and invalidate its weak pointers + // before any other members are destroyed. + _weakFactory.reset(); + [self removeInternalPlugins]; [self deregisterNotifications]; [super dealloc]; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h index ef451b5923..f3ad233389 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h @@ -99,12 +99,11 @@ class AccessibilityBridge final : public AccessibilityBridgeIos { int32_t last_focused_semantics_object_id_; fml::scoped_nsobject> objects_; fml::scoped_nsprotocol accessibility_channel_; - fml::WeakPtrFactory weak_factory_; int32_t previous_route_id_; std::unordered_map actions_; std::vector previous_routes_; std::unique_ptr ios_delegate_; - + fml::WeakPtrFactory weak_factory_; // Must be the last member. FML_DISALLOW_COPY_AND_ASSIGN(AccessibilityBridge); }; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm index 48f8d97652..81c4302f0e 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm @@ -46,11 +46,11 @@ AccessibilityBridge::AccessibilityBridge( platform_views_controller_(platform_views_controller), last_focused_semantics_object_id_(kSemanticObjectIdInvalid), objects_([[NSMutableDictionary alloc] init]), - weak_factory_(this), previous_route_id_(0), previous_routes_({}), ios_delegate_(ios_delegate ? std::move(ios_delegate) - : std::make_unique()) { + : std::make_unique()), + weak_factory_(this) { accessibility_channel_.reset([[FlutterBasicMessageChannel alloc] initWithName:@"flutter/accessibility" binaryMessenger:platform_view->GetOwnerViewController().get().engine.binaryMessenger diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/component_v1.h b/engine/src/flutter/shell/platform/fuchsia/flutter/component_v1.h index 2b79f90629..4fa6cbaf40 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/component_v1.h +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/component_v1.h @@ -81,28 +81,6 @@ class ComponentV1 final : public Engine::Delegate, #endif // !defined(DART_PRODUCT) private: - flutter::Settings settings_; - FlutterRunnerProductConfiguration product_config_; - TerminationCallback termination_callback_; - const std::string debug_label_; - UniqueFDIONS fdio_ns_ = UniqueFDIONSCreate(); - fml::UniqueFD component_data_directory_; - fml::UniqueFD component_assets_directory_; - - fidl::Binding component_controller_; - fuchsia::io::DirectoryPtr directory_ptr_; - fuchsia::io::NodePtr cloned_directory_ptr_; - fidl::InterfaceRequest directory_request_; - std::unique_ptr outgoing_dir_; - std::shared_ptr svc_; - std::shared_ptr runner_incoming_services_; - fidl::BindingSet shells_bindings_; - - fml::RefPtr isolate_snapshot_; - std::set> shell_holders_; - std::pair last_return_code_; - fml::WeakPtrFactory weak_factory_; - ComponentV1( TerminationCallback termination_callback, fuchsia::sys::Package package, @@ -133,6 +111,27 @@ class ComponentV1 final : public Engine::Delegate, // |flutter::Engine::Delegate| void OnEngineTerminate(const Engine* holder) override; + flutter::Settings settings_; + FlutterRunnerProductConfiguration product_config_; + TerminationCallback termination_callback_; + const std::string debug_label_; + UniqueFDIONS fdio_ns_ = UniqueFDIONSCreate(); + fml::UniqueFD component_data_directory_; + fml::UniqueFD component_assets_directory_; + + fidl::Binding component_controller_; + fuchsia::io::DirectoryPtr directory_ptr_; + fuchsia::io::NodePtr cloned_directory_ptr_; + fidl::InterfaceRequest directory_request_; + std::unique_ptr outgoing_dir_; + std::shared_ptr svc_; + std::shared_ptr runner_incoming_services_; + fidl::BindingSet shells_bindings_; + + fml::RefPtr isolate_snapshot_; + std::set> shell_holders_; + std::pair last_return_code_; + fml::WeakPtrFactory weak_factory_; // Must be the last member. FML_DISALLOW_COPY_AND_ASSIGN(ComponentV1); }; diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/component_v2.h b/engine/src/flutter/shell/platform/fuchsia/flutter/component_v2.h index 43a9af3536..33acbf64e9 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/component_v2.h +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/component_v2.h @@ -86,30 +86,6 @@ class ComponentV2 final #endif // !defined(DART_PRODUCT) private: - flutter::Settings settings_; - FlutterRunnerProductConfiguration product_config_; - TerminationCallback termination_callback_; - const std::string debug_label_; - UniqueFDIONS fdio_ns_ = UniqueFDIONSCreate(); - fml::UniqueFD component_data_directory_; - fml::UniqueFD component_assets_directory_; - - fidl::Binding - component_controller_; - fuchsia::io::DirectoryPtr directory_ptr_; - fuchsia::io::NodePtr cloned_directory_ptr_; - fidl::InterfaceRequest directory_request_; - std::unique_ptr outgoing_dir_; - std::unique_ptr runtime_dir_; - std::shared_ptr svc_; - std::shared_ptr runner_incoming_services_; - fidl::BindingSet shells_bindings_; - - fml::RefPtr isolate_snapshot_; - std::set> shell_holders_; - std::pair last_return_code_; - fml::WeakPtrFactory weak_factory_; - ComponentV2( TerminationCallback termination_callback, fuchsia::component::runner::ComponentStartInfo start_info, @@ -149,6 +125,29 @@ class ComponentV2 final // |flutter::Engine::Delegate| void OnEngineTerminate(const Engine* holder) override; + flutter::Settings settings_; + FlutterRunnerProductConfiguration product_config_; + TerminationCallback termination_callback_; + const std::string debug_label_; + UniqueFDIONS fdio_ns_ = UniqueFDIONSCreate(); + fml::UniqueFD component_data_directory_; + fml::UniqueFD component_assets_directory_; + + fidl::Binding + component_controller_; + fuchsia::io::DirectoryPtr directory_ptr_; + fuchsia::io::NodePtr cloned_directory_ptr_; + fidl::InterfaceRequest directory_request_; + std::unique_ptr outgoing_dir_; + std::unique_ptr runtime_dir_; + std::shared_ptr svc_; + std::shared_ptr runner_incoming_services_; + fidl::BindingSet shells_bindings_; + + fml::RefPtr isolate_snapshot_; + std::set> shell_holders_; + std::pair last_return_code_; + fml::WeakPtrFactory weak_factory_; // Must be the last member. FML_DISALLOW_COPY_AND_ASSIGN(ComponentV2); }; diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/engine.h b/engine/src/flutter/shell/platform/fuchsia/flutter/engine.h index 1c2dab34c1..6163f2fb04 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/engine.h +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/engine.h @@ -171,7 +171,6 @@ class Engine final : public fuchsia::memorypressure::Watcher { bool intercept_all_input_ = false; fml::WeakPtrFactory weak_factory_; - friend class testing::EngineTest; FML_DISALLOW_COPY_AND_ASSIGN(Engine); diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/vulkan_surface_producer.h b/engine/src/flutter/shell/platform/fuchsia/flutter/vulkan_surface_producer.h index dc0092587f..9933f6b781 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/vulkan_surface_producer.h +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/vulkan_surface_producer.h @@ -56,6 +56,14 @@ class VulkanSurfaceProducer final : public SurfaceProducer, bool TransitionSurfacesToExternal( const std::vector>& surfaces); + // Keep track of the last time we produced a surface. This is used to + // determine whether it is safe to shrink |surface_pool_| or not. + zx::time last_produce_time_ = async::Now(async_get_default_dispatcher()); + + // Disallow copy and assignment. + VulkanSurfaceProducer(const VulkanSurfaceProducer&) = delete; + VulkanSurfaceProducer& operator=(const VulkanSurfaceProducer&) = delete; + // Note: the order here is very important. The proctable must be destroyed // last because it contains the function pointers for VkDestroyDevice and // VkDestroyInstance. @@ -66,14 +74,8 @@ class VulkanSurfaceProducer final : public SurfaceProducer, std::unique_ptr surface_pool_; bool valid_ = false; - // Keep track of the last time we produced a surface. This is used to - // determine whether it is safe to shrink |surface_pool_| or not. - zx::time last_produce_time_ = async::Now(async_get_default_dispatcher()); + // WeakPtrFactory must be the last member. fml::WeakPtrFactory weak_factory_{this}; - - // Disallow copy and assignment. - VulkanSurfaceProducer(const VulkanSurfaceProducer&) = delete; - VulkanSurfaceProducer& operator=(const VulkanSurfaceProducer&) = delete; }; } // namespace flutter_runner