Skip to content

[iOS] Hot restart fails with native assets #148687

@knopp

Description

@knopp

Reproducible with the example from FFI plugin (flutter create -t package_ffi ffi_x) on iOS device

Exception after hot restart with the example application

Invalid argument(s): Couldn't resolve native function 'sum' in
           'package:ffi_x/ffi_x_bindings_generated.dart' : Failed to load dynamic library
           'ffi_x1.framework/ffi_x1': Failed to load dynamic library 'ffi_x1.framework/ffi_x1':
           dlopen(ffi_x1.framework/ffi_x1, 0x0001): tried:
           '/Library/Developer/CoreSimulator/Volumes/iOS_20E247/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS
           16.4.simruntime/Contents/Resources/RuntimeRootffi_x1.framework/ffi_x1' (no such file),
           '/Library/Developer/CoreSimulator/Volumes/iOS_20E247/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS
           16.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/ffi_x1.framework/ffi_x1' (no such
           file), '/usr/lib/swift/ffi_x1.framework/ffi_x1' (no such file, not in dyld cache),

The problem seems to be multiple assets paths generated during dry run in _assetTargetLocations:

Map<AssetImpl, KernelAsset> _assetTargetLocations(
List<AssetImpl> nativeAssets) {
final Set<String> alreadyTakenNames = <String>{};
return <AssetImpl, KernelAsset>{
for (final AssetImpl asset in nativeAssets)
asset: _targetLocationIOS(asset, alreadyTakenNames),
};
}

Here the code generates different path for each architecture even if assetId is same. Probably requires similar treatment as https://github.com/flutter/flutter/pull/144688/files.

Fixing this fixes the hot reload, though TBH I don't know why during hot reaload the path from second native asset is used. Still, they are lipeod in reality so behavior of the function as it is now seems wrong and it shouldn't produce three different paths for same asssetId.

/cc @dcharkes

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: assetsPackaging, accessing, or using assetsplatform-iosiOS applications specificallyt: hot reloadReloading code during "flutter run"team-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions