Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wallpaper crashes with error - queueBuffer: error queuing buffer to SurfaceTexture


Live Wallpaper crashes, code below

public void render(){


    Canvas canvas = null;
    try{

        canvas = this._surfaceHolder.lockCanvas(null);
        synchronized (this._surfaceHolder) {
            this.onDraw(canvas);
        }

    }catch(Exception e){ Log.w("Surface holder ", e.toString());}

    finally{
        if(canvas != null){
            this._surfaceHolder.unlockCanvasAndPost(canvas);
        }
    }   
}

protected void onDraw(Canvas canvas) {
    this.renderBackGround(canvas);
    for (Renderable renderable : this._fishes) {
        renderable.render(canvas);
    }
};

Crashes with the below error

06-07 19:49:09.143: E/SurfaceTextureClient(13629): queueBuffer: error queuing buffer to SurfaceTexture, -19

06-07 19:49:09.143: E/SurfaceTextureClient(13629): queueBuffer (handle=0x1c1b30) failed (No such device) 06-07 19:49:09.143: W/dalvikvm(13629): threadid=11: thread exiting with uncaught exception (group=0x40c671f8) 06-07 19:49:09.143: E/AndroidRuntime(13629): FATAL EXCEPTION: Thread-692

06-07 19:49:09.143: E/AndroidRuntime(13629): java.lang.IllegalArgumentException

06-07 19:49:09.143: E/AndroidRuntime(13629): at android.view.Surface.unlockCanvasAndPost(Native Method)

06-07 19:49:09.143: E/AndroidRuntime(13629): at com.android.internal.view.BaseSurfaceHolder.unlockCanvasAndPost(BaseSurfaceHolder.java:215)

thanks in advance

like image 729
Rajesh Avatar asked Jun 07 '12 19:06

Rajesh


1 Answers

This typically happens when you rotate the device in the live wallpaper picker. The only solution I've found is to catch the IllegalArgumentException and ignore it.

if (canvas != null) {
    try {
        holder.unlockCanvasAndPost(canvas);
    } catch (IllegalArgumentException e) {
        // Ignore weird bug when rotating in live wallpaper picker
    }
}
like image 167
Adam Nybäck Avatar answered Sep 19 '22 13:09

Adam Nybäck