0

My app closes with error Method called after release in Renderer class. I searched but with no luck...I tried some solutions which helped others(like camera.setPreviewCallback(null); ) but nothing...I have this problem only on Samsung Note 10.1 with OS 4.4.2. On other devices it works without error.

This is where error occured in ImageRenderer class: (in line camera.setPreviewTexture(mSurfaceTexture);)

public void setUpSurfaceTexture(final Camera camera, final GLSurfaceView surfaceView) {
    runOnDraw(new Runnable() {
        @Override
        public void run() {
            int[] textures = new int[1];
            GLES20.glGenTextures(1, textures, 0);
            mSurfaceTexture = new SurfaceTexture(textures[0]);
            try {                   
                camera.setPreviewTexture(mSurfaceTexture);
                camera.setPreviewCallback(GPUImageRenderer.this);
                camera.startPreview();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    });
}

What can cause this error? And how it can work on all devices I tried except this one?

Error log:

01-08 14:52:27.791: E/AndroidRuntime(22887): FATAL EXCEPTION: GLThread 1666
01-08 14:52:27.791: E/AndroidRuntime(22887): Process: jp.co.cyberagent.android.gpuimage.sample, PID: 22887
01-08 14:52:27.791: E/AndroidRuntime(22887): java.lang.RuntimeException: Method called after release()
01-08 14:52:27.791: E/AndroidRuntime(22887):    at android.hardware.Camera.setPreviewTexture(Native Method)
01-08 14:52:27.791: E/AndroidRuntime(22887):    at jp.co.cyberagent.android.gpuimage.GPUImageRenderer$2.run(GPUImageRenderer.java:157)
01-08 14:52:27.791: E/AndroidRuntime(22887):    at jp.co.cyberagent.android.gpuimage.GPUImageRenderer.onDrawFrame(GPUImageRenderer.java:115)
01-08 14:52:27.791: E/AndroidRuntime(22887):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1532)
01-08 14:52:27.791: E/AndroidRuntime(22887):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1249)
Kapljica
  • 21
  • 5
  • Error? Post the logcat please. – shkschneider Jan 08 '15 at 13:02
  • possible duplicate of [Releasing the camera: "Method called after release()" exception](http://stackoverflow.com/questions/26258979/releasing-the-camera-method-called-after-release-exception) – shkschneider Jan 08 '15 at 13:02
  • https://stackoverflow.com/search?q=Method+called+after+release%28%29 – shkschneider Jan 08 '15 at 14:10
  • Regarding to your post "possible duplicate of Releasing the camera: "Method called after release()" exception" , as i wrote I already tried camera.setPreviewCallback(null); an it's not helpfull :( – Kapljica Jan 08 '15 at 14:20
  • I know it is hard to debug (I spent hours on this error), but it has to be. That is what the "method called after release()" error means. It also depends on devices, I know... I can only advise you to play around with some of the answers I linked. – shkschneider Jan 08 '15 at 14:31
  • I spent a while debugging it...and finally I found that problem was something totally different than I tought...one of my methods which is setting up camera was called more times than it should, and caused al this mess. Thanks anyway :) – Kapljica Jan 09 '15 at 15:15
  • please answer your own question and accept it, to close this thread and explain what was wrong so it could help others. – shkschneider Jan 09 '15 at 15:19

1 Answers1

0

I spent a while debugging it...and finally I found that problem was something totally different than I tought...one of my methods which is setting up camera was called more times than it should, and caused al this mess. Order of methods for openning and releasing camera was problem. So actualy the thing wich everyone with this problem shoud do is to carefull debug its code. Make sure that you are not using camera after it is released, until you open it first. And you should always try with this camera.setPreviewCallback(null); which we disscuced here about. Hope it helps!

Kapljica
  • 21
  • 5