Android LogCat shows BufferQueueProcedure

泄露秘密 提交于 2019-12-14 02:38:10

问题


At first please excuse my bad English. I have a final version of my App (school work) - it is taking photos and after that photos are being stitched using c++ code. I tested the app on my phone Xperia mini API 15 where everything is OK on this device. But I borrowed school Nexus 5 API 21 and there are two problems.

First problem is frustrating. Today, I was debugging all day without solution. I have no idea, which part of code can make this error. Whenever the app is running - don't matter if it's taking photo or stitching, LogCat shows thousands of these error:

Tag: BufferQueueProceducer Text: [unnamed-3046-0] dequeueBuffer: Bufferqueue has been abandoned

The code is stopped after this error. Unfortunately I can be more specific, because I don't know. where the cause can be.

Second problem is only in process of stitching photos, when suddenly Application not responding (ANR) shows. But when I click on Wait, app continues with stitching photos. Result is good, but the dialog is annoying. I found solution on this page - problem is in runtime environment ART. I wanted to change runtime environment from ART to Dalvik, but Nexus 5 don't have option for change. Is there another choise? Error in LogCat:

Tag: art  Thread[5,tid=6270, `WaitingInMainSignalCatcherLoop,Thread*=0xf60e40,peer=0x12c00080,"Signal Catcher"]: reacting to signal 3`

Thanks for every advice, LS

I'm being simplified the code (it's the main part), so you can analyze easily, but if you want, I can write all codes here.

// button for stitching photo in folder 'img'
public void onlyStitchButtonClicked(View button)
{
    File root = new File(urlStorage + "img");
    if (!root.exists()){
        toaster("Folder '" + urlStorage + "img' doesnt exist");
    }else{
        // show message on TextView
        tOutput.append("Stitching.\n");
        choosenResultSize = getUsersSize();

        // without delay text dont show in TextView
        new Handler().postDelayed(new Runnable() {
            public void run() {
                Stitching(urlStorage, "img", choosenResultSize);
                tOutput.append("End stitching.\n");
            }
        }, 500);        
    }
    return;
}

// Button for taking photo and stitching them
public void startButtonClicked(View button){
    // Get users settings

    tOutput.setText("App is running. Start taking photo.\n");

    // Wait delay before taking first photo
    new Handler().postDelayed(new Runnable() {
        public void run() {
            StartShot();
        }
    }, DelayBeforeStart*1000);
}

// Take collection of photos
private void StartShot(){
    new CountDownTimer(((1+NumOfPhoto)*DelayBetweenShot)*1000, DelayBetweenShot*1000) {
        private int Photo = 0;

        @Override
        public void onTick(long millisUntilFinished) {
            tOutput.append("Photo num. " + ++Photo );

            try{
                camera.takePicture(null, null, mPicture);
            }
            catch(Exception e){}
        }

        @Override
        public void onFinish() {
            tOutput.append("Stop taking photo. Start stitching");
            // Wait delay before taking first photo
            new Handler().postDelayed(new Runnable() {
                public void run() {
                    Stitching(urlStorage, FolderName, choosenResultSize);

                    tOutput.append("Stitching done.");
                    scrollview.fullScroll(ScrollView.FOCUS_DOWN);
                }
            }, 500);
        }

    }.start();
}

回答1:


Problem #1:

BufferQueues, which are the mechanism underlying Surfaces, have a producer-consumer arrangement. For a SurfaceView, your app is the producer, and SurfaceFlinger (the system graphics compositor) is the consumer. For a SurfaceTexture, both sides are in your app. The "BufferQueue has been abandoned" message means the consumer side has gone away, e.g. you're trying to send frames to a SurfaceView's Surface, but the SurfaceView no longer exists.

My guess is that whatever Surface you're using for the Camera output has been discarded, and every time the Camera tries to send a preview image you get an error message.

Problem #2:

It sounds like you're doing a bunch of work on the main UI thread. This causes the system to believe the application is unresponsive, and you get the ANR dialog. Part of the ANR handling involves getting a stack trace from the unresponsive process; since it can't ask by the usual means, it sends a signal 3. The message from the VM just indicates that signal 3 was received. It's unlikely that switching to Dalvik would change matters.

Perform the photo stitching on a non-UI thread, and make sure the UI thread isn't waiting for the other thread to finish. AsyncTask can be useful here.



来源:https://stackoverflow.com/questions/30111951/android-logcat-shows-bufferqueueprocedure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!