rainyl / opencv_dart

OpenCV bindings for Dart language and Flutter. Support Asynchronous Now!
https://pub.dev/packages/opencv_dart
Apache License 2.0
138 stars 18 forks source link

Got it working on simulator, issue on real device - what am I missing? #200

Closed xonaman closed 3 months ago

xonaman commented 3 months ago

Hey!

I am using version 1.2.1 and got everything working on the simulator (iOS).

When building for release and running that on a real device (iOS), I encounter the following issue:

Invalid argument(s): Failed to lookup symbol 'Image_IMRead_Async': dlsym(RTLD_DEFAULT, Image_IMRead_Async): symbol not found

I have looked into https://github.com/rainyl/opencv_dart/issues/144 and can confirm that opencv_dart.xcframework exists in ~/.pub-cache/hosted/pub.dev/opencv_dart-1.2.1/ios.

I think there must be some setting that I need to enable to make the libs shipping with the release build.

Can anyone help?

rainyl commented 3 months ago

@xonaman hello.

could you please take a look at whether the symbol is exists, you can refer to https://github.com/rainyl/opencv_dart/issues/24#issuecomment-2047320726

xonaman commented 3 months ago

I assume you mean symbols opencv_dart | grep IMRead. Here’s the output:

~/.pub-cache/hosted/pub.dev/opencv_dart-1.2.1/ios/opencv_dart.framework % symbols opencv_dart | grep IMRead
                0x000000000009a9b0 (   0x2f0) Image_IMRead [FUNC, EXT, NameNList, MangledNameNList, Merged, NList, FunctionStarts] 
                0x000000000009c460 (   0x340) Image_IMRead_Async [FUNC, EXT, NameNList, MangledNameNList, Merged, NList, FunctionStarts]
rainyl commented 3 months ago

Yes, it is.

did you run setup manually? since i see 'opencv_dart.framework', it should be 'opencv_dart.xcframework', and there should be two subdirectory in it, arm64 for real device and x86_64 for simulator, cd to arm64 and run 'symbols opencv_dart | grep IMRead', and then tell me the result please.

I do not use iPhone so can't test it by myself, what i can help is give you the possible solution, hope you won't be bored.

rainyl commented 3 months ago

@xonaman The correct structure of ~/.pub-cache/hosted/pub.dev/opencv_dart-1.2.1/ios should be like:

image

you can try to run setup manually with dart run opencv_dart:setup ios -a os64 -f and try again

xonaman commented 3 months ago

@rainyl After dart run opencv_dart:setup ios -a os64 -f, my ~/.pub-cache/hosted/pub.dev/opencv_dart-1.2.1/ios looks like this:

robertmainzer@MacBook-Pro-2 ios % find .                          
.
./Makefile
./opencv_dart.framework
./opencv_dart.framework/opencv_dart
./opencv_dart.framework/Info.plist
./libopencv_dart-ios-os64.tar.gz
./opencv_dart.xcframework
./opencv_dart.xcframework/ios-x86_64-simulator
./opencv_dart.xcframework/ios-x86_64-simulator/opencv_dart.framework
./opencv_dart.xcframework/ios-x86_64-simulator/opencv_dart.framework/opencv_dart
./opencv_dart.xcframework/ios-x86_64-simulator/opencv_dart.framework/Info.plist
./opencv_dart.xcframework/ios-arm64
./opencv_dart.xcframework/ios-arm64/opencv_dart.framework
./opencv_dart.xcframework/ios-arm64/opencv_dart.framework/opencv_dart
./opencv_dart.xcframework/ios-arm64/opencv_dart.framework/Info.plist
./opencv_dart.xcframework/Info.plist
./opencv_dart.podspec

I build with that again using flutter build ipa --release and still the error occurs.

rainyl commented 3 months ago

https://github.com/rainyl/opencv_dart/actions/runs/10259385478/job/28383772890?pr=204#step:5:116

I have no apple devices so can't test it, but it seems every thing is okay in the above logs.

not sure why.

abdelaziz-mahdy commented 3 months ago

may that help? i found it on tflite repo

image

i see that they show in the action logs, but maybe they get stripped somehow on running on device?

rainyl commented 3 months ago

may that help? i found it on tflite repo

image

i see that they show in the action logs, but maybe they get stripped somehow on running on device?

I think so.

rainyl commented 3 months ago

No response for a long time, I am going to close this issue, feel free to reopen it again if anyone still have more problems.

For the solution, please check the advice posted by abdelaziz-mahdy https://github.com/rainyl/opencv_dart/issues/200#issuecomment-2277701671, I cant test it.

kreazyme commented 3 months ago

I got the same problems :(

Device: Mac M1 14.4 Simulator
opencv_dart: ^1.2.1
3.24.0 Flutter SDK
symbols opencv_dart | grep IMRead
                0x000000000009a9b0 (   0x2f0) Image_IMRead [FUNC, EXT, NameNList, MangledNameNList, Merged, NList, FunctionStarts]
                0x000000000009c460 (   0x340) Image_IMRead_Async [FUNC, EXT, NameNList, MangledNameNList, Merged, NList, FunctionStarts]

Here is my pub folder

image
rainyl commented 3 months ago

@kreazyme try to set the strip style, https://docs.flutter.dev/platform-integration/ios/c-interop#stripping-ios-symbols

kreazyme commented 3 months ago

Finnaly, I try to run opencv_dart:setup and flutter clean && flutter pub get many of many times, and it's worked well. Many thank to @rainyl 😄

rainyl commented 3 months ago

Finnaly, I try to run opencv_dart:setup and flutter clean && flutter pub get many of many times, and it's worked well. Many thank to @rainyl 😄

Great! Thanks for your solution~

abdelaziz-mahdy commented 3 months ago

@kreazyme try to set the strip style, https://docs.flutter.dev/platform-integration/ios/c-interop#stripping-ios-symbols

I think that should be added to readme, to avoid the problem in the future

rainyl commented 3 months ago

I think that should be added to readme, to avoid the problem in the future

Agree, and a Q&A section is necessary.

xonaman commented 3 months ago

@abdelaziz-mahdy your solution worked in my case. Thank you so much!

abdelaziz-mahdy commented 3 months ago

glad to help <3

frg-x commented 2 months ago

I've tried all the solutions, but hadn't have success. Tried to run opencv_dart:setup and flutter clean && flutter pub get many of many times without any success. How to solve this issue? Thank you in advance! screenshot-20-09-2024-13-40-32 screenshot-20-09-2024-13-42-17 screenshot-20-09-2024-13-42-49 screenshot-20-09-2024-13-43-13

abdelaziz-mahdy commented 2 months ago

I've tried all the solutions, but hadn't have success. Tried to run opencv_dart:setup and flutter clean && flutter pub get many of many times without any success. How to solve this issue? Thank you in advance! screenshot-20-09-2024-13-40-32 screenshot-20-09-2024-13-42-17 screenshot-20-09-2024-13-42-49 screenshot-20-09-2024-13-43-13

Your issue is different, increase your minimum os version and it should work correctly

rainyl commented 2 months ago

@frg-x Get it, I am working on it.