Skip to content
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

Facefilter in Android Studio fails #711

Closed
matejsteinbacher opened this issue Aug 12, 2018 · 17 comments
Closed

Facefilter in Android Studio fails #711

matejsteinbacher opened this issue Aug 12, 2018 · 17 comments

Comments

@matejsteinbacher
Copy link

matejsteinbacher commented Aug 12, 2018

Hi again:

Failed to get Facefilter working.

Running gradle worked well until the installation of Opencv. See an excerpt of the error (running gradlew with additional --debug flag). It'd circle until manually stopped. It seems memory related error.

Thanks
Matej

14:55:45.019 [INFO] [com.android.build.gradle.tasks.CmakeServerExternalNativeJsonGenerator] [hunter *** DEBUG *** 2018-08-12T14:55:45] Locking directory: /home/matej/.hunter/_Base/Download/OpenCV/3.4.1-p1/a3f4f0a
14:55:49.340 [null] [org.gradle.process.internal.health.memory.MemoryManager] 
14:55:49.340 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 8274448384, Free: 4363202560}
14:55:49.340 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 8274448384, Free: 4363202560}
14:55:49.340 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 954728448, Committed: 355467264}
14:55:50.066 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running
14:55:50.066 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
14:55:50.067 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
14:55:50.067 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
14:55:50.067 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
14:55:50.067 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
14:55:50.068 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
14:55:54.340 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 8274448384, Free: 4363350016}
14:55:54.340 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 8274448384, Free: 4363350016}
14:55:54.340 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 954728448, Committed: 355467264}
14:55:59.340 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 8274448384, Free: 4363206656}
14:55:59.340 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 8274448384, Free: 4363206656}
14:55:59.340 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 954728448, Committed: 355467264}
14:56:00.066 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running
14:56:00.066 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
14:56:00.066 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
14:56:00.066 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
14:56:00.066 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
14:56:00.066 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
14:56:00.066 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
14:56:04.340 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory 
@ruslo
Copy link
Collaborator

ruslo commented Aug 12, 2018

See an excerpt of the error

I don't see any errors in logs. Can you check top, do you see any tasks there?

@matejsteinbacher
Copy link
Author

I may have expressed weirdly. In the meantime re-running the gradle and for 10 minutes, now, it outputs the same set of messages that all relate to the memory issue. This means that it is stuck somewhere. And it's always while trying to install OpenCV.

If I'm doing it correctly, then it might be a bug inside.

@ruslo
Copy link
Collaborator

ruslo commented Aug 12, 2018

In the meantime re-running the gradle and for 10 minutes, now, it outputs the same set of messages that all relate to the memory issue. This means that it is stuck somewhere.

It's a Gradle messages, from my experience if there is no logs from Gradle it doesn't mean that CMake stopped working. Checking the top will give you more relevant information.

@matejsteinbacher
Copy link
Author

matejsteinbacher commented Aug 12, 2018

The whole log. A set of messages from the line 6930 would repeat for 20 minutes (when I stopped it).

https://drive.google.com/open?id=1UPDN5Yo8LAxKttpguh0sMl_01E-Ugm7L

@headupinclouds
Copy link
Collaborator

The 3.2 beta builds (gradle "CMake Server" sessions) have been a little quirky -- builds that would run fine with an NDK toolchain have hit a few glitches in 3.2 beta (albeit less than w/ canary). It is probably worth adding a note to the README that this is bleeding edge territory. There is a CI workaround for gradle build issues in this unmerged PR: f94bbe0 for this bug report https://issuetracker.google.com/issues/75268076. Maybe it will help? As it happens, travis also has some reported issues in the last few days as well.

Have you tried a recent NDK toolchain build for the same commit? It would be useful to confirm that the core C++ libs are building in your environment.

I think we'll have something fairly stable running in .travis.yml once the PR is merged, which will at least be a reference.

@ruslo
Copy link
Collaborator

ruslo commented Aug 13, 2018

The whole log. A set of messages from the line 6930 would repeat for 20 minutes (when I stopped it).

Again, I don't see any errors in these logs. Also it's a gradle logs, if you think that something is wrong with it or you see some errors there feel free to report it to Android Studio/Gradle, here is an issue tracker: https://issuetracker.google.com

It is probably worth adding a note to the README that this is bleeding edge territory

See #712

Link to this part in rendered variant: https://github.com/elucideye/drishti/tree/pr.android.workarounds#android-studio-workarounds

Have you tried a recent NDK toolchain build for the same commit? It would be useful to confirm that the core C++ libs are building in your environment.

Note that it will not allow you to build facefilter application, just libraries and some command line utils. Android Studio is a requirement for building facefilter.

@headupinclouds
Copy link
Collaborator

@matejsteinbacher : The cmake_build_output.txt may have more details, you can find it in the log files here:

src/examples/facefilter/android-studio/app/.externalNativeBuild/cmake/debug/arm64-v8a/cmake_build_command.txt
src/examples/facefilter/android-studio/app/.externalNativeBuild/cmake/debug/arm64-v8a/cmake_build_output.txt
src/examples/facefilter/android-studio/app/.externalNativeBuild/cmake/debug/arm64-v8a/cmake_server_log.txt

I'll time ./gradlew assemblerelease for a fresh build (no cache entries) for reference.

@headupinclouds
Copy link
Collaborator

@matejsteinbacher : Can you provide your system details? I'd like to try to walk through the build this weekend to see if I can reproduce the issue. The CMake Server part seems to be a weak link for the Android Studio builds, but I've always been able to get the build working from macOS. There may be a similar issue in #718 (Windows build). Thanks.

@matejsteinbacher
Copy link
Author

@headupinclouds : I can run Android Studio's version (with AS 3.3 Canary 6) on Ubuntu but with a workaround. Compilation from the source wouldn't create "libfacefilter_bindings.so" needed by the FaceFilterFragment.java. I haven't gone into details but did an alternative - took the whole Java and C++ part out of the code and put it into my working implementation that linked drishti as a library. It compiled, worked but ran into a run-time error that happened after the confirmation of permissions. It looks that it's something wrong with a camera. Currently don't have time but will check this in the following days. Otherwise, I'm on Samsung, using API 24 with armeabi-v7a.

Hope it helps and looking forward
Matej

@headupinclouds
Copy link
Collaborator

I just ran through a fresh install on Ubuntu 18.04 LTS with Android Studio 3.2 RC 2 (August 24).

https://developer.android.com/studio/preview/

I ran the build directly through Android Studio and I was able to build and run without issue after stepping through the 1/2 dozen updates suggested by Android Studio. I will push the corresponding gradle config updates to the repository. I haven't tried AS 3.3 canary builds.

You might want to try clearing the local gradle .externalNativeBuild tree before building.

rm -rf src/examples/facefilter/android-studio/app/.externalNativeBuild

I'm going to repeat this from a Windows host next with the same version.

@matejsteinbacher
Copy link
Author

matejsteinbacher commented Aug 30, 2018

Now, I could build the application using Ubuntu 18.04.1 LTS with Android Studio 3.2 RC-2 and also AS 3.3 Canary 6. Device: Samsung J5 (SM-J530F, Android 7.0, API24).

In both cases the app ran but crashed after granting permission. Part of the error from the adb's logcat:

2018-08-30 12:18:31.680 2516-25953/? E/Camera3-Device: RequestThread: Can't get output buffer, skipping request: Broken pipe (-32)
2018-08-30 12:18:31.680 2516-25953/? E/Camera3-OutputStream: getBufferLocked: Stream 0: Can't dequeue next output buffer: Broken pipe (-32)
2018-08-30 12:18:31.680 2516-25953/? E/Camera3-Device: RequestThread: Can't get output buffer, skipping request: Broken pipe (-32)
2018-08-30 12:18:31.680 2516-25953/? E/Camera3-OutputStream: getBufferLocked: Stream 0: Can't dequeue next output buffer: Broken pipe (-32)
2018-08-30 12:18:31.680 2516-25953/? E/Camera3-Device: RequestThread: Can't get output buffer, skipping request: Broken pipe (-32)
2018-08-30 12:18:31.681 2516-25953/? E/Camera3-OutputStream: getBufferLocked: Stream 0: Can't dequeue next output buffer: Broken pipe (-32)
2018-08-30 12:18:31.681 2516-25953/? E/Camera3-Device: RequestThread: Can't get output buffer, skipping request: Broken pipe (-32)
2018-08-30 12:18:31.681 2516-25953/? E/Camera3-OutputStream: getBufferLocked: Stream 0: Can't dequeue next output buffer: Broken pipe (-32)
2018-08-30 12:18:31.681 2516-25953/? E/Camera3-Device: RequestThread: Can't get output buffer, skipping request: Broken pipe (-32)

Thanks
Matej

@headupinclouds
Copy link
Collaborator

headupinclouds commented Aug 30, 2018

Can you post the full device log? I'm curious what the first error is. Do you see a SIGSEGV before the looping output? Something like:

 libc    : Fatal signal 11 (SIGSEGV), code 2, fault addr ...

I see a few hits when searching for "Camera3-Device: RequestThread: Can't get output buffer" in GitHub issues, but nothing conclusive.

Android bug tracker reports a few hits, including this recent one:

https://issuetracker.google.com/issues/112697074

These are just some initial searches based on the part of the log you shared. I don't know enough to say if this is an application error or something similar to the bug report above.

I did see this mentioned as a workaround for an issue with similar error logs:

adb root
adb shell setprop camera.fifo.disable 1

Bug: 30898724
Change-Id: Ic3d1d15f9deb36b49e7d710d60fac969a98a1730

@matejsteinbacher
Copy link
Author

@headupinclouds
Copy link
Collaborator

Thanks, that is helpful. I'll see what I can find. I'm guessing a little, but I see thing fail shortly after this log:

ExynosCameraNode: [CAM_ID(1)][FLITE]-DEBUG(m_setFmt[1214]):type 9, 4144 x 2332, format 844257602, yuvRange 7

I haven't tested at that resolution. This is just a guess, but would you mind trying to limit the camera preview resolution and run again. It will require a small change here:

int area = psize.getHeight() * psize.getHeight();
if (area > maxArea)
{
maxArea = area;
previewSize = psize; // select max size
}

                    int area = psize.getHeight() * psize.getWidth(); // BUG 
                    if (area > maxArea && (psize.getWidth() < 2000))
                    {
                        maxArea = area;
                        previewSize = psize; // select max size
                    }

Actually, there is a small bug there too. I'll push a fix.

@matejsteinbacher
Copy link
Author

Thanks - this fix solved an issue.

Great work
Matej

@headupinclouds
Copy link
Collaborator

this fix solved an issue.

Just to be clear, you are able to run now, and it was the resolution restriction/workaround ((psize.getWidth() < 2000)) that let you run, right?

If you can build + run now I will close this issue and open one specific to the resolution limitation.

@matejsteinbacher
Copy link
Author

That's correct, it was a workaround that limited resolution. The bug (square of a height for an area) didn't matter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants