严重的蜂窝硬件加速内存问题

时间:2011-08-01 10:19:00

标签: android android-3.0-honeycomb android-4.0-ice-cream-sandwich hardware-acceleration

我目前正在为蜂窝创建一个应用程序,但我遇到了一些重大问题,我怀疑是openGL渲染器使用的内存。

情况是我有一个包含多个容器视图的滚动视图(可能有点多,如20);这些容器视图每个都包含6个自定义视图,这些视图的layertype设置为由this.setLayerType(View.LAYER_TYPE_HARDWARE, null);加速的硬件(如果我没有设置它,所有内容都会被渲染,图像丢失或在错误的地方绘制等等)。我还有一个显示视频的视频。

现在,当我的应用程序被销毁并再次创建时(特别是在旋转时),应用程序就死了一个严重可怕的死亡,没有任何可调试的错误,除了日志显示很多GC和其他有关图形缓冲区的东西都没有记忆和各种死亡的东西:

08-01 11:59:03.540: ERROR/libEGL(4435): call to OpenGL ES API with no current context (logged once per thread)
08-01 11:59:20.050: WARN/WindowManager(125): Window freeze timeout expired.
08-01 11:59:20.300: ERROR/InputDispatcher(125): channel '40f8bc80 com.android.launcher/com.android.launcher2.Launcher (server)' ~ Consumer closed input channel or an error occurred.  events=0x8
08-01 11:59:20.300: ERROR/InputDispatcher(125): channel '40f8bc80 com.android.launcher/com.android.launcher2.Launcher (server)' ~ Channel is unrecoverably broken and will be disposed!
08-01 11:59:20.300: INFO/ActivityManager(125): Process com.android.launcher (pid 3723) has died.
08-01 11:59:20.300: INFO/WindowManager(125): WINDOW DIED Window{40f8bc80 com.android.launcher/com.android.launcher2.Launcher paused=false}
08-01 11:59:20.300: WARN/WindowManager(125): Failed looking up window
08-01 11:59:20.300: WARN/WindowManager(125): java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@40acdc08 does not exist
08-01 11:59:20.300: WARN/WindowManager(125):     at com.android.server.WindowManagerService.windowForClientLocked(WindowManagerService.java:9423)
08-01 11:59:20.300: WARN/WindowManager(125):     at com.android.server.WindowManagerService.windowForClientLocked(WindowManagerService.java:9414)
08-01 11:59:20.300: WARN/WindowManager(125):     at com.android.server.WindowManagerService$WindowState$DeathRecipient.binderDied(WindowManagerService.java:8153)
08-01 11:59:20.300: WARN/WindowManager(125):     at android.os.BinderProxy.sendDeathNotice(Binder.java:385)
08-01 11:59:20.300: WARN/WindowManager(125):     at dalvik.system.NativeStart.run(Native Method)
08-01 11:59:20.300: INFO/WindowManager(125): WIN DEATH: null
08-01 11:59:21.460: ERROR/MediaPlayer(4435): stop called in state 1
08-01 11:59:21.460: ERROR/MediaPlayer(4435): error (-38, 0)
08-01 11:59:21.490: INFO/OMXCodec(85): [OMX.Nvidia.h264.decode] AVC profile = 66 (Baseline), level = 13
08-01 11:59:21.490: INFO/OMXCodec(85): [OMX.Nvidia.h264.decode] allocating 10 buffers of size 1566720 on input port
08-01 11:59:21.490: INFO/OMXCodec(85): [OMX.Nvidia.h264.decode] allocating 9 buffers from a native window of size 777600 on output port
08-01 11:59:21.520: INFO/WindowManager(125): WIN DEATH: Window{40bad270 RecentsPanel paused=false}
08-01 11:59:21.520: INFO/ActivityManager(125): Process com.android.systemui (pid 177) has died.
08-01 11:59:21.520: WARN/ActivityManager(125): Scheduling restart of crashed service com.android.systemui/.SystemUIService in 1250ms
08-01 11:59:21.520: ERROR/InputDispatcher(125): channel '40b511d8 NotificationPanel (server)' ~ Consumer closed input channel or an error occurred.  events=0x8
08-01 11:59:21.520: ERROR/InputDispatcher(125): channel '40b511d8 NotificationPanel (server)' ~ Channel is unrecoverably broken and will be disposed!
08-01 11:59:21.520: INFO/WindowManager(125): WIN DEATH: Window{40b51d98 NotificationPeekWindow paused=false}
08-01 11:59:21.520: INFO/StatusBarManagerService(125): binder died for pkg=com.android.systemui
08-01 11:59:21.520: INFO/WindowManager(125): WIN DEATH: Window{40b58810 StatusBar paused=false}
08-01 11:59:21.530: INFO/ActivityManager(125): Start proc com.android.systemui for restart com.android.systemui: pid=4553 uid=1000 gids={2001, 3003, 3002, 3001}
08-01 11:59:21.530: INFO/WindowManager(125): WIN DEATH: Window{409fd688 InputMethodsPanel paused=false}
08-01 11:59:21.530: INFO/WindowManager(125): WINDOW DIED Window{40b511d8 NotificationPanel paused=false}
08-01 11:59:21.530: WARN/WindowManager(125): Failed looking up window
08-01 11:59:21.530: WARN/WindowManager(125): java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@40b50fe8 does not exist
08-01 11:59:21.530: WARN/WindowManager(125):     at com.android.server.WindowManagerService.windowForClientLocked(WindowManagerService.java:9423)
08-01 11:59:21.530: WARN/WindowManager(125):     at com.android.server.WindowManagerService.windowForClientLocked(WindowManagerService.java:9414)
08-01 11:59:21.530: WARN/WindowManager(125):     at com.android.server.WindowManagerService$WindowState$DeathRecipient.binderDied(WindowManagerService.java:8153)
08-01 11:59:21.530: WARN/WindowManager(125):     at android.os.BinderProxy.sendDeathNotice(Binder.java:385)
08-01 11:59:21.530: WARN/WindowManager(125):     at dalvik.system.NativeStart.run(Native Method)
08-01 11:59:21.530: INFO/WindowManager(125): WIN DEATH: null
08-01 11:59:21.540: WARN/GraphicBufferAllocator(125): alloc(720, 720, 842094169, 00002100, ...) failed -12 (Out of memory)
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125): Allocated buffers:
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125):   0x1c1a08:  150.00 KiB |  800 ( 800) x   48 |        2 | 0x00000133
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125):   0x225fd0: 3850.00 KiB |  800 ( 800) x 1232 |        1 | 0x00000300
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125):   0x22d198:  506.25 KiB |  720 ( 720) x  720 | 32315659 | 0x00002100
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125):   0x2a5250:  398.19 KiB |  360 ( 368) x  277 |        1 | 0x00000300
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125):   0x2ae858: 5280.00 KiB | 1920 (1920) x 1408 |        4 | 0x00000133
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125):   0x3510f0:  506.25 KiB |  720 ( 720) x  720 | 32315659 | 0x00002100
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125):   0x3b0958:  506.25 KiB |  720 ( 720) x  720 | 32315659 | 0x00002100
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125):   0x40e238:  150.00 KiB |  800 ( 800) x   48 |        2 | 0x00000133
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125):   0x41a3c0:  506.25 KiB |  720 ( 720) x  720 | 32315659 | 0x00002100
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125):   0x5bfe60:  398.19 KiB |  360 ( 368) x  277 |        1 | 0x00000300
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125): Total allocated: 12251.38 KB
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125): Nvidia Gralloc
08-01 11:59:21.540: ERROR/SurfaceFlinger(125): Layer::requestBuffer(this=0x35dab0), index=5, w=720, h=720 failed (Out of memory)
08-01 11:59:21.540: WARN/GraphicBufferAllocator(125): alloc(800, 1232, 1, 00000300, ...) failed -12 (Out of memory)
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125): Allocated buffers:
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125):   0x1c1a08:  150.00 KiB |  800 ( 800) x   48 |        2 | 0x00000133
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125):   0x225fd0: 3850.00 KiB |  800 ( 800) x 1232 |        1 | 0x00000300
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125):   0x22d198:  506.25 KiB |  720 ( 720) x  720 | 32315659 | 0x00002100
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125):   0x2a5250:  398.19 KiB |  360 ( 368) x  277 |        1 | 0x00000300
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125):   0x2ae858: 5280.00 KiB | 1920 (1920) x 1408 |        4 | 0x00000133
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125):   0x3510f0:  506.25 KiB |  720 ( 720) x  720 | 32315659 | 0x00002100
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125):   0x3b0958:  506.25 KiB |  720 ( 720) x  720 | 32315659 | 0x00002100
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125):   0x40e238:  150.00 KiB |  800 ( 800) x   48 |        2 | 0x00000133
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125):   0x41a3c0:  506.25 KiB |  720 ( 720) x  720 | 32315659 | 0x00002100
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125):   0x5bfe60:  398.19 KiB |  360 ( 368) x  277 |        1 | 0x00000300
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125): Total allocated: 12251.38 KB
08-01 11:59:21.540: DEBUG/GraphicBufferAllocator(125): Nvidia Gralloc
08-01 11:59:21.540: ERROR/SurfaceFlinger(125): Layer::requestBuffer(this=0x5b8568), index=1, w=800, h=1232 failed (Out of memory)
08-01 11:59:21.560: ERROR/InputDispatcher(125): channel '40f0e030 com.myapp/com.myApp.MyActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x8
08-01 11:59:21.560: ERROR/InputDispatcher(125): channel '40f0e030 com.myapp/com.myApp.MyActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
08-01 11:59:21.560: INFO/WindowManager(125): WINDOW DIED Window{40f0e030 com.myapp/com.myApp.MyActivity paused=false}
08-01 11:59:21.560: WARN/WindowManager(125): Force-removing child win Window{40f21568 SurfaceView paused=false} from container Window{40f0e030 com.myapp/com.myApp.MyActivity paused=false}
08-01 11:59:21.570: WARN/AudioSystem(215): AudioFlinger server died!
08-01 11:59:21.570: WARN/AudioSystem(215): AudioPolicyService server died!
08-01 11:59:21.570: INFO/ServiceManager(80): service 'media.audio_flinger' died
08-01 11:59:21.570: INFO/ServiceManager(80): service 'media.player' died
08-01 11:59:21.570: INFO/ServiceManager(80): service 'media.camera' died
08-01 11:59:21.570: INFO/ServiceManager(80): service 'media.audio_policy' died
08-01 11:59:21.570: WARN/IMediaDeathNotifier(125): media server died
08-01 11:59:21.570: WARN/AudioSystem(125): AudioPolicyService server died!
08-01 11:59:21.570: INFO/ActivityManager(125): Process com.myapp (pid 4435) has died.
08-01 11:59:21.570: WARN/WindowManager(125): Failed looking up window
08-01 11:59:21.570: WARN/WindowManager(125): java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@41041880 does not exist
08-01 11:59:21.570: WARN/WindowManager(125):     at com.android.server.WindowManagerService.windowForClientLocked(WindowManagerService.java:9423)
08-01 11:59:21.570: WARN/WindowManager(125):     at com.android.server.WindowManagerService.windowForClientLocked(WindowManagerService.java:9414)
08-01 11:59:21.570: WARN/WindowManager(125):     at com.android.server.WindowManagerService$WindowState$DeathRecipient.binderDied(WindowManagerService.java:8153)
08-01 11:59:21.570: WARN/WindowManager(125):     at android.os.BinderProxy.sendDeathNotice(Binder.java:385)
08-01 11:59:21.570: WARN/WindowManager(125):     at dalvik.system.NativeStart.run(Native Method)
08-01 11:59:21.570: INFO/WindowManager(125): WIN DEATH: null
08-01 11:59:21.570: INFO/ActivityManager(125): Start proc com.android.launcher for activity com.android.launcher/com.android.launcher2.Launcher: pid=4559 uid=10025 gids={}
08-01 11:59:21.650: INFO/ActivityThread(4559): Pub com.android.launcher2.settings: com.android.launcher2.LauncherProvider

所以问题是,我怎样才能确保不会发生这种情况?特别是:

  • 我是否需要特别注意缓存等等,如何?
  • 我是否必须限制硬件加速视图的数量?

1 个答案:

答案 0 :(得分:2)

硬件层在内存方面非常昂贵。您应该只在视图上临时启用它们(例如,在动画的持续时间内。)要进入您描述应用程序的状态,必须在Xoom平板电脑上使用超过256 + 32 MB的视频内存。此外,如果您使用的是WebView,请小心,因为它本身会占用相当多的内存。