The exception is thrown the 1st time around the loop. And Unlock is never called, since there was never a successful Lock in the first place... :(
Right now, my code looks like this one: http://developer.android.com/guide/samples/ApiDemos/src/com/example/android/apis/graphics/GLSurfaceView.html However, in the run() method, instead of having: if ((w > 0) && (h > 0)) { /* draw a frame here */ mRenderer.drawFrame(gl); /* * Once we're done with GL, we need to call swapBuffers() * to instruct the system to display the rendered frame */ mEglHelper.swap(); } I modified it a little: if ((w > 0) && (h > 0)) { mRenderer.drawFrame(gl); if (mRun){ Canvas c = null; try { mHolder = getHolder(); //make sure holder is updated c = mHolder.lockCanvas(); synchronized (mHolder) { if (mMode == STATE_RUNNING && c != null){ doDraw(c); } } } finally { // do this in a finally so that if an exception is thrown // during the above, we don't leave the Surface in an // inconsistent state if (c != null) { mHolder.unlockCanvasAndPost(c); } } } mEglHelper.swap(); } On Apr 8, 4:04 am, "[email protected]" <[email protected]> wrote: > Sorry, I misread your code before. It looks the same as lunarview and > also the same as my game loop, both of which work fine, so I think it > must be something you are doing outside of this code snippet. > > You do have to unlock for every successful lock (but not if you get a > null back), so your code looks correct to me in this regard > > The error looks like the one you would get if the canvas was already > locked when you called lock, so are you sure you aren't doing > something elsewhere in the code that is locking the canvas? > > Maybe you could also add some more trace info - is the unlock call > definitely being reached, and is the exception thrown the 1st time > round the loop or after a number of iterations? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

