mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1383499 - Animated PNGs should allocate after-first frames on the heap instead of as volatile buffers on Android. r=tnikkel
Animated image frames are never actually released to let the OS purge them, because AnimationSurfaceProvider keeps them as RawAccessFrameRef. Meanwhile, each volatile buffer on Android needs a file handle to be retained for as long as the buffer lives. Given sufficient number of animated image frames, we could easily exhaust the available file handles (which in turn causes many problems). As such on Android we should stick with the heap for animated image frames. On other platforms it is better to stay because we will avoid a memset, because the OS will zero-fill the requested pages on our behalf.
This commit is contained in:
parent
3160467cf1
commit
539ab65d03
@ -83,6 +83,19 @@ AllocateBufferForImage(const IntSize& size,
|
||||
SurfaceFormat format,
|
||||
bool aIsAnimated = false)
|
||||
{
|
||||
#ifdef ANDROID
|
||||
if (aIsAnimated) {
|
||||
// For as long as an animated image is retained, its frames will never be
|
||||
// released to let the OS purge volatile buffers. On Android, a volatile
|
||||
// buffer actually keeps a file handle active, which we would like to avoid
|
||||
// since many images and frames could easily exhaust the pool. As such, we
|
||||
// use the heap. On the other platforms we do not have the file handle
|
||||
// problem, and additionally we may avoid a superfluous memset since the
|
||||
// volatile memory starts out as zero-filled.
|
||||
return Factory::CreateDataSourceSurface(size, format, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t stride = VolatileSurfaceStride(size, format);
|
||||
if (!aIsAnimated && gfxPrefs::ImageMemShared()) {
|
||||
RefPtr<SourceSurfaceSharedData> newSurf = new SourceSurfaceSharedData();
|
||||
|
Loading…
Reference in New Issue
Block a user