I'm using quite a large amount of NinePatchDrawables in the app views. The underlying Bitmaps are cached, so there is no memory issue.
While preparing/drawing the screen, the app crashes with the following log entry:
04-03 19:37:42.651: A/libc(4064): Fatal signal 11 (SIGSEGV), code 2, fault addr 0x9e985ff8 in tid 4093 (RenderThread)
The issue just popped up with the latest Android 5.1 builds (LMY47D, LMY47E, LMY47I). The same views with the same graphics worked well on earlier Android Versions up to 5.0.2 (LRX22C). I'm getting the issue on the Nexus 6, so far I don't had the chance to test it on any other device.
The crash occurs only when using a large amount of NinePatchDrawables, especially when layering them on top of each other. When I load exactly the same graphics (just for testing) as plain png's, it works without problems. Also other views with a smaller amount of NinePatchDrawables work without problems.
The same issue was existing on earlier Android versions (5.0.2 or older), but it just happened with at least three or four times as much NinePatchDrawables per screen.
04-03 19:37:42.651: A/libc(4064): Fatal signal 11 (SIGSEGV), code 2, fault addr 0x9e985ff8 in tid 4093 (RenderThread)
04-03 19:37:42.752: I/DEBUG(354): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
04-03 19:37:42.752: I/DEBUG(354): Build fingerprint: 'google/shamu/shamu:5.1/LMY47D/1743759:user/release-keys'
04-03 19:37:42.752: I/DEBUG(354): Revision: '33696'
04-03 19:37:42.752: I/DEBUG(354): ABI: 'arm'
04-03 19:37:42.752: I/DEBUG(354): pid: 4064, tid: 4093, name: RenderThread >>> com.xyz.myapp <<<
04-03 19:37:42.752: I/DEBUG(354): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x9e985ff8
04-03 19:37:42.794: I/DEBUG(354): r0 b4a23880 r1 aee24000 r2 00000000 r3 00000001
04-03 19:37:42.794: I/DEBUG(354): r4 9e986064 r5 aec3c658 r6 00000001 r7 aec2c570
04-03 19:37:42.794: I/DEBUG(354): r8 00000003 r9 00000001 sl 0000001c fp aee24000
04-03 19:37:42.794: I/DEBUG(354): ip aadb4948 sp 9e985ff8 lr aad072db pc aac954a2 cpsr a0030030
04-03 19:37:42.795: I/DEBUG(354): backtrace:
04-03 19:37:42.795: I/DEBUG(354): #00 pc 001024a2 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxResource::PrepareGpuAccess(EsxContext*, unsigned int, EsxAccessType)+1)
04-03 19:37:42.795: I/DEBUG(354): #01 pc 0010d4fd /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::HwBlt(EsxBltCopy const*)+12)
04-03 19:37:42.795: I/DEBUG(354): #02 pc 0010eb6b /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::Blt(EsxBltCopy const*)+10)
04-03 19:37:42.795: I/DEBUG(354): #03 pc 0010ec81 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::BlitRect(EsxResource*, EsxResource*, EsxRect, EsxRect*, int)+272)
04-03 19:37:42.795: I/DEBUG(354): #04 pc 0010ed67 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::PreserveBackBufferViaBlt(int)+126)
04-03 19:37:42.796: I/DEBUG(354): #05 pc 001159a7 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::ProcessAndSubmitRendering(EsxFlushReason)+134)
04-03 19:37:42.796: I/DEBUG(354): #06 pc 00177435 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxCmdMgr::Flush(EsxFlushReason)+412)
04-03 19:37:42.796: I/DEBUG(354): #07 pc 0017759d /system/vendor/lib/egl/libGLESv2_adreno.so (EsxCmdMgr::GetCmdSpace(EsxCmdBufType, unsigned int)+140)
04-03 19:37:42.796: I/DEBUG(354): #08 pc 00173653 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxBltLib::CopyBltHw(EsxBltCopy const*)+938)
04-03 19:37:42.796: I/DEBUG(354): #09 pc 0017430d /system/vendor/lib/egl/libGLESv2_adreno.so (EsxBltLib::CopyBlt(EsxBltCopy const*)+132)
04-03 19:37:42.796: I/DEBUG(354): #10 pc 0010d4fd /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::HwBlt(EsxBltCopy const*)+12)
04-03 19:37:42.796: I/DEBUG(354): #11 pc 0010eb6b /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::Blt(EsxBltCopy const*)+10)
04-03 19:37:42.797: I/DEBUG(354): #12 pc 0010ec81 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::BlitRect(EsxResource*, EsxResource*, EsxRect, EsxRect*, int)+272)
04-03 19:37:42.797: I/DEBUG(354): #13 pc 0010ed67 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::PreserveBackBufferViaBlt(int)+126)
04-03 19:37:42.797: I/DEBUG(354): #14 pc 001159a7 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::ProcessAndSubmitRendering(EsxFlushReason)+134)
04-03 19:37:42.797: I/DEBUG(354): #15 pc 00177435 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxCmdMgr::Flush(EsxFlushReason)+412)
04-03 19:37:42.797: I/DEBUG(354): #16 pc 0017759d /system/vendor/lib/egl/libGLESv2_adreno.so (EsxCmdMgr::GetCmdSpace(EsxCmdBufType, unsigned int)+140)
04-03 19:37:42.797: I/DEBUG(354): #17 pc 00173653 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxBltLib::CopyBltHw(EsxBltCopy const*)+938)
04-03 19:37:42.798: I/DEBUG(354): #18 pc 0017430d /system/vendor/lib/egl/libGLESv2_adreno.so (EsxBltLib::CopyBlt(EsxBltCopy const*)+132)
04-03 19:37:42.798: I/DEBUG(354): #19 pc 0010d4fd /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::HwBlt(EsxBltCopy const*)+12)
04-03 19:37:42.798: I/DEBUG(354): #20 pc 0010eb6b /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::Blt(EsxBltCopy const*)+10)
04-03 19:37:42.798: I/DEBUG(354): #21 pc 0010ec81 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::BlitRect(EsxResource*, EsxResource*, EsxRect, EsxRect*, int)+272)
04-03 19:37:42.798: I/DEBUG(354): #22 pc 0010ed67 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::PreserveBackBufferViaBlt(int)+126)
04-03 19:37:42.798: I/DEBUG(354): #23 pc 001159a7 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::ProcessAndSubmitRendering(EsxFlushReason)+134)
04-03 19:37:42.798: I/DEBUG(354): #24 pc 00177435 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxCmdMgr::Flush(EsxFlushReason)+412)
04-03 19:37:42.799: I/DEBUG(354): #25 pc 0017759d /system/vendor/lib/egl/libGLESv2_adreno.so (EsxCmdMgr::GetCmdSpace(EsxCmdBufType, unsigned int)+140)
04-03 19:37:42.799: I/DEBUG(354): #26 pc 00173653 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxBltLib::CopyBltHw(EsxBltCopy const*)+938)
04-03 19:37:42.799: I/DEBUG(354): #27 pc 0017430d /system/vendor/lib/egl/libGLESv2_adreno.so (EsxBltLib::CopyBlt(EsxBltCopy const*)+132)
04-03 19:37:42.799: I/DEBUG(354): #28 pc 0010d4fd /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::HwBlt(EsxBltCopy const*)+12)
04-03 19:37:42.799: I/DEBUG(354): #29 pc 0010eb6b /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::Blt(EsxBltCopy const*)+10)
04-03 19:37:42.799: I/DEBUG(354): #30 pc 0010ec81 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::BlitRect(EsxResource*, EsxResource*, EsxRect, EsxRect*, int)+272)
04-03 19:37:42.799: I/DEBUG(354): #31 pc 0010ed67 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::PreserveBackBufferViaBlt(int)+126)
04-03 19:37:42.800: I/DEBUG(354): #32 pc 001159a7 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::ProcessAndSubmitRendering(EsxFlushReason)+134)
04-03 19:37:42.800: I/DEBUG(354): #33 pc 00177435 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxCmdMgr::Flush(EsxFlushReason)+412)
04-03 19:37:42.800: I/DEBUG(354): #34 pc 0017759d /system/vendor/lib/egl/libGLESv2_adreno.so (EsxCmdMgr::GetCmdSpace(EsxCmdBufType, unsigned int)+140)
04-03 19:37:42.800: I/DEBUG(354): #35 pc 00173653 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxBltLib::CopyBltHw(EsxBltCopy const*)+938)
04-03 19:37:42.800: I/DEBUG(354): #36 pc 0017430d /system/vendor/lib/egl/libGLESv2_adreno.so (EsxBltLib::CopyBlt(EsxBltCopy const*)+132)
04-03 19:37:42.800: I/DEBUG(354): #37 pc 0010d4fd /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::HwBlt(EsxBltCopy const*)+12)
04-03 19:37:42.801: I/DEBUG(354): #38 pc 0010eb6b /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::Blt(EsxBltCopy const*)+10)
04-03 19:37:42.801: I/DEBUG(354): #39 pc 0010ec81 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::BlitRect(EsxResource*, EsxResource*, EsxRect, EsxRect*, int)+272)
04-03 19:37:42.801: I/DEBUG(354): #40 pc 0010ed67 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::PreserveBackBufferViaBlt(int)+126)
04-03 19:37:42.801: I/DEBUG(354): #41 pc 001159a7 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::ProcessAndSubmitRendering(EsxFlushReason)+134)
04-03 19:37:42.801: I/DEBUG(354): #42 pc 00177435 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxCmdMgr::Flush(EsxFlushReason)+412)
04-03 19:37:42.801: I/DEBUG(354): #43 pc 0017759d /system/vendor/lib/egl/libGLESv2_adreno.so (EsxCmdMgr::GetCmdSpace(EsxCmdBufType, unsigned int)+140)
04-03 19:37:42.801: I/DEBUG(354): #44 pc 00173653 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxBltLib::CopyBltHw(EsxBltCopy const*)+938)
04-03 19:37:42.802: I/DEBUG(354): #45 pc 0017430d /system/vendor/lib/egl/libGLESv2_adreno.so (EsxBltLib::CopyBlt(EsxBltCopy const*)+132)
04-03 19:37:42.802: I/DEBUG(354): #46 pc 0010d4fd /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::HwBlt(EsxBltCopy const*)+12)
04-03 19:37:42.802: I/DEBUG(354): #47 pc 0010eb6b /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::Blt(EsxBltCopy const*)+10)
04-03 19:37:42.802: I/DEBUG(354): #48 pc 0010ec81 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::BlitRect(EsxResource*, EsxResource*, EsxRect, EsxRect*, int)+272)
04-03 19:37:42.802: I/DEBUG(354): #49 pc 0010ed67 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::PreserveBackBufferViaBlt(int)+126)
04-03 19:37:42.802: I/DEBUG(354): #50 pc 001159a7 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::ProcessAndSubmitRendering(EsxFlushReason)+134)
04-03 19:37:42.802: I/DEBUG(354): #51 pc 00177435 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxCmdMgr::Flush(EsxFlushReason)+412)
04-03 19:37:42.803: I/DEBUG(354): #52 pc 0017759d /system/vendor/lib/egl/libGLESv2_adreno.so (EsxCmdMgr::GetCmdSpace(EsxCmdBufType, unsigned int)+140)
04-03 19:37:42.803: I/DEBUG(354): #53 pc 00173653 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxBltLib::CopyBltHw(EsxBltCopy const*)+938)
04-03 19:37:42.803: I/DEBUG(354): #54 pc 0017430d /system/vendor/lib/egl/libGLESv2_adreno.so (EsxBltLib::CopyBlt(EsxBltCopy const*)+132)
04-03 19:37:42.803: I/DEBUG(354): #55 pc 0010d4fd /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::HwBlt(EsxBltCopy const*)+12)
04-03 19:37:42.803: I/DEBUG(354): #56 pc 0010eb6b /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::Blt(EsxBltCopy const*)+10)
04-03 19:37:42.803: I/DEBUG(354): #57 pc 0010ec81 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::BlitRect(EsxResource*, EsxResource*, EsxRect, EsxRect*, int)+272)
04-03 19:37:42.803: I/DEBUG(354): #58 pc 0010ed67 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::PreserveBackBufferViaBlt(int)+126)
04-03 19:37:42.804: I/DEBUG(354): #59 pc 001159a7 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::ProcessAndSubmitRendering(EsxFlushReason)+134)
04-03 19:37:42.804: I/DEBUG(354): #60 pc 00177435 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxCmdMgr::Flush(EsxFlushReason)+412)
04-03 19:37:42.804: I/DEBUG(354): #61 pc 0017759d /system/vendor/lib/egl/libGLESv2_adreno.so (EsxCmdMgr::GetCmdSpace(EsxCmdBufType, unsigned int)+140)
04-03 19:37:42.804: I/DEBUG(354): #62 pc 00173653 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxBltLib::CopyBltHw(EsxBltCopy const*)+938)
04-03 19:37:42.804: I/DEBUG(354): #63 pc 0017430d /system/vendor/lib/egl/libGLESv2_adreno.so (EsxBltLib::CopyBlt(EsxBltCopy const*)+132)
04-03 19:37:43.285: I/AudioFlinger(357): BUFFER TIMEOUT: remove(4099) from active list on thread 0xb59c4000
04-03 19:37:43.381: W/ActivityManager(859): Force finishing activity 1 com.xyz.myapp/.MainLandscape
04-03 19:37:43.382: I/DEBUG(354): Tombstone written to: /data/tombstones/tombstone_09
04-03 19:37:43.382: I/BootReceiver(859): Copying /data/tombstones/tombstone_09 to DropBox (SYSTEM_TOMBSTONE)
04-03 19:37:43.384: W/AudioTrack(4064): releaseBuffer() track 0xb491df80 disabled due to previous underrun, restarting
04-03 19:37:43.396: D/audio_hw_primary(357): out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
04-03 19:37:43.446: I/Adreno(859): EGLInit: QTI Build: 01/29/15, 1bccc5d, I0ba6dce82d
04-03 19:37:43.452: I/WindowState(859): WIN DEATH: Window{10b6ffea u0 com.xyz.myapp/com.xyz.myapp.MainLandscape}
04-03 19:37:43.463: I/OpenGLRenderer(859): Initialized EGL, version 1.4
04-03 19:37:43.467: I/Zygote(377): Process 4064 exited due to signal (11)
04-03 19:37:43.479: I/ActivityManager(859): Process com.xyz.myapp (pid 4064) has died
04-03 19:37:43.513: V/ActivityManager(859): Display changed displayId=0
04-03 19:37:43.514: I/InputReader(859): Reconfiguring input devices. changes=0x00000004
04-03 19:37:43.514: I/InputReader(859): Device reconfigured: id=5, name='atmel_mxt_ts', size 1440x2560, orientation 0, mode 1, display id 0
04-03 19:37:43.516: I/ActivityManager(859): Config changes=480 {1.0 ?mcc?mnc en_US ?layoutDir sw411dp w411dp h658dp 560dpi nrml port finger -keyb/v/h -nav/h s.9}
04-03 19:37:43.530: W/AudioPolicyManager(357): unregisterEffect() unknown effect ID 39
04-03 19:37:43.530: W/AudioFlinger(357): session id 36 not found for pid 4064
04-03 19:37:43.530: W/AudioFlinger(357): removeEffect_l() 0xb59c4000 cannot promote chain for effect 0xb5958d80
04-03 19:37:43.530: W/AudioPolicyManager(357): unregisterEffect() unknown effect ID 39
04-03 19:37:43.540: D/ImsConfigImpl(1308): onConfigurationChange
04-03 19:37:43.546: E/SurfaceFlinger(258): rejecting buffer: bufWidth=1792, bufHeight=728, front.active.{w=225, h=225}
04-03 19:37:43.562: E/SurfaceFlinger(258): rejecting buffer: bufWidth=1664, bufHeight=728, front.active.{w=225, h=225}
04-03 19:37:43.717: I/WindowManager(859): Screen frozen for +232ms due to Window{eccfac3 u0 com.android.systemui.ImageWallpaper}
04-03 19:37:45.792: I/art(859): Explicit concurrent mark sweep GC freed 16618(953KB) AllocSpace objects, 12(2MB) LOS objects, 30% free, 37MB/53MB, paused 1.137ms total 68.663ms
04-03 19:37:45.855: D/audio_hw_primary(357): disable_audio_route: reset and update mixer path: low-latency-playback speaker
04-03 19:37:45.856: D/audio_hw_primary(357): disable_snd_device: snd_device(2: speaker)
Any help would be very much appreciated. Thanks a lot in advance.
So far (even in Android M) there's no bug fix for the graphics driver bug (Adreno 420), but I found a way to work around the bug. It's definitely not a long time solution, but for the moment it's just the best available to stop apps from crashing.
I reduced the number of graphics layers to a minimum (flattened many layered graphics)
I disabled GPU rendering for particular graphic layers. It slows the drawing down a bit, but not significant.
view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
Within the "software" layers, you can still set particular views to "hardware" rendering, if you need to.
view.setLayerType(View.LAYER_TYPE_HARDWARE, null);