Your use of SurfaceHolder
is pretty weird. I'm thinking the unintended behavior is due to that. This is how I've used SurfaceView in the past:
public void run() {
Canvas canvas;
while(running) {
try {
if(!holder.getSurface().isValid())
continue;
canvas = holder.lockCanvas();
synchronized (surface) {
//Code to draw text/etc
}
} catch (...) {
} finally {
holder.unlockCanvasAndPost(canvas);
}
}
}
Note your missing lockCanvas
expression to actually assign canvas and pair with unlockCanvasAndPost