diff --git a/include/flutter-pi.h b/include/flutter-pi.h index 65a814a6..0a0d5c67 100644 --- a/include/flutter-pi.h +++ b/include/flutter-pi.h @@ -313,7 +313,7 @@ struct frame { struct compositor; enum flutter_runtime_mode { - kDebug, kRelease + kDebug, kProfile, kRelease }; struct flutterpi { @@ -426,6 +426,7 @@ struct flutterpi { char *app_elf_path; void *app_elf_handle; char *icu_data_path; + char *libflutter_engine_path; FlutterLocale **locales; size_t n_locales; diff --git a/src/flutter-pi.c b/src/flutter-pi.c index 81933cfa..86ea0d2e 100644 --- a/src/flutter-pi.c +++ b/src/flutter-pi.c @@ -69,6 +69,12 @@ OPTIONS:\n\ This also requires a libflutter_engine.so that was\n\ built with --runtime-mode=release.\n\ \n\ + --profile Run the app in profile mode. The AOT snapshot\n\ + of the app (\"app.so\") must be located inside the\n\ + asset bundle directory.\n\ + This also requires a libflutter_engine.so that was\n\ + built with --runtime-mode=profile.\n\ + \n\ -o, --orientation Start the app in this orientation. Valid\n\ for are: portrait_up, landscape_left,\n\ portrait_down, landscape_right.\n\ @@ -1341,7 +1347,7 @@ static int init_display(void) { if (horizontal_dpi != vertical_dpi) { // See https://github.com/flutter/flutter/issues/71865 for current status of this issue. - fprintf(stderr, "[flutter-pi] WARNING: display has non-square pixels. Non-square-pixels are not supported by flutter.\n"); + fprintf(stderr, "[flutter-pi] WARNING: display has non-square pixels. Non-square-pixels are ;-).\n"); } } @@ -1680,7 +1686,18 @@ static int init_application(void) { int ok; libflutter_engine_handle = NULL; - if (flutterpi.flutter.runtime_mode == kRelease) { + + libflutter_engine_handle = dlopen(flutterpi.flutter.libflutter_engine_path, RTLD_LOCAL | RTLD_NOW); + + if (libflutter_engine_handle == NULL) + { + LOG_FLUTTERPI_ERROR( + "[flutter-pi] Warning: Could not load libflutter_engine.so inside the asset bundle : " + "%s. Trying to open libflutter_engine.so.${runtimeMode} ...\n", + dlerror()); + } + + if (flutterpi.flutter.runtime_mode == kRelease) { libflutter_engine_handle = dlopen("libflutter_engine.so.release", RTLD_LOCAL | RTLD_NOW); if (libflutter_engine_handle == NULL) { LOG_FLUTTERPI_ERROR("[flutter-pi] Warning: Could not load libflutter_engine.so.release: %s. Trying to open libflutter_engine.so...\n", dlerror()); @@ -2094,7 +2111,7 @@ static int init_user_input(void) { static bool setup_paths(void) { - char *kernel_blob_path, *icu_data_path, *app_elf_path; + char *kernel_blob_path, *icu_data_path, *app_elf_path, *libflutter_engine_path; #define PATH_EXISTS(path) (access((path),R_OK)==0) if (!PATH_EXISTS(flutterpi.flutter.asset_bundle_path)) { @@ -2123,11 +2140,15 @@ static bool setup_paths(void) { return false; } - flutterpi.flutter.kernel_blob_path = kernel_blob_path; + asprintf(&libflutter_engine_path, "%s/libflutter_engine.so", flutterpi.flutter.asset_bundle_path); + + + flutterpi.flutter.kernel_blob_path = kernel_blob_path; flutterpi.flutter.icu_data_path = icu_data_path; flutterpi.flutter.app_elf_path = app_elf_path; + flutterpi.flutter.libflutter_engine_path = libflutter_engine_path; - return true; + return true; #undef PATH_EXISTS }