Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions shell/common/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand Down
14 changes: 0 additions & 14 deletions shell/common/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,6 @@ bool Shell::OnServiceProtocolRunInView(
configuration.AddAssetResolver(
std::make_unique<DirectoryAssetBundle>(fml::OpenDirectory(
asset_directory_path.c_str(), false, fml::FilePermission::kRead)));
configuration.AddAssetResolver(RestoreOriginalAssetResolver());

auto& allocator = response->GetAllocator();
response->SetObject();
Expand Down Expand Up @@ -1517,7 +1516,6 @@ bool Shell::OnServiceProtocolSetAssetBundlePath(

auto asset_manager = std::make_shared<AssetManager>();

asset_manager->PushFront(RestoreOriginalAssetResolver());
asset_manager->PushFront(std::make_unique<DirectoryAssetBundle>(
fml::OpenDirectory(params.at("assetDirectory").data(), false,
fml::FilePermission::kRead)));
Expand Down Expand Up @@ -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<DirectoryAssetBundle> Shell::RestoreOriginalAssetResolver() {
if (fml::UniqueFD::traits_type::IsValid(settings_.assets_dir)) {
return std::make_unique<DirectoryAssetBundle>(
fml::Duplicate(settings_.assets_dir));
}
return std::make_unique<DirectoryAssetBundle>(fml::OpenDirectory(
settings_.assets_path.c_str(), false, fml::FilePermission::kRead));
};

} // namespace flutter
4 changes: 0 additions & 4 deletions shell/common/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<DirectoryAssetBundle> RestoreOriginalAssetResolver();

// For accessing the Shell via the raster thread, necessary for various
// rasterizer callbacks.
std::unique_ptr<fml::TaskRunnerAffineWeakPtrFactory<Shell>> weak_factory_gpu_;
Expand Down