android渲染问题导致延迟?
我正在开发一款 Android 游戏,并且已经进行了垃圾收集 GC 大约每 5 分钟左右才会发生一次,我 暂时认为可以接受。
问题是,每隔一段时间,我就会在 日志:
08-29 09:58:46.410 W/copybit ( 1912): stretch_copybit::run_render fail
08-29 09:59:09.000 E/libs3c2drender( 1912): int
S3c2DRender::DoG2D(unsigned int, s3c_img*, s3c_rect*, unsigned int,
s3c_img*, s3c_rect*, int, int)::S3C_G2D_ROTATOR_18176 fail
当出现此消息时,我的游戏似乎暂停了大约 100-200 毫秒..
我目前正在使用 Canvas 来绘图,尽管如果我的记忆是 准确,我在使用 OpenGL 时也看到过同样的错误消息。
这是我绘制图像对象的代码:
cachedMatrix.reset();
cachedMatrix.postTranslate(-halfImageWidth, -halfImageHeight);
cachedMatrix.postScale(localScaleX, localScaleY);
cachedMatrix.postTranslate(localOffset.x, localOffset.y);
float degrees = (radiansToDegrees(-rotation) + 360f) % 360f;
cachedMatrix.postRotate(degrees);
cachedMatrix.postTranslate(screenPos.x, screenPos.y);
canvas.drawBitmap(image, cachedMatrix, null);
坦率地说,我不知道如何解决这个问题。我的 Samsung Moment 手机上就发生了这种情况。
还有其他人遇到过这个问题吗?并找到了解决方法或 深入了解为什么会发生这种情况?
I'm developing an Android game and I've got the garbage collection to
the point where it GC's only about once every 5 minutes or so, which I
think is acceptable, for now.
The problem is that, every once in a while, I'll see this message in
the logs:
08-29 09:58:46.410 W/copybit ( 1912): stretch_copybit::run_render fail
08-29 09:59:09.000 E/libs3c2drender( 1912): int
S3c2DRender::DoG2D(unsigned int, s3c_img*, s3c_rect*, unsigned int,
s3c_img*, s3c_rect*, int, int)::S3C_G2D_ROTATOR_18176 fail
And when this message comes up, my game seems to pause for about
100-200 milliseconds..
I'm currently using a Canvas to draw with, although if my memory is
accurate, I've seen this same error message using Open GL as well.
Here's my code to draw the image object:
cachedMatrix.reset();
cachedMatrix.postTranslate(-halfImageWidth, -halfImageHeight);
cachedMatrix.postScale(localScaleX, localScaleY);
cachedMatrix.postTranslate(localOffset.x, localOffset.y);
float degrees = (radiansToDegrees(-rotation) + 360f) % 360f;
cachedMatrix.postRotate(degrees);
cachedMatrix.postTranslate(screenPos.x, screenPos.y);
canvas.drawBitmap(image, cachedMatrix, null);
Frankly, I am at a loss as to how to get around this. This is happening on my Samsung Moment phone.
Has anyone else encountered this issue ? And found a workaround or
insights into why this is happening ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论