Skip to content

Commit dd5c912

Browse files
Merge pull request #206 from pieter-scholtz/profile-mode-rework
Modification to first try loading libflutter_engine.so from the asset bundle
2 parents e60ccd1 + 0f269bb commit dd5c912

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

include/flutter-pi.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ struct frame {
313313
struct compositor;
314314

315315
enum flutter_runtime_mode {
316-
kDebug, kRelease
316+
kDebug, kProfile, kRelease
317317
};
318318

319319
struct flutterpi {
@@ -426,6 +426,7 @@ struct flutterpi {
426426
char *app_elf_path;
427427
void *app_elf_handle;
428428
char *icu_data_path;
429+
char *libflutter_engine_path;
429430

430431
FlutterLocale **locales;
431432
size_t n_locales;

src/flutter-pi.c

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ OPTIONS:\n\
6969
This also requires a libflutter_engine.so that was\n\
7070
built with --runtime-mode=release.\n\
7171
\n\
72+
--profile Run the app in profile mode. The AOT snapshot\n\
73+
of the app (\"app.so\") must be located inside the\n\
74+
asset bundle directory.\n\
75+
This also requires a libflutter_engine.so that was\n\
76+
built with --runtime-mode=profile.\n\
77+
\n\
7278
-o, --orientation <orientation> Start the app in this orientation. Valid\n\
7379
for <orientation> are: portrait_up, landscape_left,\n\
7480
portrait_down, landscape_right.\n\
@@ -1341,7 +1347,7 @@ static int init_display(void) {
13411347

13421348
if (horizontal_dpi != vertical_dpi) {
13431349
// See https://github.com/flutter/flutter/issues/71865 for current status of this issue.
1344-
fprintf(stderr, "[flutter-pi] WARNING: display has non-square pixels. Non-square-pixels are not supported by flutter.\n");
1350+
fprintf(stderr, "[flutter-pi] WARNING: display has non-square pixels. Non-square-pixels are ;-).\n");
13451351
}
13461352
}
13471353

@@ -1680,7 +1686,18 @@ static int init_application(void) {
16801686
int ok;
16811687

16821688
libflutter_engine_handle = NULL;
1683-
if (flutterpi.flutter.runtime_mode == kRelease) {
1689+
1690+
libflutter_engine_handle = dlopen(flutterpi.flutter.libflutter_engine_path, RTLD_LOCAL | RTLD_NOW);
1691+
1692+
if (libflutter_engine_handle == NULL)
1693+
{
1694+
LOG_FLUTTERPI_ERROR(
1695+
"[flutter-pi] Warning: Could not load libflutter_engine.so inside the asset bundle : "
1696+
"%s. Trying to open libflutter_engine.so.${runtimeMode} ...\n",
1697+
dlerror());
1698+
}
1699+
1700+
if (flutterpi.flutter.runtime_mode == kRelease) {
16841701
libflutter_engine_handle = dlopen("libflutter_engine.so.release", RTLD_LOCAL | RTLD_NOW);
16851702
if (libflutter_engine_handle == NULL) {
16861703
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) {
20942111

20952112

20962113
static bool setup_paths(void) {
2097-
char *kernel_blob_path, *icu_data_path, *app_elf_path;
2114+
char *kernel_blob_path, *icu_data_path, *app_elf_path, *libflutter_engine_path;
20982115
#define PATH_EXISTS(path) (access((path),R_OK)==0)
20992116

21002117
if (!PATH_EXISTS(flutterpi.flutter.asset_bundle_path)) {
@@ -2123,11 +2140,15 @@ static bool setup_paths(void) {
21232140
return false;
21242141
}
21252142

2126-
flutterpi.flutter.kernel_blob_path = kernel_blob_path;
2143+
asprintf(&libflutter_engine_path, "%s/libflutter_engine.so", flutterpi.flutter.asset_bundle_path);
2144+
2145+
2146+
flutterpi.flutter.kernel_blob_path = kernel_blob_path;
21272147
flutterpi.flutter.icu_data_path = icu_data_path;
21282148
flutterpi.flutter.app_elf_path = app_elf_path;
2149+
flutterpi.flutter.libflutter_engine_path = libflutter_engine_path;
21292150

2130-
return true;
2151+
return true;
21312152

21322153
#undef PATH_EXISTS
21332154
}

0 commit comments

Comments
 (0)