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

how to solve the problem of OOM,caused by supersized Gif . #124

Closed
guqun opened this issue Mar 6, 2015 · 7 comments
Closed

how to solve the problem of OOM,caused by supersized Gif . #124

guqun opened this issue Mar 6, 2015 · 7 comments
Labels

Comments

@guqun
Copy link

guqun commented Mar 6, 2015

Thank you very much to maintain the valuable code,I wonder how to solve the problem of OOM,caused by supersized Gif .example,4096 * 4096

@koral--
Copy link
Owner

koral-- commented Mar 9, 2015

There are several solutions:

  • enable largeHeap in manifest (available on API 11+)
  • divide your app into several processes (using android:process in manifest) however it can cause some side effects
  • if you have another GifDrawables, Bitmaps or another objects not needed at the same time with that huge GIF, you can try recycling (or nullifying) them

Unfortunately currently there is no feature like inSampleSize and all pixels of the GIF need to be loaded into memory.

@koral-- koral-- closed this as completed Mar 9, 2015
@guqun
Copy link
Author

guqun commented Mar 9, 2015

thanks for your detailed reply,I consider SampleSize is a better method to avoid OOM,As well as SampleSize works great when decoding in my app.Is there have a good way to implement samplesize?

@koral--
Copy link
Owner

koral-- commented Mar 9, 2015

Subsampling is basically skipping each n-th column and row of the image (where n is integral number >=2). Eg. if n=2 just 1st, 3rd, 5th etc. row and column is read respectively. It looks simple in single bitmap however can be a little bit tricky with GIFs. Here are some caveats:

To implement subsampling you have to modify flow of GifInfo#rasterBits

@koral--
Copy link
Owner

koral-- commented Mar 13, 2015

@guqun you can try GifTextureView. Bitmap is not needed there. Available on API 14+.

@guqun
Copy link
Author

guqun commented Mar 13, 2015

thank you very much! Although there are differences with ImageView, the GifTextureView is a effective way to avoid OOM. I will consider how to behave in the form of GifTextureView and ImageView is consistent.

@huyduongtu
Copy link

@guqun Did you find any solution for supporting resize Gif image yet? I'm facing this problem, too.

@koral--
Copy link
Owner

koral-- commented Feb 28, 2016

Info for anyone interested in subsampling option: this feature is now available, more info in: https://github.com/koral--/android-gif-drawable/issues/239

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants