I am developing a prototype app, utilizing the tango depth camera for template matching. So far, I have been able to solve all problems with the help of already answered questions, documentation etc.
However, now I seem to have come to a stop. Last major change I made, was to draw a contour on the camera preview image, before displaying it. No matter what I do now, the app works for a while, before it crashes.
I have looked at heap dumps and allocation tracking in Android Studio. The only possibly weird thing there is that there can be a lot of memory on FinalizerReference objects in the heap dump...
I also tried moving the processing to an AsyncTask, and just skip every color frame until the task was done (so that only one task was running at a time) and the processed frame was displayed, but the problem remained.
I am using Google Tango for getting color and depth camera data and opencv in java for analyzing the data and doing the template matching.
Does someone have a clue of what these logcat messages mean?
Logcat errors:
E/lowmemorykiller: Error opening /proc/10173/oom_score_adj; errno=2
E/mm-camera-isp2: abf40_trigger_update:587 aec_ratio.ratio = 0.039062
W/ActivityManager: Scheduling restart of crashed service
com.lenovo.lsf.device/com.lenovo.lsf.push.service.PushService in 68068ms
W/ActivityManager: Scheduling restart of crashed service com.qualcomm.qti.modemtestmode/.MbnSystemService in 88020ms
E/InputDispatcher: channel '478a66c com.android.documentsui/com.android.documentsui.DocumentsActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
E/lowmemorykiller: Error writing /proc/10113/oom_score_adj; errno=22
E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 76)
E/lowmemorykiller: Error writing /proc/32408/oom_score_adj; errno=22
E/InputDispatcher: channel '85c4188 com.android.launcher3/com.android.launcher3.Launcher (server)' ~ Channel is unrecoverably broken and will be disposed!
E/mm-camera-isp2: abf40_trigger_update:587 aec_ratio.ratio = 0.000000
E/ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ id=332, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED] ]
E/mm-camera: mct_util_timer_handler:Error Backend stuck during HAL Command Raising SIGABRT
E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 76)
E/lowmemorykiller: Error writing /proc/32437/oom_score_adj; errno=22
E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 308)
E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 76)
E/lowmemorykiller: Error writing /proc/32437/oom_score_adj; errno=22
E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 76)
E/mm-camera: mct_util_timer_handler:Error Backend stuck during HAL Command Raising SIGABRT E/Surface: queueBuffer: error queuing buffer to SurfaceTexture, -32
E/Surface: queueBuffer: error queuing buffer to SurfaceTexture, -32
E/mm-camera: cpp_module_send_buf_divert_event:545] buffer event received with no divert config
E/mm-camera: cpp_module_send_buf_divert_event:545] buffer event received with no divert config
E/Camera3-OutputStream: getBufferLocked: Stream 0: Can't dequeue next output buffer: Broken pipe (-32)
E/Camera3-OutputStream: returnBufferCheckedLocked: Stream 0: Error queueing buffer to native window: Broken pipe (-32)
E/Camera3-Device: RequestThread: Can't get output buffer, skipping request: Broken pipe (-32)
E/Camera3-Device: Can't return buffer to its stream: Broken pipe (-32)
E/Camera3-OutputStream: getBufferLocked: Stream 0: Can't dequeue next output buffer: Broken pipe (-32)
E/Camera3-Device: RequestThread: Can't get output buffer, skipping request: Broken pipe (-32)
Code for displaying camera preview:
mTango.experimentalConnectOnFrameListener(TangoCameraIntrinsics.TANGO_CAMERA_COLOR, new Tango.OnFrameAvailableListener() {
byte[] imageByteArray = new byte[colorCameraIntrinsics.height * colorCameraIntrinsics.width * 3 / 2];
Mat yuvMat = new Mat( colorCameraIntrinsics.height + colorCameraIntrinsics.height/2, colorCameraIntrinsics.width, CvType.CV_8UC1 );
Bitmap bitmapDisplay = Bitmap.createBitmap( colorCameraIntrinsics.width, colorCameraIntrinsics.height, Bitmap.Config.ARGB_8888 );
Mat colorMatDisplay;
#Override
public void onFrameAvailable(TangoImageBuffer imageBuffer, int cameraId) {
Log.d(TAG, "onFrameAvailable: color frame available");
if (colorFrameCounter < 3) { //only use every 3rd frame
Log.d(TAG, "onFrameAvailable: skipping frame " + colorFrameCounter);
colorFrameCounter++;
} else {
colorFrameCounter = 0;
if (!stopCameraView.get()) { // Only view frame if camera view is not stopped
// convert image buffer data to byte array
imageBuffer.data.get(imageByteArray);
// byte array to Mat object with YUV coding (NV21)
yuvMat.put(0, 0, imageByteArray);
// locking access to lastColorFrameMat
synchronized (lockVar) {
Log.d(TAG, "onFrameAvailable: converting to bitmap");
// convert from YUV (NV21) Mat to RGBA Mat and place in lastColorFrameMat (global)
Imgproc.cvtColor(yuvMat, lastColorFrameMat, Imgproc.COLOR_YUV2RGBA_NV21, 4);
colorMatDisplay = lastColorFrameMat.clone();
}
if (templateContours != null) {
Imgproc.drawContours(colorMatDisplay, templateContours, templateContourMaxIdx, new Scalar(0, 255, 0, 255), 5);
}
// convert colorMatDisplay to bitmap, for display in imageview
Utils.matToBitmap(colorMatDisplay, bitmapDisplay);
Log.d(TAG, "onFrameAvailable: view lastColorFrameMat on phone display");
// View colorImage in imageViewer on UI thread
runOnUiThread(new Runnable() {
#Override
public void run() {
imageViewer.setImageBitmap(bitmapDisplay);
}
});
}
}
}
});
There are two things potentially happened here:
the buffer for camera image went out of scope.
With current Tango's SDK, the callee of onFrameAvailable callback only have control to imageBuffer within the scope of the callback. That means if you reference imageBuffer in an AsynTask, you could potentially get a null buffer, and result in a crash. The way Tango solve it is to always deep copy out the data from the callback, and process it in another thread.
the process is blocking Tango's thread for too long.
Without the AsyncTask, what's likely happened is that the processing blocked Tango's thread for too long, and this is know to be bad for Tango as well.
Related
My app worked fine at api29. Now getting this native error. No clue otherwise.
D/TransportRuntime.SQLiteEventStore: Storing event with priority=DEFAULT, name=FIREPERF for destination cct
V/FA: Connection attempt already in progress
V/FA: Connection attempt already in progress
D/TransportRuntime.JobInfoScheduler: Scheduling upload for context TransportContext(cct, DEFAULT, MSRodHRwczovL2ZpcmViYXNlbG9nZ2luZy1wYS5nb29nbGVhcGlzLmNvbS92MS9maXJlbG9nL2xlZ2FjeS9iYXRjaGxvZ1xBSXphU3lDY2traUg4aTJaQVJ3T3MxTEV6RktsZDE1YU9HOG96S28=) with jobId=-546033166 in 30000ms(Backend next call timestamp 1639520060629). Attempt 1
D/mainact: buildDisplayDataBase:
A/libc: fdsan: attempted to close file descriptor 75, expected to be unowned, actually owned by FILE* 0xf108246c
Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 20661 (eymoreau.fitlog), pid 20661 (eymoreau.fitlog)
Disconnected from the target VM, address: 'localhost:60917', transport: 'socket'
If you are displaying images try eliminating them to see of it fixes the error.
It did for me and I ended up changing my image loading from:
mainMenu_viewHolder.getImageView().setImageResource(R.drawable.gear);
to...
Bitmap checkImg = BitmapFactory.decodeResource(fragment.getResources(), R.drawable.check);
mainMenu_viewHolder.getImageView().setImageBitmap(checkImg);
The issue is buried very deep so if this doesn't work for you don't try stepping through your code or researching the native error. It will be wasted time. Just disable your fragments entire view structure and add back in piece by piece.
I have error while take screenshot on surface. After a lot of pictures, this error is made (it comes with the device), but the application does not stop.
After a lot of pictures, this method is no longer working. Do you have an idea about how to solve problems?
#SuppressLint("NewApi")
public static void request(Activity activity, SurfaceView surfaceView, OnScreenShotFinishedListener onScreenShotFinishedListener) {
// Create a bitmap the size of the scene surfaceView.
final Bitmap bitmap = Bitmap.createBitmap(surfaceView.getWidth(), surfaceView.getHeight(), Bitmap.Config.ARGB_8888);
// Create a handler thread to offload the processing of the image.
final HandlerThread handlerThread = new HandlerThread("PixelCopier" + String.valueOf(new Random().nextInt()));
handlerThread.start();
// Make the request to copy.
PixelCopy.request(surfaceView, bitmap, (copyResult) -> {
activity.runOnUiThread(() -> onScreenShotFinishedListener.onScreenShotFinished(copyResult, bitmap));
Log.d("MyData", bitmap.toString());
handlerThread.quitSafely();
handlerThread.interrupt();
}, new Handler(handlerThread.getLooper()));
}
2019-01-29 18:36:07.361 23730-23768/ge.bunny.giffer E/Parcel: dup() failed in Parcel::read, i is 0, fds[i] is -1, fd_count is 2, error: Too many open files
2019-01-29 18:36:07.361 23730-23768/ge.bunny.giffer W/OpenGLRenderer: Failed to get last queued buffer, error = -22
I have seen the same error when using PixelCopy to grab the contents of a SurfaceView continuously (ie. for video transmission). I saw this effect only on Android 7.0 devices.
I attribute this to a memory leak that was present in Readback.cpp which, if I'm not wrong, is what PixelCopy uses internally.
https://github.com/aosp-mirror/platform_frameworks_base/commit/8a29c0ec86a9411a07bb10018c3da69fffc0fe7d#diff-3f79906243073ec92400b65644d330654c8b349e6317259e9639f3a026347d17
This fix was added on September 1st 2016, while Android 7.0 was released August 22nd 2016,
I'm using webcam capture to get a webcam image in Java via the following code:
Webcam webcam = Webcam.getWebcamByName("VF0415 Live! Cam Vid. IM Ultra 1"); // USB webcam
webcam.open();
BufferedImage image = webcam.getImage();
ImageIO.write(image, "JPG", new File("test.jpg"));
Unfortunately, I get a timeout with the following error:
[main] INFO com.github.sarxos.webcam.Webcam - WebcamDefaultDriver capture driver will be used
[atomic-processor-1] INFO com.github.sarxos.webcam.ds.cgt.WebcamOpenTask - Opening webcam VF0415 Live! Cam Vid. IM Ultra 1
[frames-refresher-[1]] ERROR com.github.sarxos.webcam.ds.buildin.WebcamDefaultDevice - Timeout when requesting image!
[shutdown-hook-1] INFO com.github.sarxos.webcam.WebcamShutdownHook - Automatic VF0415 Live! Cam Vid. IM Ultra 1 deallocation
[shutdown-hook-1] INFO com.github.sarxos.webcam.Webcam - Disposing webcam VF0415 Live! Cam Vid. IM Ultra 1
[frames-refresher-[1]] ERROR com.github.sarxos.webcam.ds.buildin.WebcamDefaultDevice - Timeout when requesting image!
I've looked through related issues on GitHub, and I've tried keeping my USB power on and intercepting the OS signals, but the error messages remain the same, giving me an essentially black image, as shown here:
Is there anything else I can try to fix this?
I am working with the ARToolKit sample app ARSimple on Android. Instead of having it track the hiro marker, I want to track an NFT marker. So I am using:
int testMarker = ARToolKit.getInstance().addMarker("2d;data/nft/Test.jpg");
According to the documentation, that is the right way to add an NFT marker (unless I've missed something).
This gives the following output:
E/libARWrapper: ARController (native): [error]Error: Unknown marker type '2d' in config '2d;data/nft/Test.jpg'.
E/libARWrapper: ARController (native): [error]Error: Failed to load marker.
Which would appear to suggest it is not the right way to do it. So how do I add an NFT marker?
Edit:
With the changes from Thor_Bux's answer applied, my code becomes:
public boolean configureARScene() {
pinballMarker = ARToolKit.getInstance().addMarker("nft;data/pinball");
if (pinballMarker == -1) return false;
return true;
}
The files pinball.fset, pinball.fset3 and pinball.iset are located in my assets/Data directory.
Error message is now the following:
E/libar: Error: unable to open file 'data/pinball.iset' for reading.
E/libar: Error opening file 'data/pinball.iset'.
E/libARWrapper: ARController (native): [error]Error reading data from data/pinball.fset
E/libARWrapper: ARController (native): [error]Error: Failed to load marker.
Edit:
After uninstalling the app, like Thor_Bux suggested, and changing the configuration to nft;Data/pinball, the marker loads. But there is still an error message:
E/libARWrapper: ARController (native): [error]Loading Data/pinball.fset.
I/libar: ### Surface No.1 ###
I/libar: Read ImageSet.
I/libar: Imageset contains 8 images.
D/Camera-JNI: Using callback buffer from queue of length 9
D/Camera-JNI: Using callback buffer from queue of length 8
D/Camera-JNI: Using callback buffer from queue of length 7
D/Camera-JNI: Using callback buffer from queue of length 6
D/Camera-JNI: Using callback buffer from queue of length 5
D/Camera-JNI: Using callback buffer from queue of length 4
D/Camera-JNI: Using callback buffer from queue of length 3
D/Camera-JNI: Using callback buffer from queue of length 2
D/Camera-JNI: Using callback buffer from queue of length 1
D/Camera-JNI: Out of buffers, clearing callback!
I/libar: end.
I/libar: Read FeatureSet.
I/libar: end.
E/libARWrapper: ARController (native): [info]First NFT marker added; enabling NFT marker detection.
E/libARWrapper: ARController (native): [info]Added marker (UID=0), total markers loaded: 1.
Even though the marker appears to have loaded successfully it is not detected with queryMarkerVisible(). Furthermore it seems SimpleRenderer#draw() is never called despite the scene being configured successfully.
from the previous conversation it looks like you are working with this example code and want to change this line of code to make it track NFT markers:
https://github.com/artoolkitx/artoolkit5/blob/master/AndroidStudioProjects/ARSimpleProj/aRSimple/src/main/java/org/artoolkit/ar/samples/ARSimple/SimpleRenderer.java#L72
You also state that you already created the needed NFT .fset and .iset files as described here: https://archive.artoolkit.org/documentation/doku.php?id=3_Marker_Training:marker_nft_training
What you now need to do is to add the fset and iset files into the 'assets/Data/' directory of your project. (Right next to the hiro.patt)
Then you change the mentioned line of code to this:
nft;data/pinball
Which is documented here:
https://github.com/artoolkitx/artoolkit5/blob/master/AndroidStudioProjects/ARBaseLibProj/aRBaseLib/src/main/java/org/artoolkit/ar/base/ARToolKit.java#L303
and
https://github.com/artoolkitx/artoolkit5/blob/master/lib/SRC/ARWrapper/ARMarker.cpp#L239
Hope that helps
I am using a custom camera to record Videos on android.
The device experiencing the issue is a Nexus 5 with Android 6.0.1 on it.
When the camera finishes recording for only for the 2nd time, i get the following exception in the under-the-hood android media AudioTrack class. This is something that is called implicitly by android, by the FinalizerDaemon, and not as a result of any code I execute directly. So the FinalizerDaemon calls finalize on AudioTrack, and gets an IllegalStateException.
12-02 09:20:23.155 23705-23714/social.ivideo.greetings E/System: Uncaught exception thrown by finalizer
12-02 09:20:23.160 23705-23714/social.ivideo.greetings E/System: java.lang.IllegalStateException: Binder has been finalized!
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:615)
at com.android.internal.app.IAppOpsService$Stub$Proxy.stopWatchingMode(IAppOpsService.java:435)
at android.media.PlayerBase.baseRelease(PlayerBase.java:136)
at android.media.AudioTrack.finalize(AudioTrack.java:979)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:222)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:209)
at java.lang.Thread.run(Thread.java:761)
Perhaps I need to do some sort of clean up when the camera finishes recording? Here's the current code I'm using when the recording stops:
#Override
public void stopRecording(boolean wasCancelled, float duration) {
if (mMediaRecorder != null) {
mMediaRecorder.stop();
mMediaRecorder.reset();
if (flashState) {
toggleFlash();
}
if (!wasCancelled) {
callbacks.onFinishedRecording(null, mediaPath, duration, wasCancelled);
}
}
}
mMediaRecorder is an instance of MediaRecorder class.
Any suggestions?
So I think this might be an Android bug. Looks suspiciously like this issue, which is marked as fixed in a "future version": https://issuetracker.google.com/issues/37138597
Same Issue Reported in Android 7.1.2
fixed in Android 8.0 https://android.googlesource.com/platform/frameworks/base/+log/aee6ee94675d56e71a42d52b16b8d8e5fa6ea3ff/media/java/android/media/PlayerBase.java