googlesamples / android-vision

Deprecated: The Mobile Vision API is now a part of ML Kit: Check out this repo:
https://github.com/firebase/quickstart-android/tree/master/mlkit
Apache License 2.0
2.93k stars 1.73k forks source link

Vision 8.4.0 still crashes on some images #58

Open eicm opened 8 years ago

eicm commented 8 years ago

I see crashes on some images using the 8.4.0, here's the sample image that it crashes on:

2012-08-05 16 55 18 medium

This is what I do for down sampling:

private int calculateInSampleSize(MediaData mediaData) { int inSampleSize = 1;

    if (mediaData.getHeight() > 400 || mediaData.getWidth() > 400) {

        final int halfHeight = mediaData.getHeight() / 2;
        final int halfWidth = mediaData.getWidth() / 2;

        // Calculate the largest inSampleSize value that is a power of 2 and keeps both
        // height and width larger than the requested height and width.
        while ((halfHeight / inSampleSize) > 400
                && (halfWidth / inSampleSize) > 400) {
            inSampleSize *= 2;
        }
    }

    return inSampleSize;
}
pm0733464 commented 8 years ago

What kind of crashes? Can you provide the log output?

eicm commented 8 years ago

@pm0733464 This is the crash out put: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x3030b0c911ea51 in tid 2118 (cedetectiontest)

You can save the image from the above link and try it. The image is 1366 * 767, if I down sample it by factor of 2 it wouldnt crash.

pm0733464 commented 8 years ago

I tried the image above without the SafeDetector, and it works for me with 8.4.

Please check that you have Google Play services 8.4 on the device (this may be different than the version that you compile your app with). You can find this version by navigating the following on your device:

Settings > Apps > All > Google Play services

What version is shown there?

eicm commented 8 years ago

@pm0733464 The device is running 8.4.89(2428711-036). I just tried the image from the link I posted and it crashed.

eicm commented 8 years ago

01-04 09:10:20.058 4671-4745/ A/libc: Fatal signal 11 (SIGSEGV) at 0x7ded6000 (code=1), thread 4745 (Thread-805)

pm0733464 commented 8 years ago

Try clearing the native library (which should trigger a new download), and see if it still crashes:

adb root adb shell rm -rf /data/data/com.google.android.gms/files/com.google.android.gms.vision

If it's still crashing, I suspect that it could be a memory issue rather than the original bug. It's a known issue that the native library could be more resilient w.r.t. handling OOM conditions. The scaled down version of the image might be avoiding the issue because it doesn't require as much additional memory allocation to do face detection.

In any case, I suggest that you stick with the SafeDetector for now if that avoids the problem for you.

eicm commented 8 years ago

@pm0733464 No it still crashes, and it also crashes using SafeDetecor. What is the best way to handle these type of native crashes?

pm0733464 commented 8 years ago

It's probably a different issue.

As I said above, I suspect that the app is short on memory before calling into the detector, and it crashes due to OOM. If this is the issue, then the only way around it is to use less memory in your app (e.g., avoid holding references to lots of big images).

eicm commented 8 years ago

@pm0733464 The app doesn't use much memory maybe around 12 MB when it crashes on this image. I just created a sample app that does nothing but runs the detect function on this image and it crashes.

eicm commented 8 years ago

@pm0733464 Here's the link to the test app: https://drive.google.com/file/d/0B1bMZaI8m0GFcXQyVFFyS3Q2Qmc/view?usp=sharing

eicm commented 8 years ago

@pm0733464 Did you get a chance to try it. Follow is the problematic image: testing.jpg.zip

SjoerdvGestel commented 8 years ago

im having the same issue with htc m8 01-14 10:56:29.406 5686-6073/com.app.debug A/libc: invalid address or address of corrupt block 0xb8f64cd8 passed to dlfree 01-14 10:56:29.406 5686-6073/com.app.debug A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0xdeadbaad in tid 6073 (AsyncTask #2)

input image was 1024px width, fixed it by re-sizing the bitmap to 300px fed to the detector fixed it

pm0733464 commented 8 years ago

We'll take a look. In the short term, I'd recommend scaling down the images first before calling into the face detector, if that avoids the issue.