onnxruntime: [Mobile] onnxruntime-c and onnxruntime-extensions-c pod conflict with DocumentReader pod

Describe the issue

My app already contains the DocumentReader pod from Regula(https://github.com/regulaforensics/DocumentReader-iOS) then add “pod ‘onnxruntime-objc’, ‘1.14.0’” and App runs fine.

When I have tried to create
auto m_envPtr = Ort::Env(); It gives EXC_BAD_ACCESS error.

For testing purposes I have removed the DocumentReader pod then It is working fine.

Please check the screenshot given. image

Please help me how to fix this issue. Thanks!

To reproduce

Download the project from this repo(https://github.com/microsoft/onnxruntime-inference-examples/tree/main/mobile/examples/super_resolution/ios/ORTSuperResolution) and just add the following pod in the Podfile.

pod 'DocumentReader', '~> 6.1'

Then just run the app on the device or simulator you will get the same error as mentioned above.

Urgency

No response

Platform

iOS

OS Version

16.3.1

ONNX Runtime Installation

Built from Source

Compiler Version (if ‘Built from Source’)

No response

Package Name (if ‘Released Package’)

None

ONNX Runtime Version or Commit ID

1.14.0

ONNX Runtime API

C++/C

Architecture

X64

Execution Provider

Default CPU

Execution Provider Library Version

No response

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 17 (12 by maintainers)

Most upvoted comments

Not clear why/where that old version is coming from though. I don’t see any dependency on that in the DocumentReader pods.

Looks like there is a shared library, DocumentReaderCore:

% file Pods/DocumentReaderFullRFID/DocumentReaderCore.xcframework/ios-arm64_x86_64-simulator/DocumentReaderCore.framework/DocumentReaderCore
Pods/DocumentReaderFullRFID/DocumentReaderCore.xcframework/ios-arm64_x86_64-simulator/DocumentReaderCore.framework/DocumentReaderCore: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [arm64]
Pods/DocumentReaderFullRFID/DocumentReaderCore.xcframework/ios-arm64_x86_64-simulator/DocumentReaderCore.framework/DocumentReaderCore (for architecture x86_64):        Mach-O 64-bit dynamically linked shared library x86_64
Pods/DocumentReaderFullRFID/DocumentReaderCore.xcframework/ios-arm64_x86_64-simulator/DocumentReaderCore.framework/DocumentReaderCore (for architecture arm64): Mach-O 64-bit dynamically linked shared library arm64

which exports symbol _OrtGetApiBase.

% nm -g Pods/DocumentReaderFullRFID/DocumentReaderCore.xcframework/ios-arm64_x86_64-simulator/DocumentReaderCore.framework/DocumentReaderCore | grep OrtGetApiBase
0000000000b0c550 T _OrtGetApiBase

The static library in onnxruntime-c also has a symbol with the same name.

I’m able to reproduce the issue with a build on main.

This line in the output window provides a clue: The given version [15] is not supported, only version 1 to 10 is supported in this build.

Upon closer inspection, I noticed a similar line appears in your screenshot too.

The message is kind of cryptic. It comes from here: https://github.com/microsoft/onnxruntime/blob/c57cf374b67f72575546d7b4c69a1af4972e2b54/onnxruntime/core/session/onnxruntime_c_api.cc#L2677-L2685

Used by the C++ API here: https://github.com/microsoft/onnxruntime/blob/c57cf374b67f72575546d7b4c69a1af4972e2b54/include/onnxruntime/core/session/onnxruntime_cxx_api.h#L114-L121

This message means there is a mismatch between the ORT_API_VERSION value defined in the header file and the one in the ORT library, with the former being too new. Moreover, the result of GetApi(ORT_API_VERSION) will be nullptr, which is probably why we see the BAD_ACCESS error. There’s no check for GetApi(ORT_API_VERSION)'s result being null before GetApi() dereferences it and the Env constructor tries to use the result of GetApi(): https://github.com/microsoft/onnxruntime/blob/c57cf374b67f72575546d7b4c69a1af4972e2b54/include/onnxruntime/core/session/onnxruntime_cxx_inline.h#L410-L411

It seems that after adding the DocumentReaderFullRFID pod, the app starts using an older version of ORT. If you don’t require ORT 1.14, you could try using an older version like 1.10 (where ORT_API_VERSION == 10) or earlier.

I think we can also make this message clearer.