android.view.Surface - OutOfResourcesException

3
我遇到了一个奇怪的bug,但没有找到任何可能的解决方案。这个问题总是在我玩我的应用程序一会儿后随机出现。该应用程序在几乎所有设备上都运行得非常完美。但是其中一个设备存在此问题,它正在运行CM 7.1.0,我知道很多CM7用户抱怨类似的问题。
不幸的是,我有一些用户在使用应用程序时遇到了相同的问题,但我不知道他们是否在使用CM7。由于我无法在同一ROM上的其他应用程序中重现此错误,因此它必须与其他某些事物有关。
正如我之前所说,它似乎完全是随机的,因此复制源代码毫无意义。相反,以下是日志,希望已经有人遇到过相同的问题并能够帮助我。谢谢。
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)
3个回答

3
经过长时间的提交我的git,我终于找到了一个没有这个问题的版本。由于我正在开发的应用程序在屏幕上显示敏感数据,我试图更改“最近使用的应用程序”部分中显示的缩略图的图像。为了实现这一点,我将安全标志设置为窗口:http://developer.android.com/reference/android/view/Window.html#setFlags(int, int) http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_SECURE。结果,这正是导致异常和显示黑屏的问题所在。当我去除它后,一切都正常运作了。希望这个技巧能帮助其他面临相同问题的开发人员。

0

我有类似的问题,但与硬件表面相关。

我有ProgressDialog和SignIn组件。 这些组件之间的所有通信都通过Handler类完成。

在我的情况下,唯一能避免崩溃的方法是关闭特定Activity的硬件加速。


0

好的,希望这样会更清晰。Surface是一个包含像素的对象,这些像素被合成到屏幕上。您在屏幕上看到的每个窗口都有自己的表面,它们绘制到其中,并且Surface Flinger按照正确的Z顺序将它们呈现到最终显示器上。表面通常具有两个以上的缓冲区以进行双缓冲渲染:应用程序可以在表面Flinger使用上一个缓冲区合成屏幕时绘制其下一个UI状态,而无需等待。=>因此,这是由Android操作系统本身处理的,而不是在应用程序内部处理的。 - Levente Kürti
@LeviKurti 也许你想在这里阅读:http://code.google.com/p/cyanogenmod/issues/detail?id=3106 - poitroae
谢谢你的链接,Michael,但不幸的是我已经阅读过一打CM和Google发布的问题,包括这个,但是没有运气。我甚至还发现了2012年5月底发布的帖子,但是没有可用的解决方法。看起来其他开发人员也陷入了这个无休止的循环中。 - Levente Kürti

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接