Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [mediapipe_text] Failed to load dynamic library 'arm64_libtext.framework/arm64_libtext' on IOS emulator #55

Open
youngjun-k opened this issue May 24, 2024 · 4 comments

Comments

@youngjun-k
Copy link

youngjun-k commented May 24, 2024

I tested the mediapipe_text with the following instructions from the readme.
It works perfectly on macOS and Android emulators. However, all three of the models do not work on the iOS emulator. and they generate the same error all across.

If I run the example app it says that it failed to load dynamic library
'text.framework/text'
but if I run on my project it requires this dynamic library
'arm64_libtext.framework/arm64_libtext'

flutter doctor

[✓] Flutter (Channel master, 3.23.0-4.0.pre.1, on macOS 14.5 23F79
    darwin-arm64, locale en-KR)
[✓] Android toolchain - develop for Android devices (Android SDK
    version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
[✗] Chrome - develop for the web (Cannot find Chrome executable at
    /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome
      executable.
[✓] Android Studio (version 2023.3)
[✓] VS Code (version 1.89.1)
[✓] Connected device (3 available)
[✓] Network resources

Here are the error logs.

[ERROR:flutter/runtime/dart_isolate.cc(1291)] Unhandled exception:
Invalid argument(s): Couldn't resolve native function 'text_embedder_create' in
'package:mediapipe_text/src/io/third_party/mediapipe/generated/mediapipe_text_bindings.dart' : Failed to load
dynamic library 'arm64_libtext.framework/arm64_libtext': Failed to load dynamic library
'arm64_libtext.framework/arm64_libtext': dlopen(arm64_libtext.framework/arm64_libtext, 0x0001): tried:
'/Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS
17.4.simruntime/Contents/Resources/RuntimeRootarm64_libtext.framework/arm64_libtext' (no such file),
'/Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS
17.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/arm64_libtext.framework/arm64_libtext' (no such
file), '/usr/lib/swift/arm64_libtext.framework/arm64_libtext' (no such file, not in dyld cache),
'/Users/youngjun/Library/Developer/CoreSimulat<…>

@youngjun-k
Copy link
Author

youngjun-k commented May 24, 2024

And Android App Bundle also failed. Because null check operator used on a null value in build.dart file for downloading the sdks from cloud storage.

for (final String arch in archKeys) {
    final assetUrl = sdkDownloadUrls[targetOs]!['libtext']![arch]!;
    final downloadFileLocation = buildConfig.outDir.resolve(
      '${arch}_${assetUrl.split('/').last}',
    );
    log('downloadFileLocation: $downloadFileLocation');
    buildOutput.assets.add(
      Asset(
        id: 'package:mediapipe_text/src/io/third_party/mediapipe/generated/mediapipe_text_bindings.dart',
        linkMode: LinkMode.dynamic,
        target: Target.fromArchitectureAndOs(
            Architecture.fromString(arch), buildConfig.targetOs),
        path: AssetAbsolutePath(downloadFileLocation),
      ),
    );
    if (!buildConfig.dryRun) {
      downloadAsset(assetUrl, downloadFileLocation);
    }
  }

Therefore, I needed to add this line of code for the null check.

    if (targetOs == 'android' && (arch == 'arm' || arch == 'x64')) {
      continue;
    }

additional logs from the IOS

[  +15 ms] Generating
/Users/youngjun/Conversation/android/app/src/main/java/io/flutter/plugins/Genera
tedPluginRegistrant.java
[ +381 ms] Dry running native assets for ios.
[  +13 ms] config.json contents: {
             "dry_run": true,
             "link_mode_preference": "dynamic",
             "out_dir":
             "/Users/youngjun/Conversation/.dart_tool/native_assets_builder/dry_
             run_build_ios_dynamic/out/",
             "package_name": "mediapipe_text",
             "package_root":
             "/Users/youngjun/.pub-cache/hosted/pub.dev/mediapipe_text-0.0.1/",
             "supported_asset_types": [
               "native_code"
             ],
             "target_os": "ios",
             "version": "1.3.0"
           }
[   +2 ms] Running `/Users/youngjun/flutter/bin/dart
--packages=/Users/youngjun/Conversation/.dart_tool/package_config.json
/Users/youngjun/.pub-cache/hosted/pub.dev/mediapipe_text-0.0.1/build.dart
--config=/Users/youngjun/Conversation/.dart_tool/native_assets_builder/dry_run_b
uild_ios_dynamic/config.json`.

@youngjun-k youngjun-k changed the title 🐛 [mediapipe_text] Failed to load dynamic library 'text.framework/text' on IOS emulator 🐛 [mediapipe_text] Failed to load dynamic library 'arm64_libtext.framework/arm64_libtext' on IOS emulator May 24, 2024
@craiglabenz
Copy link
Collaborator

Do you have an Intel or ARM Mac? If you have an Intel Mac, the error is probably that the ARM SDK is being selected; yet the system believes mobile devices always imply ARM.

This is a known issue, as we haven't yet gotten around to recompiling the iOS and Android SDKs for Intel architectures. Only developers using mobile simulators on Intel Macs should hit this issue.

@youngjun-k
Copy link
Author

I don't think the issue is related to the architecture support. because If you see my flutter doctor log, you can see that I am using an ARM Mac.

[✓] Flutter (Channel master, 3.23.0-4.0.pre.1, on macOS 14.5 23F79
darwin-arm64, locale en-KR)

@craiglabenz
Copy link
Collaborator

craiglabenz commented Jun 5, 2024

Apologies - I missed that you're on ARM.

The issue appears to be this out of the crash:

incompatible platform (have 'iOS', need 'iOS-sim'))

I'll talk to the relevant folks internally about the right way to handle this.

For Googlers: b/345243192

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants