diff --git a/shell/common/engine.cc b/shell/common/engine.cc index d2384c03579cf..1a778a17e035d 100644 --- a/shell/common/engine.cc +++ b/shell/common/engine.cc @@ -112,11 +112,18 @@ bool Engine::UpdateAssetManager( return false; } + auto old_asset_manager = asset_manager_; asset_manager_ = new_asset_manager; if (!asset_manager_) { return false; } + // Add the original asset resolvers to the new manager so that unmodified + // assets bundled with the application specific format (APK, IPA) can be used + // without syncing to the Dart devFS. + if (old_asset_manager != nullptr) { + asset_manager_->PushBack(old_asset_manager); + } // Using libTXT as the text engine. font_collection_.RegisterFonts(asset_manager_); diff --git a/shell/common/shell.cc b/shell/common/shell.cc index 2da9e9786e385..1503519ca7f4d 100644 --- a/shell/common/shell.cc +++ b/shell/common/shell.cc @@ -1404,7 +1404,6 @@ bool Shell::OnServiceProtocolRunInView( configuration.AddAssetResolver( std::make_unique(fml::OpenDirectory( asset_directory_path.c_str(), false, fml::FilePermission::kRead))); - configuration.AddAssetResolver(RestoreOriginalAssetResolver()); auto& allocator = response->GetAllocator(); response->SetObject(); @@ -1517,7 +1516,6 @@ bool Shell::OnServiceProtocolSetAssetBundlePath( auto asset_manager = std::make_shared(); - asset_manager->PushFront(RestoreOriginalAssetResolver()); asset_manager->PushFront(std::make_unique( fml::OpenDirectory(params.at("assetDirectory").data(), false, fml::FilePermission::kRead))); @@ -1624,16 +1622,4 @@ void Shell::OnDisplayUpdates(DisplayUpdateType update_type, display_manager_->HandleDisplayUpdates(update_type, displays); } -// Add the original asset directory to the resolvers so that unmodified assets -// bundled with the application specific format (APK, IPA) can be used without -// syncing to the Dart devFS. -std::unique_ptr Shell::RestoreOriginalAssetResolver() { - if (fml::UniqueFD::traits_type::IsValid(settings_.assets_dir)) { - return std::make_unique( - fml::Duplicate(settings_.assets_dir)); - } - return std::make_unique(fml::OpenDirectory( - settings_.assets_path.c_str(), false, fml::FilePermission::kRead)); -}; - } // namespace flutter diff --git a/shell/common/shell.h b/shell/common/shell.h index a345b0461e5fc..6eb9dfec7f319 100644 --- a/shell/common/shell.h +++ b/shell/common/shell.h @@ -613,10 +613,6 @@ class Shell final : public PlatformView::Delegate, const ServiceProtocol::Handler::ServiceProtocolMap& params, rapidjson::Document* response); - // Creates an asset bundle from the original settings asset path or - // directory. - std::unique_ptr RestoreOriginalAssetResolver(); - // For accessing the Shell via the raster thread, necessary for various // rasterizer callbacks. std::unique_ptr> weak_factory_gpu_;