通过堆栈跟踪报告发送的 Android 回收位图崩溃
我没有太多信息可以参考,因为报告没有评论崩溃发生时我正在玩游戏的哪一部分,但从我现在的立场来看,应该不可能出现此错误。
这是 stackTrace:
java.lang.RuntimeException: Canvas: trying to use a recycled bitmap
android.graphics.Bitmap@44d37950 at
android.graphics.Canvas.throwIfRecycled(Canvas.java:955) at
android.graphics.Canvas.drawBitmap(Canvas.java:1044) at
bladequest.graphics.DrawObject.render(DrawObject.java:81)
我收到错误消息,说在程序中的某个点从第 77 行到第 81 行(单独的堆栈跟踪)正在使用回收的位图
但是,这是我针对这些行的代码:
case Bmp1:
if(bmp != null && !bmp.isRecycled())
canvas.drawBitmap(bmp, f1, f2, p);
break;
case Bmp2:
if(bmp != null && !bmp.isRecycled())
canvas.drawBitmap(bmp, r1, r2, p);
break;
回收的位图怎么可能位图是否曾进入绘图调用???
I don't have a whole lot of information to go off of since the reports had no comments about what part of my game was being played when the crash occurred but from where I;m standing, it should be impossible to be getting this error.
This is the stackTrace:
java.lang.RuntimeException: Canvas: trying to use a recycled bitmap
android.graphics.Bitmap@44d37950 at
android.graphics.Canvas.throwIfRecycled(Canvas.java:955) at
android.graphics.Canvas.drawBitmap(Canvas.java:1044) at
bladequest.graphics.DrawObject.render(DrawObject.java:81)
I get the error saying that recycled bitmaps are being used at some point in the program from lines 77 and from 81 (seperate stacktraces)
However, here is my code for those lines:
case Bmp1:
if(bmp != null && !bmp.isRecycled())
canvas.drawBitmap(bmp, f1, f2, p);
break;
case Bmp2:
if(bmp != null && !bmp.isRecycled())
canvas.drawBitmap(bmp, r1, r2, p);
break;
How is it even possible that a recycled bitmap is ever making it to the draw call???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
原因可能是
onDraw
方法被调用了,如果你想回收位图,并避免这个错误,建议重写onDraw
方法,在onDraw中,你需要检查这bmp != null && !bmp.isRecycled()
the reason maybe the
onDraw
method has be invoked, if you want to recycle the bitmap, and avoid this error, suggestion override theonDraw
method, in the ondraw, you need check thebmp != null && !bmp.isRecycled()