From 28a810a5b27c6a2df91ea8009fbe06658b5b225e Mon Sep 17 00:00:00 2001 From: Greg Spencer Date: Mon, 20 Mar 2023 14:16:21 -0700 Subject: [PATCH] Rename setters for lifecycle state (flutter/engine#40462) Rename setters for lifecycle state --- engine/src/flutter/lib/ui/hooks.dart | 4 ++-- .../src/flutter/lib/ui/platform_dispatcher.dart | 2 +- .../lib/ui/window/platform_configuration.cc | 17 +++++++++-------- .../lib/ui/window/platform_configuration.h | 4 ++-- .../src/flutter/runtime/runtime_controller.cc | 6 +++--- engine/src/flutter/runtime/runtime_controller.h | 10 ++++++---- engine/src/flutter/shell/common/engine.cc | 2 +- 7 files changed, 24 insertions(+), 21 deletions(-) diff --git a/engine/src/flutter/lib/ui/hooks.dart b/engine/src/flutter/lib/ui/hooks.dart index 0ac4fe4992..f92d287cf0 100644 --- a/engine/src/flutter/lib/ui/hooks.dart +++ b/engine/src/flutter/lib/ui/hooks.dart @@ -67,8 +67,8 @@ void _updateUserSettingsData(String jsonData) { } @pragma('vm:entry-point') -void _updateLifecycleState(String state) { - PlatformDispatcher.instance._updateLifecycleState(state); +void _updateInitialLifecycleState(String state) { + PlatformDispatcher.instance._updateInitialLifecycleState(state); } @pragma('vm:entry-point') diff --git a/engine/src/flutter/lib/ui/platform_dispatcher.dart b/engine/src/flutter/lib/ui/platform_dispatcher.dart index 5e2b74124c..f955bb5f18 100644 --- a/engine/src/flutter/lib/ui/platform_dispatcher.dart +++ b/engine/src/flutter/lib/ui/platform_dispatcher.dart @@ -922,7 +922,7 @@ class PlatformDispatcher { bool _initialLifecycleStateAccessed = false; // Called from the engine, via hooks.dart - void _updateLifecycleState(String state) { + void _updateInitialLifecycleState(String state) { // We do not update the state if the state has already been used to initialize // the lifecycleState. if (!_initialLifecycleStateAccessed) { diff --git a/engine/src/flutter/lib/ui/window/platform_configuration.cc b/engine/src/flutter/lib/ui/window/platform_configuration.cc index 95a2714929..4e6e583745 100644 --- a/engine/src/flutter/lib/ui/window/platform_configuration.cc +++ b/engine/src/flutter/lib/ui/window/platform_configuration.cc @@ -48,9 +48,9 @@ void PlatformConfiguration::DidCreateIsolate() { update_user_settings_data_.Set( tonic::DartState::Current(), Dart_GetField(library, tonic::ToDart("_updateUserSettingsData"))); - update_lifecycle_state_.Set( + update_initial_lifecycle_state_.Set( tonic::DartState::Current(), - Dart_GetField(library, tonic::ToDart("_updateLifecycleState"))); + Dart_GetField(library, tonic::ToDart("_updateInitialLifecycleState"))); update_semantics_enabled_.Set( tonic::DartState::Current(), Dart_GetField(library, tonic::ToDart("_updateSemanticsEnabled"))); @@ -108,17 +108,18 @@ void PlatformConfiguration::UpdateUserSettingsData(const std::string& data) { })); } -void PlatformConfiguration::UpdateLifecycleState(const std::string& data) { +void PlatformConfiguration::UpdateInitialLifecycleState( + const std::string& data) { std::shared_ptr dart_state = - update_lifecycle_state_.dart_state().lock(); + update_initial_lifecycle_state_.dart_state().lock(); if (!dart_state) { return; } tonic::DartState::Scope scope(dart_state); - tonic::CheckAndHandleError(tonic::DartInvoke(update_lifecycle_state_.Get(), - { - tonic::StdStringToDart(data), - })); + tonic::CheckAndHandleError(tonic::DartInvoke( + update_initial_lifecycle_state_.Get(), { + tonic::StdStringToDart(data), + })); } void PlatformConfiguration::UpdateSemanticsEnabled(bool enabled) { diff --git a/engine/src/flutter/lib/ui/window/platform_configuration.h b/engine/src/flutter/lib/ui/window/platform_configuration.h index c6f3c7811e..381b8e02e1 100644 --- a/engine/src/flutter/lib/ui/window/platform_configuration.h +++ b/engine/src/flutter/lib/ui/window/platform_configuration.h @@ -296,7 +296,7 @@ class PlatformConfiguration final { /// /// @param[in] data The lifecycle state data. /// - void UpdateLifecycleState(const std::string& data); + void UpdateInitialLifecycleState(const std::string& data); //---------------------------------------------------------------------------- /// @brief Notifies the PlatformConfiguration that the embedder has @@ -436,7 +436,7 @@ class PlatformConfiguration final { tonic::DartPersistentValue on_error_; tonic::DartPersistentValue update_locales_; tonic::DartPersistentValue update_user_settings_data_; - tonic::DartPersistentValue update_lifecycle_state_; + tonic::DartPersistentValue update_initial_lifecycle_state_; tonic::DartPersistentValue update_semantics_enabled_; tonic::DartPersistentValue update_accessibility_features_; tonic::DartPersistentValue dispatch_platform_message_; diff --git a/engine/src/flutter/runtime/runtime_controller.cc b/engine/src/flutter/runtime/runtime_controller.cc index bf923ed5a7..996cc38114 100644 --- a/engine/src/flutter/runtime/runtime_controller.cc +++ b/engine/src/flutter/runtime/runtime_controller.cc @@ -119,7 +119,7 @@ bool RuntimeController::FlushRuntimeStateToIsolate() { SetAccessibilityFeatures( platform_data_.accessibility_feature_flags_) && SetUserSettingsData(platform_data_.user_settings_data) && - SetLifecycleState(platform_data_.lifecycle_state); + SetInitialLifecycleState(platform_data_.lifecycle_state); } bool RuntimeController::SetViewportMetrics(const ViewportMetrics& metrics) { @@ -157,11 +157,11 @@ bool RuntimeController::SetUserSettingsData(const std::string& data) { return false; } -bool RuntimeController::SetLifecycleState(const std::string& data) { +bool RuntimeController::SetInitialLifecycleState(const std::string& data) { platform_data_.lifecycle_state = data; if (auto* platform_configuration = GetPlatformConfigurationIfAvailable()) { - platform_configuration->UpdateLifecycleState( + platform_configuration->UpdateInitialLifecycleState( platform_data_.lifecycle_state); return true; } diff --git a/engine/src/flutter/runtime/runtime_controller.h b/engine/src/flutter/runtime/runtime_controller.h index 98fbf11464..b3fc828f82 100644 --- a/engine/src/flutter/runtime/runtime_controller.h +++ b/engine/src/flutter/runtime/runtime_controller.h @@ -205,9 +205,11 @@ class RuntimeController : public PlatformConfigurationClient { bool SetUserSettingsData(const std::string& data); //---------------------------------------------------------------------------- - /// @brief Forward the lifecycle state data to the running isolate. If - /// the isolate is not running, this data will be saved and - /// flushed to the isolate when it starts running. + /// @brief Forward the initial lifecycle state data to the running + /// isolate. If the isolate is not running, this data will be + /// saved and flushed to the isolate when it starts running. + /// After the isolate starts running, the current lifecycle + /// state is pushed to it via the "flutter/lifecycle" channel. /// /// @deprecated The persistent isolate data must be used for this purpose /// instead. @@ -217,7 +219,7 @@ class RuntimeController : public PlatformConfigurationClient { /// @return If the lifecycle state data was forwarded to the running /// isolate. /// - bool SetLifecycleState(const std::string& data); + bool SetInitialLifecycleState(const std::string& data); //---------------------------------------------------------------------------- /// @brief Notifies the running isolate about whether the semantics tree diff --git a/engine/src/flutter/shell/common/engine.cc b/engine/src/flutter/shell/common/engine.cc index 278f84fad4..522ee89a52 100644 --- a/engine/src/flutter/shell/common/engine.cc +++ b/engine/src/flutter/shell/common/engine.cc @@ -331,7 +331,7 @@ bool Engine::HandleLifecyclePlatformMessage(PlatformMessage* message) { state == "AppLifecycleState.inactive") { ScheduleFrame(); } - runtime_controller_->SetLifecycleState(state); + runtime_controller_->SetInitialLifecycleState(state); // Always forward these messages to the framework by returning false. return false; }