From 32e271a2ad9eadcf740fe82827c9f9d33fcef264 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Tue, 28 Jan 2020 11:44:27 -0800 Subject: [PATCH] Revert "Disable setting a library tag handler." (flutter/engine#16157) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit a801e2264fc2f48646d3a3bc2f15a3416e6dc87b. This address the use case of an internal customer. In a subsequent patch, I will add a test for this functionality. Instead of removing support for the same from tonic (along with the stuff surrounding filesystem access and package map handling), I’ll rework the same to use FML to avoid code duplication and maintainability. --- engine/src/flutter/runtime/dart_isolate.cc | 12 +++++++++--- engine/src/flutter/runtime/dart_service_isolate.cc | 6 ++++++ engine/src/flutter/runtime/dart_service_isolate.h | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/engine/src/flutter/runtime/dart_isolate.cc b/engine/src/flutter/runtime/dart_isolate.cc index 9f41ed8b2b..fd0c833244 100644 --- a/engine/src/flutter/runtime/dart_isolate.cc +++ b/engine/src/flutter/runtime/dart_isolate.cc @@ -184,6 +184,11 @@ bool DartIsolate::Initialize(Dart_Isolate dart_isolate) { SetMessageHandlingTaskRunner(GetTaskRunners().GetUITaskRunner()); + if (tonic::LogIfError( + Dart_SetLibraryTagHandler(tonic::DartState::HandleLibraryTag))) { + return false; + } + if (!UpdateThreadPoolNames()) { return false; } @@ -618,9 +623,10 @@ Dart_Isolate DartIsolate::DartCreateAndStartServiceIsolate( tonic::DartState::Scope scope(service_isolate); if (!DartServiceIsolate::Startup( - settings.observatory_host, // server IP address - settings.observatory_port, // server observatory port - false, // disable websocket origin check + settings.observatory_host, // server IP address + settings.observatory_port, // server observatory port + tonic::DartState::HandleLibraryTag, // embedder library tag handler + false, // disable websocket origin check settings.disable_service_auth_codes, // disable VM service auth codes error // error (out) )) { diff --git a/engine/src/flutter/runtime/dart_service_isolate.cc b/engine/src/flutter/runtime/dart_service_isolate.cc index bc9da0910c..d13666be8f 100644 --- a/engine/src/flutter/runtime/dart_service_isolate.cc +++ b/engine/src/flutter/runtime/dart_service_isolate.cc @@ -30,6 +30,7 @@ namespace flutter { namespace { +static Dart_LibraryTagHandler g_embedder_tag_handler; static tonic::DartLibraryNatives* g_natives; static std::string g_observatory_uri; @@ -126,12 +127,17 @@ void DartServiceIsolate::Shutdown(Dart_NativeArguments args) { bool DartServiceIsolate::Startup(std::string server_ip, intptr_t server_port, + Dart_LibraryTagHandler embedder_tag_handler, bool disable_origin_check, bool disable_service_auth_codes, char** error) { Dart_Isolate isolate = Dart_CurrentIsolate(); FML_CHECK(isolate); + // Remember the embedder's library tag handler. + g_embedder_tag_handler = embedder_tag_handler; + FML_CHECK(g_embedder_tag_handler); + // Setup native entries. if (!g_natives) { g_natives = new tonic::DartLibraryNatives(); diff --git a/engine/src/flutter/runtime/dart_service_isolate.h b/engine/src/flutter/runtime/dart_service_isolate.h index 6f2f86878d..0adbabca9a 100644 --- a/engine/src/flutter/runtime/dart_service_isolate.h +++ b/engine/src/flutter/runtime/dart_service_isolate.h @@ -23,6 +23,7 @@ class DartServiceIsolate { static bool Startup(std::string server_ip, intptr_t server_port, + Dart_LibraryTagHandler embedder_tag_handler, bool disable_origin_check, bool disable_service_auth_codes, char** error);