From 681e4c6427a1c35fc786461846ab871814363aad Mon Sep 17 00:00:00 2001 From: Dan Field Date: Tue, 13 Nov 2018 23:41:56 -0800 Subject: [PATCH] Flush UserSettings to window (flutter/engine#6850) --- engine/src/flutter/lib/ui/hooks.dart | 3 +++ engine/src/flutter/runtime/runtime_controller.cc | 3 ++- .../flutter/testing/dart/window_hooks_integration_test.dart | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/lib/ui/hooks.dart b/engine/src/flutter/lib/ui/hooks.dart index 923662dc41..54c5033b40 100644 --- a/engine/src/flutter/lib/ui/hooks.dart +++ b/engine/src/flutter/lib/ui/hooks.dart @@ -68,6 +68,9 @@ void _updateLocales(List locales) { @pragma('vm:entry-point') void _updateUserSettingsData(String jsonData) { final Map data = json.decode(jsonData); + if (data.isEmpty) { + return; + } _updateTextScaleFactor(data['textScaleFactor'].toDouble()); _updateAlwaysUse24HourFormat(data['alwaysUse24HourFormat']); } diff --git a/engine/src/flutter/runtime/runtime_controller.cc b/engine/src/flutter/runtime/runtime_controller.cc index 0beacff828..e5b765a35f 100644 --- a/engine/src/flutter/runtime/runtime_controller.cc +++ b/engine/src/flutter/runtime/runtime_controller.cc @@ -128,7 +128,8 @@ bool RuntimeController::FlushRuntimeStateToIsolate() { return SetViewportMetrics(window_data_.viewport_metrics) && SetLocales(window_data_.locale_data) && SetSemanticsEnabled(window_data_.semantics_enabled) && - SetAccessibilityFeatures(window_data_.accessibility_feature_flags_); + SetAccessibilityFeatures(window_data_.accessibility_feature_flags_) && + SetUserSettingsData(window_data_.user_settings_data); } bool RuntimeController::SetViewportMetrics(const ViewportMetrics& metrics) { diff --git a/engine/src/flutter/testing/dart/window_hooks_integration_test.dart b/engine/src/flutter/testing/dart/window_hooks_integration_test.dart index d6df903eb7..446f5ac8ab 100644 --- a/engine/src/flutter/testing/dart/window_hooks_integration_test.dart +++ b/engine/src/flutter/testing/dart/window_hooks_integration_test.dart @@ -67,6 +67,12 @@ void main() { window.onTextScaleFactorChanged = originalOnTextScaleFactorChanged; }); + test('updateUserSettings can handle an empty object', () { + // this should now throw. + _updateUserSettingsData('{}'); + expect(true, equals(true)); + }); + test('onMetricsChanged preserves callback zone', () { Zone innerZone; Zone runZone;