@@ -1401,10 +1401,21 @@ bool Shell::OnServiceProtocolRunInView(
14011401 configuration.SetEntrypointAndLibrary (engine_->GetLastEntrypoint (),
14021402 engine_->GetLastEntrypointLibrary ());
14031403
1404- configuration.AddAssetResolver (
1405- std::make_unique<DirectoryAssetBundle>(fml::OpenDirectory (
1406- asset_directory_path.c_str (), false , fml::FilePermission::kRead )));
1407- configuration.AddAssetResolver (RestoreOriginalAssetResolver ());
1404+ configuration.AddAssetResolver (std::make_unique<DirectoryAssetBundle>(
1405+ fml::OpenDirectory (asset_directory_path.c_str (), false ,
1406+ fml::FilePermission::kRead ),
1407+ false ));
1408+
1409+ // Preserve any original asset resolvers to avoid syncing unchanged assets
1410+ // over the DevFS connection.
1411+ auto old_asset_manager = engine_->GetAssetManager ();
1412+ if (old_asset_manager != nullptr ) {
1413+ for (auto & old_resolver : old_asset_manager->TakeResolvers ()) {
1414+ if (old_resolver->IsValidAfterAssetManagerChange ()) {
1415+ configuration.AddAssetResolver (std::move (old_resolver));
1416+ }
1417+ }
1418+ }
14081419
14091420 auto & allocator = response->GetAllocator ();
14101421 response->SetObject ();
@@ -1517,10 +1528,21 @@ bool Shell::OnServiceProtocolSetAssetBundlePath(
15171528
15181529 auto asset_manager = std::make_shared<AssetManager>();
15191530
1520- asset_manager->PushFront (RestoreOriginalAssetResolver ());
15211531 asset_manager->PushFront (std::make_unique<DirectoryAssetBundle>(
15221532 fml::OpenDirectory (params.at (" assetDirectory" ).data (), false ,
1523- fml::FilePermission::kRead )));
1533+ fml::FilePermission::kRead ),
1534+ false ));
1535+
1536+ // Preserve any original asset resolvers to avoid syncing unchanged assets
1537+ // over the DevFS connection.
1538+ auto old_asset_manager = engine_->GetAssetManager ();
1539+ if (old_asset_manager != nullptr ) {
1540+ for (auto & old_resolver : old_asset_manager->TakeResolvers ()) {
1541+ if (old_resolver->IsValidAfterAssetManagerChange ()) {
1542+ asset_manager->PushBack (std::move (old_resolver));
1543+ }
1544+ }
1545+ }
15241546
15251547 if (engine_->UpdateAssetManager (std::move (asset_manager))) {
15261548 response->AddMember (" type" , " Success" , allocator);
@@ -1624,16 +1646,4 @@ void Shell::OnDisplayUpdates(DisplayUpdateType update_type,
16241646 display_manager_->HandleDisplayUpdates (update_type, displays);
16251647}
16261648
1627- // Add the original asset directory to the resolvers so that unmodified assets
1628- // bundled with the application specific format (APK, IPA) can be used without
1629- // syncing to the Dart devFS.
1630- std::unique_ptr<DirectoryAssetBundle> Shell::RestoreOriginalAssetResolver () {
1631- if (fml::UniqueFD::traits_type::IsValid (settings_.assets_dir )) {
1632- return std::make_unique<DirectoryAssetBundle>(
1633- fml::Duplicate (settings_.assets_dir ));
1634- }
1635- return std::make_unique<DirectoryAssetBundle>(fml::OpenDirectory (
1636- settings_.assets_path .c_str (), false , fml::FilePermission::kRead ));
1637- };
1638-
16391649} // namespace flutter
0 commit comments