Home » Android » android – Wallpaper crashes with error – queueBuffer: error queuing buffer to SurfaceTexture

android – Wallpaper crashes with error – queueBuffer: error queuing buffer to SurfaceTexture

Posted by: admin May 14, 2020 Leave a comment

Questions:

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

How to&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
    }
}