В настоящее время я создаю приложение для сотовых ячеек, но у меня возникают серьезные проблемы, которые, как я подозреваю, связаны с памятью, используемой рендерером openGL.
Ситуация такова, что у меня есть представление прокрутки, которое содержит несколько представлений контейнера (может быть несколько, например, 20); каждый из этих контейнерных представлений состоит из примерно 6 пользовательских представлений, чей тип слоя установлен на аппаратное ускорение 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
Итак, вопрос в том, как я могу убедиться, что этого не произойдет? А конкретно:
- Нужно ли мне особенно заботиться о кешах и тому подобном, как?
- Нужно ли ограничивать количество просмотров с аппаратным ускорением?