通过堆栈跟踪报告发送的 Android 回收位图崩溃

发布于 2024-12-25 02:46:35 字数 801 浏览 1 评论 0原文

我没有太多信息可以参考,因为报告没有评论崩溃发生时我正在玩游戏的哪一部分,但从我现在的立场来看,应该不可能出现此错误。

这是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巴黎盛开的樱花 2025-01-01 02:46:35

原因可能是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 the onDraw method, in the ondraw, you need check the
bmp != null && !bmp.isRecycled()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文