android.view.Surface - OutOfResourcesException

3

I have this strange bug, and found nothing about a possible solution to it. The problem always appears randomly after playing around a bit with my app. The app runs perfectly on almost all devices. Still one of the devices on which this issue is present is running CM 7.1.0 and I know that a lot of CM7 users were complaining about similar problems.

Unfortunately I have some users that had the same issue with the app, but I don't know if they were using CM7 or not. Since I wasn't able to reproduce this error in other apps on the same ROM it must be related to something else.

As I've said before it appears totally random, so copying the source code doesn't makes no sense. Here's the log instead, hopefully someone already had the same problem and can help me out. Thanks.

msm7k.gralloc(1306): alloc mmap(fd=150, size=614400, prot=3) failed (Try again)
msm7k.gralloc(1306): gralloc failed err=Try again
GraphicBufferAllocator(1306): alloc(320, 480, 1, 00000033, ...) failed -11 (Try again)
GraphicBufferAllocator(1306): Allocated buffers:
GraphicBufferAllocator(1306):   0x20a8d0:  300.00 KiB |  320 ( 320) x  480 |  4 | 0x00000133
GraphicBufferAllocator(1306):   0x20c110:  531.25 KiB |  320 ( 320) x  425 |  1 | 0x00000133
GraphicBufferAllocator(1306):   0x292db0:   31.25 KiB |  320 ( 320) x   25 |  1 | 0x00000133
GraphicBufferAllocator(1306):   0x299568:  300.00 KiB |  320 ( 320) x  480 |  4 | 0x00000133
GraphicBufferAllocator(1306):   0x4a2288:  331.25 KiB |  320 ( 320) x  265 |  1 | 0x00000133
GraphicBufferAllocator(1306):   0x4b2518:   31.25 KiB |  320 ( 320) x   25 |  1 | 0x00000133
GraphicBufferAllocator(1306): Total allocated: 1525.00 KB
SurfaceFlinger(1306): Layer::requestBuffer(this=0x3a7618), index=0, w=320, h=480 failed (Try again)
Surface(7024): Surface (identity=224) requestBuffer(0, 0, 0, 0, 00000033) returned a buffer with a null handle
Surface(7024): getBufferLocked(0, 0, 0, 0, 00000033) failed (Out of memory)
Surface(7024): dequeueBuffer failed (Out of memory)
ViewRoot(7024): OutOfResourcesException locking surface
ViewRoot(7024): android.view.Surface$OutOfResourcesException
ViewRoot(7024):     at android.view.Surface.lockCanvasNative(Native Method)
ViewRoot(7024):     at android.view.Surface.lockCanvas(Surface.java:314)
ViewRoot(7024):     at android.view.ViewRoot.draw(ViewRoot.java:1461)
ViewRoot(7024):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1263)
ViewRoot(7024):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1865)
ViewRoot(7024):     at android.os.Handler.dispatchMessage(Handler.java:99)
ViewRoot(7024):     at android.os.Looper.loop(Looper.java:130)
ViewRoot(7024):     at android.app.ActivityThread.main(ActivityThread.java:3835)
ViewRoot(7024):     at java.lang.reflect.Method.invokeNative(Native Method)
ViewRoot(7024):     at java.lang.reflect.Method.invoke(Method.java:507)
ViewRoot(7024):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
ViewRoot(7024):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
ViewRoot(7024):     at dalvik.system.NativeStart.main(Native Method)
android
exception
canvas
resources
surfaceview
asked on Stack Overflow Jul 6, 2012 by Levente Kürti • edited Jun 19, 2014 by JasonMArcher

3 Answers

3

After long hours of pulling my git commits I've finally found one that didn't had this problem. Since the app I'm working on displays sensitive data on the screen, I was trying to change the image displayed as the thumbnail in the "Recent Apps" section. In order to achieve this I was setting the secure flag to the window:

http://developer.android.com/reference/android/view/Window.html#setFlags(int, int) http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_SECURE

Turns out that this was the problem that caused the exception and the black screen that was shown. After I've removed it, everything was working just fine. Hopefully this tip will help other devs facing the same problem.

answered on Stack Overflow Jul 9, 2012 by Levente Kürti
0

You need to call release() if you are not using your android.view.Surface anymore.

http://developer.android.com/intl/es/reference/android/view/Surface.html#release()

answered on Stack Overflow Jul 6, 2012 by poitroae
0

I have similar problem, but related to HW surface.

I have ProgressDialog and SignIn component. All Communication between this components done through Handler class.

In my case the only thing that saves from crash is turning off hw acceleration for specific Activity.

answered on Stack Overflow Nov 6, 2013 by Sergey Dryganets

User contributions licensed under CC BY-SA 3.0