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

Issue with TensorflowLite Interpreter in IOS release build #96

Open
shaheer20 opened this issue Jun 20, 2023 · 17 comments
Open

Issue with TensorflowLite Interpreter in IOS release build #96

shaheer20 opened this issue Jun 20, 2023 · 17 comments

Comments

@shaheer20
Copy link

I am passing the tflite file to the interpreter but it returns nothing. This is only happening when I download the IOS build from a test flight. Running an app with IDE works fine.

tfl.Interpreter? interpreter = await tfl.Interpreter.fromAsset('assets/config/mobilefacenet.tflite');

I have also tried

tfl.Interpreter.fromFile(File(path));

But this also doesn't return anything.

How I am testing: I have added a stack view with a Text widget on that and added logs into a string and print the text to check which line is executed. I am not getting any error even if I add this interpreter into try-catch. I have added a text before assigning the value to the interpreter and after the value is assigned to the interpreter only the before-added text shows not after one. This is why I am assuming it got stuck while assigning and didn't return anything.

@gregorscholz
Copy link
Contributor

can you maybe show more code?
it is hard to tell whats wrong from this snippet

@shaheer20
Copy link
Author

@gregorscholz This where I am getting the issue.
Screenshot 2023-06-21 at 1 05 00 PM

Now i am getting this Error in catch:
'error while loading invalid arguments(s): Failed to lookup symbol 'TfLiteModelCreate': dlsym(RTLD_DEFAULT, TfLiteModelCreate): symbol not found'

@gregorscholz
Copy link
Contributor

Did you double check if the model is correct? Maybe there is some error with the model?

@shaheer20
Copy link
Author

It is working fine on Android and IOS (debug) . The issue only occurs in the build i download from test flight for IOS.

@gregorscholz
Copy link
Contributor

gregorscholz commented Jun 22, 2023

Oh sorry, yea, mb.
I think i've read some time back someone had also problems with ios release build while it worked in debug.
I will try to find it

Edit:
Maybe one of those can help
shaqian/flutter_tflite#171 (comment)
tensorflow/tensorflow#49897 (comment)

@shaheer20
Copy link
Author

Thanks for the links.

shaqian/flutter_tflite#171 (comment):
This is showing how can i load the model. I don't have any issue with loading the model it just happens when I pass model to Interpreter. I have tried to get the model into a file and check the size that shows I am getting the right file and there is no issue in getting the file.

tensorflow/tensorflow#49897 (comment):
This example shows an error while compiling I only get an error when I run the app on an IOS device in release (From test flight).

@peazz
Copy link

peazz commented Jun 26, 2023

Was a solution found to this? I’m facing the same issues. Works fine in debug but release doesn’t on TestFlight

@shaheer20
Copy link
Author

Not yet. Did you try the below solution is any one of this works for you?
shaqian/flutter_tflite#171 (comment)
tensorflow/tensorflow#49897 (comment)

@kvanry
Copy link

kvanry commented Jun 26, 2023

@shaheer20 Did you follow this step: https://github.com/tensorflow/flutter-tflite#android--ios

Specifically:

When creating a release archive (IPA), the symbols are stripped by Xcode, so the command flutter build ipa may throw a Failed to lookup symbol ... symbol not found error. To work around this:

In Xcode, go to Target Runner > Build Settings > Strip Style
Change from All Symbols to Non-Global Symbols

I had a similar issue recently and that was the solution.

@shaheer20
Copy link
Author

@kvanry Thanks it works fine by changing All Symbols to Non-Global Symbols. But It's not working on iPhone 7.

@sarthakydv
Copy link

@PaulTR FireStore recommends statically linked libraries, is there a plan to make a more robust fix for this for better integration with other google products?

@denis-kolkov
Copy link

Hello. I have a similar problem in 2024. Everything works in the debug version, but the release version does't work. Xcode does't add the framework to the ipa file.

I'm using the latest version of tflite_flutter: ^0.10.4
Options:
Strip Style = Non-Global Symbols
Strip Linked Product = No

MacBook Pro Apple M1 Pro Sonoma 14.3 (23D56)
Xcode Version 15.2 (15C500b)

I also tried adding frameworks manually.
They are added to the ipa package, but the package cannot be installed or uploaded to TestFly.

Asset validation failed
Invalid Bundle. The bundle Runner.app/Frameworks/TensorFlowLite.framework does not support the minimum OS Version specified in the Info.plist. (ID: 8c2faa9d-72b6-4024-b1b2-4849a7aa2afe)

What am I doing wrong in my life? :)
Thanks in advance for your help.

@cs-milan-sadariya
Copy link

@gregorscholz This where I am getting the issue. Screenshot 2023-06-21 at 1 05 00 PM

Now i am getting this Error in catch: 'error while loading invalid arguments(s): Failed to lookup symbol 'TfLiteModelCreate': dlsym(RTLD_DEFAULT, TfLiteModelCreate): symbol not found'

For this issue issue you need to change XCode settings under the Target Runner. Follow the below 2 simple steps and your app will start to working in released mode also.

Step 1: In Xcode, go to Target Runner > Build Settings > Strip Style
Step 2: Change from All Symbols to Non-Global Symbols

@SantroTechneAi
Copy link

SantroTechneAi commented Jun 20, 2024

Hi @shaheer20 , Have you find our solution for your issue? I am facing same issue.Hello @cs-milan-sadariya, You provided solution not working.I am still facing "Failed to lookup symbol 'TfLiteModelCreate': dlsym(RTLD_DEFAULT, TfLiteModelCreate): symbol not found" for IOS

@cs-milan-sadariya
Copy link

@gregorscholz This where I am getting the issue. Screenshot 2023-06-21 at 1 05 00 PM
Now i am getting this Error in catch: 'error while loading invalid arguments(s): Failed to lookup symbol 'TfLiteModelCreate': dlsym(RTLD_DEFAULT, TfLiteModelCreate): symbol not found'

For this issue issue you need to change XCode settings under the Target Runner. Follow the below 2 simple steps and your app will start to working in released mode also.

Step 1: In Xcode, go to Target Runner > Build Settings > Strip Style Step 2: Change from All Symbols to Non-Global Symbols

@SantroTechneAi
try this solution it has worked for me and this solution is also available on flutter package code. Follow the below link:
tflite_flutter

@phobosbag
Copy link

same problem in release from TestFlight
Invalid argument(s): Failed to lookup symbol 'TfLiteModelCreate': dlsym(RTLD_DEFAULT, TfLiteModelCreate): symbol not found
#0 DynamicLibrary.lookup (dart:ffi-patch/ffi_dynamic_library_patch.dart:33)
#1 TensorFlowLiteBindings._TfLiteModelCreatePtr (package:tflite_flutter/src/bindings/tensorflow_lite_bindings_generated.dart:63)
#2 TensorFlowLiteBindings._TfLiteModelCreate (package:tflite_flutter/src/bindings/tensorflow_lite_bindings_generated.dart)
#3 TensorFlowLiteBindings.TfLiteModelCreate (package:tflite_flutter/src/bindings/tensorflow_lite_bindings_generated.dart)
#4 new Model.fromBuffer (package:tflite_flutter/src/model.dart:51)
#5 new Interpreter.fromBuffer (package:tflite_flutter/src/interpreter.dart:108)
#6 Interpreter.fromAsset (package:tflite_flutter/src/interpreter.dart:126)

I will try Non-Global Symbols solution

@phobosbag
Copy link

it is working

In Xcode, go to Target Runner > Build Settings > Strip Style
Change from All Symbols to Non-Global Symbols

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

9 participants