title: Exception locking surface, java.lang.IllegalArgumentException
body: <p>I am using a thread to handle a wallpaper and using surface view. I am getting the following error and unable to solve it. There is an answer in which they told that there is problem in the sequence of lock <code>surfaceHolder.lockcanvas()</code> and <code>surfaceHolder.unlockCanvasAndPost(canvas)</code>. But i check and it is right.
  plese help someone..
   the LogCat is below:</p>
  
  <pre><code>07-06 12:58:24.459: E/SurfaceTextureClient(719): queueBuffer: error queuing buffer to SurfaceTexture, -19
  07-06 12:58:24.459: E/SurfaceTextureClient(719): queueBuffer (handle=0x2a185508) failed (No such device)
  07-06 12:58:24.470: W/System.err(719): java.lang.IllegalArgumentException
  07-06 12:58:24.479: W/System.err(719):  at android.view.Surface.nativeUnlockCanvasAndPost(Native Method)
  07-06 12:58:24.489: W/System.err(719):  at android.view.Surface.unlockCanvasAndPost(Surface.java:457)
  07-06 12:58:24.489: W/System.err(719):  at com.android.internal.view.BaseSurfaceHolder.unlockCanvasAndPost(BaseSurfaceHolder.java:215)
  07-06 12:58:24.489: W/System.err(719):  at com.shagun.sunsetlivewallpaper.BackgroundSelector$LeafThread.run(BackgroundSelector.java:160)
  07-06 12:58:24.630: E/SurfaceTextureClient(719): dequeueBuffer failed (No such device)
  07-06 12:58:24.649: E/InputEventReceiver(719): channel '40ee2318 com.shagun.sunsetlivewallpaper.WallpaperService (client)' ~ Publisher closed input channel or an error occurred.  events=0x9
  07-06 12:58:24.690: E/BaseSurfaceHolder(719): Exception locking surface
  07-06 12:58:24.690: E/BaseSurfaceHolder(719): java.lang.IllegalArgumentException
  07-06 12:58:24.690: E/BaseSurfaceHolder(719):   at android.view.Surface.nativeLockCanvas(Native Method)
  07-06 12:58:24.690: E/BaseSurfaceHolder(719):   at android.view.Surface.lockCanvas(Surface.java:447)
  07-06 12:58:24.690: E/BaseSurfaceHolder(719):   at com.android.internal.view.BaseSurfaceHolder.internalLockCanvas(BaseSurfaceHolder.java:184)
  07-06 12:58:24.690: E/BaseSurfaceHolder(719):   at com.android.internal.view.BaseSurfaceHolder.lockCanvas(BaseSurfaceHolder.java:157)
  07-06 12:58:24.690: E/BaseSurfaceHolder(719):   at com.shagun.sunsetlivewallpaper.BackgroundSelector$LeafThread.run(BackgroundSelector.java:145)
  07-06 12:58:24.690: W/dalvikvm(719): threadid=12: thread exiting with uncaught exception (group=0x40a70930)
  07-06 12:58:24.719: E/AndroidRuntime(719): FATAL EXCEPTION: Thread-68
  07-06 12:58:24.719: E/AndroidRuntime(719): java.lang.NullPointerException
  07-06 12:58:24.719: E/AndroidRuntime(719):  at com.shagun.sunsetlivewallpaper.BackgroundSelector.drawScreen(BackgroundSelector.java:85)
  07-06 12:58:24.719: E/AndroidRuntime(719):  at com.shagun.sunsetlivewallpaper.BackgroundSelector.access$1(BackgroundSelector.java:80)
  07-06 12:58:24.719: E/AndroidRuntime(719):  at com.shagun.sunsetlivewallpaper.BackgroundSelector$LeafThread.run(BackgroundSelector.java:148)
  07-06 12:58:30.680: I/Process(719): Sending signal. PID: 719 SIG: 9
  </code></pre>