microsoft / microsoft/onnxruntime

[Mobile] OpenCV assertion failure on MediaTek devices (SM-A137F): Missing CPU baseline features

Open
#22,780 5 comments 1 reaction 0 assignees View on GitHub
contributions welcome platform:mobile
Dominant language
C++
Stars
21.9k
Forks
4.2k
Avg merge
4d 11h
Merged PRs (30d)
184

Description

### Describe the issue

## Issue Description
When attempting to initialize an ONNX Runtime inference session on a Samsung A13 (SM-A137F) with MediaTek MT6833 Dimensity 700 processor (ARM32 - armeabi-v7a), the app crashes with an OpenCV assertion error regarding missing CPU baseline features. This happens in even when using minimal CPU-only configuration options or any other set of options.

## Error Message
```
2024-11-08 17:31:09.911 4739-4937 cv::error() E OpenCV(4.5.4) Error: Assertion failed (Missing support for required CPU baseline features. Check OpenCV build configuration and required CPU/HW setup.) in initialize, file /Users/runner/work/1/b/android_aar/intermediates/armeabi-v7a/Release/_deps/opencv-src/modules/core/src/system.cpp, line 663
2024-11-08 17:31:09.911 4739-4937 libc++abi E terminating due to uncaught exception of type cv::Exception: OpenCV(4.5.4) /Users/runner/work/1/b/android_aar/intermediates/armeabi-v7a/Release/_deps/opencv-src/modules/core/src/system.cpp:663: error: (-215:Assertion failed) Missing support for required CPU baseline features. Check OpenCV build configuration and required CPU/HW setup. in function 'initialize'
````

## Expected Behavior
The inference session should initialize successfully with fallback to basic CPU features when advanced CPU features are not available.

## Additional Context

- The error occurs at the OpenCV/native level before any JavaScript options can take effect
- The crash is a fatal, uncaught assertion that cannot be caught by try-catch blocks
- This appears to be a compatibility issue between the prebuilt OpenCV libraries included with ONNX Runtime and certain MediaTek processors

### To reproduce

We are using the embedding model `jina-embeddings-v2-small-en-quantized` ([available on HF](https://huggingface.co/Xenova/jina-embeddings-v2-small-en/tree/main/onnx))

1. Create a React Native project with onnxruntime-react-native v1.17.0
2. Attempt to create an inference session with the following code:

```typescript
const options: InferenceSession.SessionOptions = {
executionProviders: ['cpu']
};

await InferenceSession.create(modelPath, options);
```

3. Run on a Samsung SM-A137F device

### Urgency

_No response_

### Platform

Android

### OS Version

14

### ONNX Runtime Installation

Released Package

### Compiler Version (if 'Built from Source')

_No response_

### Package Name (if 'Released Package')

onnxruntime-react-native

### ONNX Runtime Version or Commit ID

1.17.0

### ONNX Runtime API

Java/Kotlin

### Architecture

ARM32

### Execution Provider

Default CPU

### Execution Provider Library Version

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce with onnxruntime-react-native v1.17.0, the jina-embeddings-v2-small-en-quantized model, and a Samsung SM-A137F running Android 14. Start at the OpenCV error in modules/core/src/system.cpp line 663 and investigate the armeabi-v7a native initialization path. Done means the inference session initializes successfully on the affected device without the fatal missing-CPU-features assertion.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, cpp, react-native, typescript
Domain
computer-vision, machine-learning, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.