Perhapse我对不同信号的致命错误很幸运。今天的情况如下:
02-05 20:57:21.827: D/MY_TEST_MESSAGE(4349): Engine.onVisibilityChanged()
02-05 20:57:21.827: D/MY_TEST_MESSAGE(4349): DrawTask #3 is created!
02-05 20:57:21.827: D/MY_TEST_MESSAGE(4349): DrawTas #3 is working!
02-05 20:57:21.837: I/brcm-gr(4349): [gralloc_lock]: new usage 0x903
02-05 20:57:21.837: I/brcm-gr(4349): [gralloc_lock]: new usage 0x930
02-05 20:57:21.877: I/brcm-gr(4349): [gralloc_lock]: new usage 0x933
02-05 20:57:21.927: D/dalvikvm(4349): GC_FOR_ALLOC freed 1519K, 18% free 20612K/25095K, paused 31ms, total 31ms
02-05 20:57:21.987: I/brcm-gr(4349): [gralloc_lock]: new usage 0x933
02-05 20:57:22.257: D/MY_TEST_MESSAGE(4349): Engine.onVisibilityChanged()
02-05 20:57:22.347: I/brcm-gr(4349): [gralloc_lock]: new usage 0x933
02-05 20:57:22.427: I/brcm-gr(4349): [gralloc_lock]: new usage 0x903
02-05 20:57:22.427: I/brcm-gr(4349): [gralloc_lock]: new usage 0x930
02-05 20:57:22.447: I/brcm-gr(4349): [gralloc_lock]: new usage 0x933
02-05 20:57:22.497: D/MY_TEST_MESSAGE(4349): Engine.onSurfaceDestroyed()
02-05 20:57:22.507: D/MY_TEST_MESSAGE(4349): Engine.onDestroy released
02-05 20:57:22.517: D/MY_TEST_MESSAGE(4349): WallpaperService.onDestroy()
02-05 20:57:22.627: D/dalvikvm(4349): GC_FOR_ALLOC freed 1510K, 18% free 20619K/25095K, paused 18ms, total 19ms
02-05 20:57:22.627: I/dalvikvm-heap(4349): Grow heap (frag case) to 25.673MB for 5242896-byte allocation
02-05 20:57:22.657: D/dalvikvm(4349): GC_CONCURRENT freed 8K, 16% free 25731K/30279K, paused 3ms+3ms, total 23ms
02-05 20:57:22.727: A/libc(4349): Fatal signal 11 (SIGSEGV) at 0x52905020 (code=2), thread 4376 (AsyncTask #3)
这个日志片段告诉我,当我尝试使用实际上使用onSurfaceDestroyed()方法销毁的SurfaceHolder时,可能会发生错误。
这种状态的用例是:
那么,(4)和(5)之间的关系是什么?主要的一点是,在按回到设置屏幕后,onVisualChanged()方法调用预设动画以使用可用的持有者更改图像和canvas,但下一次立即按Back会调用onSurfaceDestroyed()方法,使持有者被销毁。
@"这只是我可以通过上述错误重现的一种情况。"
@"如果第二次按Back将接近状态动画完成"
,则不会发生错误所以,我的问题是:
答案 0 :(得分:0)
不确定,是否以正确的方式完成,但目前我通过添加三秒睡眠解决了我的问题。因此, onSurfaceDestroyed()已更改为:
@Override
public void onSurfaceDestroyed(SurfaceHolder holder) {
super.onSurfaceDestroyed(holder);
Log.d("MY_TEST_MESSAGE", "Engine.onSurfaceDestroyed()");
try{
Thread.currentThread().sleep(500);
}
catch(Exception ie){ }
mVisible = false;
if (myDrawTask != null) {
myDrawTask.cancel(false);
}
}
它没有任何意外的延迟。