-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[Mobile] IOS library crashes in Release configuration #21960
Comments
I don't think any of us are familiar with UnrealEngine or that plugin, and the link returns a 404 for me. I'm not aware of anyone else having an issue running on iOS though so the plugin could potentially be the issue. However if it's checked into the UnrealEngine source I would assume it works for others. Can you provide a stack trace from the crash? The code using OrtApi that crashes would be helpful too. Are you creating the OrtEnv instance before making any other calls and keeping it valid until the end? |
In order to see the Unreal Engine Github Repository, you have to join the Epic Games Organisation. The code causing the crash is rather simple Here is the stack trace using |
Relevant files in the Unreal Engine are:
|
Based on the stack it's crashing when registering the internal ORT operator schemas.
That code is run for every usage of ORT on all platforms. If there was something wrong with it it should break everywhere. Your issue may be due to creating the Ort::Env with a nullptr. That hits a ctor which doesn't actually create a valid environment. struct Env : detail::Base<OrtEnv> {
explicit Env(std::nullptr_t) {} ///< Create an empty Env object, must be assigned a valid one to be used
/// \brief Wraps OrtApi::CreateEnv
Env(OrtLoggingLevel logging_level = ORT_LOGGING_LEVEL_WARNING, _In_ const char* logid = ""); You could try creating it with no arguments as that would hit the second constructor. |
I've changed the env variable definition to In the mean time I've also removed the embedding of the framework, as it's a static library for IOS, by changing the Unreal plugin code to: if (Target.Platform == UnrealTargetPlatform.IOS)
{
PublicAdditionalFrameworks.Add(new Framework(
"ONNXRuntime",
Path.Combine(PluginDirectory, "Binaries", "ThirdParty", "Onnxruntime", Target.Platform.ToString(), "onnxruntime.xcframework")
));
} This also didn't solve the issue. However I didn't manage to add the compiler flags only for the Unreal plugin, which are set in the Cocoapod |
I wouldn't have thought so. They're about restricting symbol visibility, but your issue is not an unresolved symbol. Based on the crash info it appears something is off with how memory is being allocated/freed. AFAIK ORT isn't doing anything special here and as it's happening at startup we haven't done much at all at that point. Given we haven't seen this issue previously and that code is always run on all platforms I would suspect something about what NNERuntimeORT + Unreal Engine is doing is the cause and you should be asking the developers of that for assistance. e.g. maybe something limits the memory or changes how memory allocation/free works by overriding malloc/free and the optimization only happens in a release build. |
That is only the definition of the
|
Given the plugin you're using doesn't officially support usage on mobile and the ORT environment initialization works fine everywhere else (including iOS example applications we have) I would expect the issue is with the plugin. https://forums.unrealengine.com/t/course-neural-network-engine-nne/1162628/158 |
To avoid any relation between the issue and the |
Anyone else got any idea here? I really need to fix this issue 😓 |
Describe the issue
Hi,
I'm currently adding the Android & IOS library to the Unreal Engine 5.4
NNERuntimeORT
plugin. Android works fine in Development & Release, however IOS only works inDebug
, not inRelease
builds. I've used the following code to include the framework to the plugin:The framework is always correctly included in the
Frameworks
folder in the app, but as soon as theOrtApi
is used, the app crashes. I also tried to useORT_API_MANUAL_INIT
and manually init the API, which didn't change anything. I've also tried binaries fromnuget
, as well asdownload.onnxruntime.ai/pod-archive-onnxruntime-c
. Also tried versions1.14.0
,1.14.1
as well as1.19.1
all versions with exactly the same behaviour.To reproduce
NNERuntimeORT
plugin (recommended to use latest version from ue5-main branch)Shipping
mode withBuild for Distribution
enabledUrgency
I'm near the deadline for the next release, which is why I wanted to create a shipping build for the final testing.
Platform
iOS
OS Version
17.6.1
ONNX Runtime Installation
Released Package
Package Name (if 'Released Package')
onnxruntime-c
ONNX Runtime Version or Commit ID
1.14.1
ONNX Runtime API
C++/C
Architecture
ARM64
Execution Provider
Default CPU
The text was updated successfully, but these errors were encountered: