异常锁定表面,java.lang.IllegalArgumentException

时间:2013-07-07 11:20:27

标签: android multithreading locking

我正在使用线程处理壁纸并使用表面视图。我收到以下错误,无法解决它。有一个答案,他们告诉我们锁定surfaceHolder.lockcanvas()surfaceHolder.unlockCanvasAndPost(canvas)的顺序存在问题。但我检查,这是对的。 请帮助某人..  LogCat如下:

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

2 个答案:

答案 0 :(得分:0)

Thread.sleep(200); 
当它崩溃时,那对我有所帮助。 你可以看到更多:

End SurfaceView and GameThread on exiting app

答案 1 :(得分:-2)

  try{
                 if(canvas != null)
                 {
                    _surfaceHolder.unlockCanvasAndPost(canvas);
                 }
            }catch(Exception e){

            }