rainyl / opencv_dart

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

Crash when trying to for loop contour in release mode iOS #148

Closed Codestian closed 4 months ago

Codestian commented 4 months ago

Describe the bug I'm trying to find contours in an image, but the app crashes when i try to run a for loop even with nothing inside it. This only happens in release mode for iOS, haven't tested for Android yet. This also seems to happen if the size of the contour list is larger than roughly 300.

What boggles my mind further is if i put a random print("hello") statement before the for loop, it is less likely to crash but as long as contour list is still low.

To Reproduce Steps to reproduce the behavior:

  1. Create the following:
    
    (Contours, Mat) contour = cv.findContours(
    imageMat, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE);

final Contours contourList = contour.$1;

2. Attempt to `for loop` the list:

for (final contour in contourList) {}


3. Run it in debug mode then release mode.

**Expected behavior**
The code should run through just fine.

**Screenshots**
-

**Desktop (please complete the following information):**
 - macOS

**Smartphone (please complete the following information):**
 - iPhone 13 (physical device)

**Additional context**
IOS crash logs indicate something about EXC_GUARD and GUARD_TYPE_USER.
Codestian commented 4 months ago

Uh issue solved, just need to wrap for loop in a try catch. Silly me.

rainyl commented 4 months ago

Well... Could you please post the full crash log?

try catch just handles the exception but it still exists, I am not an apple user so can't reproduce it, more info is needed to debug.