From 15e524a10e4db3c1300464a5793edf9f2f95c7fb Mon Sep 17 00:00:00 2001 From: Adam Duskett Date: Tue, 2 Jan 2024 16:59:29 -0700 Subject: [PATCH] package/flutter-engine: Add profile runtime mode selection Buildroot only offers two possible runtime modes for Flutter that are automatically selected based on what the user has selected: - debug if BR2_ENABLE_RUNTIME_DEBUG is enabled. - release if BR2_ENABLE_RUNTIME_DEBUG is not enabled. However, Flutter also offers the profile runtime mode option. From https://docs.flutter.dev/testing/build-modes: ``` "Use profile mode when you want to analyze performance." What is profile mode? Some debugging ability is maintained in profile mode, which is enough to profile your app's performance. Profile mode is turned off on the emulator and simulator because their behavior does not represent actual performance. ``` As Flutter projects can be heavy and consume many resources, it is necessary to allow users developing a Flutter application to profile their application during development. This patch introduces a new choice: FLUTTER_ENGINE_RUNTIME_MODE_PROFILE. If unselected, the global option BR2_ENABLE_RUNTIME_DEBUG continues to determine whether to build Flutter in release or debug mode. This new option may confuse some users who wonder where the release and debug options are, so the help menu section under the FLUTTER_ENGINE_RUNTIME_MODE_PROFILE option explains that the global BR2_ENABLE_RUNTIME_DEBUG option controls the debug and release modes. Signed-off-by: Adam Duskett Signed-off-by: Yann E. MORIN --- package/flutter-engine/Config.in | 25 ++++++++++++++++++++++++ package/flutter-engine/flutter-engine.mk | 4 +++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/package/flutter-engine/Config.in b/package/flutter-engine/Config.in index 2ec5b90ffd..3c92e40f74 100644 --- a/package/flutter-engine/Config.in +++ b/package/flutter-engine/Config.in @@ -39,6 +39,31 @@ config BR2_PACKAGE_FLUTTER_ENGINE https://github.com/flutter/engine +if BR2_PACKAGE_FLUTTER_ENGINE + +config FLUTTER_ENGINE_RUNTIME_MODE_PROFILE + bool "enable profiling" + help + Some debugging ability is maintained—enough to profile your + apps performance. Profile mode is disabled on the emulator + and simulator, because their behavior is not representative + of real performance. Profile mode is similar to release mode, + with the following differences: + + - Some service extensions, such as the one that enables the + performance overlay, are enabled. + + - Tracing is enabled, and tools supporting source-level + debugging (such as DevTools) can connect to the process. + + If this option is left unselected, the global option + BR2_ENABLE_RUNTIME_DEBUG determines whether to build Flutter + in release or debug mode. + + https://docs.flutter.dev/testing/build-modes#profile + +endif + comment "flutter-engine needs an OpenGL or OpenGLES backend" depends on BR2_PACKAGE_FLUTTER_ENGINE_ARCH_SUPPORTS depends on !BR2_PACKAGE_HAS_LIBGL && !BR2_PACKAGE_HAS_LIBGLES diff --git a/package/flutter-engine/flutter-engine.mk b/package/flutter-engine/flutter-engine.mk index c3ac144f2a..e972612097 100644 --- a/package/flutter-engine/flutter-engine.mk +++ b/package/flutter-engine/flutter-engine.mk @@ -52,7 +52,9 @@ FLUTTER_ENGINE_TARGET_ARCH = x64 FLUTTER_ENGINE_TARGET_TRIPPLE = x86_64-unknown-linux-gnu endif -ifeq ($(BR2_ENABLE_RUNTIME_DEBUG),y) +ifeq ($(FLUTTER_ENGINE_RUNTIME_MODE_PROFILE),y) +FLUTTER_ENGINE_RUNTIME_MODE=profile +else ifeq ($(BR2_ENABLE_RUNTIME_DEBUG),y) FLUTTER_ENGINE_RUNTIME_MODE=debug else FLUTTER_ENGINE_RUNTIME_MODE=release