From d5cceff94a7cfad96e6047759b2d4ca8fd122c6b Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Tue, 25 Apr 2023 12:08:27 -0400 Subject: [PATCH] feat: Support async updates from the updater library. (#13) * feat: Support async updates from the updater library. This is the engine side of: https://github.com/shorebirdtech/updater/pull/11 I also removed passing vmpath (unused) and adjusted names to be more consistent. * Add DEPS change --- DEPS | 2 +- shell/common/shell.cc | 2 +- shell/platform/android/flutter_main.cc | 23 ++++++++++++----------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/DEPS b/DEPS index 24c840e416e46..377c286c88192 100644 --- a/DEPS +++ b/DEPS @@ -21,7 +21,7 @@ vars = { 'skia_revision': '0d31aa1f49cb8cfd790c44d92a9a023839524865', 'updater_git': 'https://github.com/shorebirdtech/updater.git', - 'updater_rev': 'bc19f5df79005d65073debdc736f17ca6d827f89', + 'updater_rev': '4ab78869b8e75f10450d6156c92d9ab7dc401516', # WARNING: DO NOT EDIT canvaskit_cipd_instance MANUALLY # See `lib/web_ui/README.md` for how to roll CanvasKit to a new version. diff --git a/shell/common/shell.cc b/shell/common/shell.cc index eafcac7feff3f..bad2834907e95 100644 --- a/shell/common/shell.cc +++ b/shell/common/shell.cc @@ -145,7 +145,7 @@ std::unique_ptr Shell::Create( // non-android targets (e.g. flutter_tester) will fail to link. #if FML_OS_ANDROID if (!vm) { - shorebird_report_failed_launch(); + shorebird_report_launch_failure(); } #endif FML_CHECK(vm) << "Must be able to initialize the VM."; diff --git a/shell/platform/android/flutter_main.cc b/shell/platform/android/flutter_main.cc index 75b3ada070829..62c2f850b537d 100644 --- a/shell/platform/android/flutter_main.cc +++ b/shell/platform/android/flutter_main.cc @@ -120,34 +120,35 @@ void ConfigureShorebird(std::string android_cache_path, app_parameters.original_libapp_paths = c_paths.data(); app_parameters.original_libapp_paths_size = c_paths.size(); - app_parameters.vm_path = "libflutter.so"; // Unused. - // shorebird_init copies from app_parameters and shorebirdYaml. shorebird_init(&app_parameters, shorebirdYaml.c_str()); } - FML_LOG(INFO) << "Starting Shorebird update"; - shorebird_update(); - - char* c_active_path = shorebird_active_path(); + char* c_active_path = shorebird_next_boot_patch_path(); if (c_active_path != NULL) { std::string active_path = c_active_path; shorebird_free_string(c_active_path); FML_LOG(INFO) << "Shorebird updater: active path: " << active_path; - - settings.application_library_path.clear(); - settings.application_library_path.emplace_back(active_path); - - char* c_patch_number = shorebird_active_patch_number(); + char* c_patch_number = shorebird_next_boot_patch_number(); if (c_patch_number != NULL) { std::string patch_number = c_patch_number; shorebird_free_string(c_patch_number); FML_LOG(INFO) << "Shorebird updater: active patch number: " << patch_number; } + + settings.application_library_path.clear(); + settings.application_library_path.emplace_back(active_path); + // Once start_update_thread is called, the next_boot_patch* functions may + // change their return values if the shorebird_report_launch_failed + // function is called. + shorebird_report_launch_start(); } else { FML_LOG(INFO) << "Shorebird updater: no active patch."; } + + FML_LOG(INFO) << "Starting Shorebird update"; + shorebird_start_update_thread(); } void FlutterMain::Init(JNIEnv* env,