LoginSignup
3

More than 5 years have passed since last update.

GlideのTransformation自作時はBitmap#recycleしてはいけない

Posted at

自分用おぼえがきです。タイトルそのままです。

公式ドキュメントの Bitmap re-use の項に明記してありました。
https://github.com/bumptech/glide/wiki/Transformations#bitmap-re-use

一回使い切りの場合や取得結果をキャッシュしていない場合はあまり影響なさそうですが、再利用しようとすると当然エラーになります。それでも落ちたりしないし再取得を試みてくれてるっぽいので、うっかり間違っててもすぐには気づきにくいかも。

W/Bitmap: Called getConfig() on a recycle()'d bitmap! This is undefined behavior!
W/Bitmap: Called getRowBytes() on a recycle()'d bitmap! This is undefined behavior!
W/Bitmap: Called getHeight() on a recycle()'d bitmap! This is undefined behavior!

こんなのがわらわらでます。

よくある間違い、的なページもありました。
https://github.com/bumptech/glide/wiki/Resource-re-use-in-Glide#common-mistakes

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3