Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@70e62c7 #52

Closed
bobSir opened this issue Apr 20, 2017 · 7 comments

Comments

@bobSir
Copy link

@bobSir bobSir commented Apr 20, 2017

at android.graphics.Canvas.throwIfCannotDraw(Canvas.java:1271)
at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:257)
at android.graphics.Canvas.drawBitmap(Canvas.java:1415)
at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:545)
at android.widget.ImageView.onDraw(ImageView.java:1286)
at android.view.View.draw(View.java:17134)
at android.view.View.updateDisplayListIfDirty(View.java:16116)
at android.view.View.draw(View.java:16900)
at android.view.ViewGroup.drawChild(ViewGroup.java:3764)
at org.apmem.tools.layouts.FlowLayout.drawChild(FlowLayout.java:359)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)

@bobSir

This comment has been minimized.

Copy link
Author

@bobSir bobSir commented Apr 20, 2017

报了一个FlowLayout一个Crash。
项目中是用Fresco图片加载框架,在用Fresco下载图片以后 拿到Bitmap设置给imageview。
如果图片加载框架是Fresco,应该怎么做票圈里面的转场动画,求指教。。

@razerdp

This comment has been minimized.

Copy link
Owner

@razerdp razerdp commented Apr 21, 2017

这个crash信息不够详细诶,虽然是指向于flowlayout,但其实是flowlayout的drawchild,所以其实还是自定义控件的问题,建议断点看看PhotoContents的onMeasure方法。

@bobSir

This comment has been minimized.

Copy link
Author

@bobSir bobSir commented Apr 21, 2017

问题是出在用fresco下载图片 得到bitmap 设置给ImageView, 我采用其他的图片加载框架 是没有问题的,但用的是Fresco。UP有何高见

@razerdp

This comment has been minimized.

Copy link
Owner

@razerdp razerdp commented Apr 21, 2017

下载的bitmap,然后设置么,,,你看看crash信息有没有类似于“System.err: java.lang.RuntimeException: Canvas: trying to use a recycled bitmap ”的字样。

@bobSir

This comment has been minimized.

Copy link
Author

@bobSir bobSir commented Apr 21, 2017

对Crash日志就是这个“System.err: java.lang.RuntimeException: Canvas: trying to use a recycled bitmap ”

dataSource.subscribe 这个方法下载图片成功后 有个回调 参数里有Bitmap 。 直接设置给ImageView,

@razerdp

This comment has been minimized.

Copy link
Owner

@razerdp razerdp commented Apr 21, 2017

一般来说,使用bitmap请判断一下bitmap.isRecycled()

@razerdp

This comment has been minimized.

Copy link
Owner

@razerdp razerdp commented Apr 21, 2017

事实上没记错fresco使用ashmen内存,对于bitmap都是在C层自行调配(显性释放)的,在fresco的git上有一个类似的issue,或者你也可以搜搜其他类似的#648

@razerdp razerdp closed this Sep 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.