Skip to content
This repository was archived by the owner on Apr 27, 2024. It is now read-only.
This repository was archived by the owner on Apr 27, 2024. It is now read-only.

Crash in native code #52

Open
Open

Description

@baldur

Hi I just diving in to troubleshoot a crash that started happening after we updated to android 4.4. The devices affected are Samsung Galaxy S4, we have a nexus running 4.4 which doesn't seem to be affected or at least we have not experience the problem there, nore did we with our S4 prior to the 4.4 update.

I figured I would raise the issue here incase someone already knows about this issue or has some insights. I will follow up as I progress in my search.

********** Crash dump: **********
Build fingerprint: 'samsung/jflteuc/jflteatt:4.4.2/KOT49H/I337UCUFNB1:user/release-keys'
pid: 19670, tid: 19693, name: Thread-8277  >>> com.mapzen <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 80e6c000 
Stack frame #00  pc 0002225c  /system/lib/libc.so (__memcpy_base+227)
Stack frame #01  pc 00071107  /system/vendor/lib/egl/libGLESv2_adreno.so (rb_memcpy+282)
Stack frame #02  pc 0007d4a1  /system/vendor/lib/egl/libGLESv2_adreno.so (rb_vbo_cache_buffer+320)
Stack frame #03  pc 000465a7  /system/vendor/lib/egl/libGLESv2_adreno.so (cache_vbo_attrib+298)
Stack frame #04  pc 0004962d  /system/vendor/lib/egl/libGLESv2_adreno.so
Stack frame #05  pc 00049da5  /system/vendor/lib/egl/libGLESv2_adreno.so (core_glDrawElementsInstancedXXX+140)
Stack frame #06  pc 00049fd7  /system/vendor/lib/egl/libGLESv2_adreno.so (core_glDrawElements+10)
Stack frame #07  pc 00039767  /system/vendor/lib/egl/libGLESv2_adreno.so (glDrawElements+28)
Stack frame #08  pc 00020bcc  /system/lib/libdvm.so (dvmPlatformInvoke+112)
Stack frame #09  pc 00051927  /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
Stack frame #10  pc 0002a060  /system/lib/libdvm.so
Stack frame #11  pc 00031510  /system/lib/libdvm.so (dvmMterpStd(Thread*)+76)
Stack frame #12  pc 0002eba8  /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
Stack frame #13  pc 00063e75  /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+336)
Stack frame #14  pc 00063e99  /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20)
Stack frame #15  pc 00058b6b  /system/lib/libdvm.so
Stack frame #16  pc 0000d278  /system/lib/libc.so (__thread_entry+72)
Stack frame #17  pc 0000d410  /system/lib/libc.so (pthread_create+240)

Activity

  1. hjanetzek commented on Mar 14, 2014

    @hjanetzek
    Member

    The same crash with adreno chipset and kitkat was reported earlier today (via mail). The user found that GL.glDrawElements(GL20.GL_LINES ... ) in ExtrusionRenderer triggers the problem. I havent looked further into it yet, though google:'adreno kitkat rb_memcpy' shows the issue also happens elsewhere.

  2. baldur commented on Mar 19, 2014

    @baldur
    Author

    Just dumping info here for what it's worth: https://gist.github.com/baldur/9652381

    it's a bit strange the map loads fine but as soon as you start interact with it it eventually will crash and it's almost always shortly after a GC run. I have tried fiddling with some of the code including the line you mentioned and I am not convinced it's the same issue. I've been unable to attach a gdb debugger due various issues http://developer.samsung.com/forum/thread/ndk-debugging-with-gdb/77/178834 being one of them.

    I am sort of running out of ideas and if you have any advice on how I can help with debugging this further please let me know ... thankfully we do have devices still with 4.3 so we are not pressed for time but I can definitely spend a bit more time if you have ideas for what would be good to experiment with in order to identify the culprit.

  3. hjanetzek commented on Mar 19, 2014

    @hjanetzek
    Member

    There were some reports for Unity providing similar traces. So I'm pretty sure it's a bug in the driver - or in Android memory management. One way to test if it is caused by buffer data is being garbage collected before moved to GL memory would be to comment out 'mUsedBuffers = releaseAll(mUsedBuffers);' in MapRenderer. If thats the case one could ensure to keep references to the Buffer objects and not reuse them until the corresponding VBOs are drawn once.

  4. hjanetzek commented on Mar 20, 2014

    @hjanetzek
    Member

    Could you try changing GL_DYNAMIC_DRAW in BufferObject to GL_STATIC_DRAW? It might use a different path in the driver and circumvent the problem.

  5. baldur commented on Mar 20, 2014

    @baldur
    Author

    Tried both of those to no avail ... everything points to the problem with the driver as you mentioned. Next step I am planning on is to root the device and reset some of the settings as is suggested here https://developer.qualcomm.com/forum/qdevnet-forums/mobile-technologies/mobile-gaming-graphics-optimization-adreno/26936. This mentions opengl 3 so I am not sure if it applies to our situation but it's worth a shot.

    The post does mention another workaround which I didn't quite understand but perhaps you understand what he means by:

    I have found another thing to do that helps decrease the chance of it crashing, 
    this is another terrible workaround but it "works." Every time I draw something with 
    glDrawRangeElements, I insert a eglSwapBuffers. This has the downfall of absolutely 
    murdering performance and introducing flickering, but again, it helps lessen the 
    chance of crashing.
    
  6. stleusc commented on Apr 13, 2014

    @stleusc
    Contributor

    I just had reported the same via email and then I found it here ;-)
    One user of my app reported same issue, same device, etc.
    Any idea here?

  7. hjanetzek commented on Apr 14, 2014

    @hjanetzek
    Member

    If you could check the ant traces file one might see if the crash is triggered by a rendering call from the same renderer - One reporter told me that it happens in ExtrusionRenderer but he didnt replied back to confirm that it's the only place. In this case one could disable 3D buildings for blacklisted drivers...

  8. baldur commented on Apr 14, 2014

    @baldur
    Author

    Just for the record I can crash without the building layer added ... so I am not sure if that approach will suffice.

  9. bcamper commented on Apr 14, 2014

    @bcamper

    Also blacklisting two of the most popular GPUs doesn't feel like a great
    permanent solution (though maybe a short-term band-aid).

    On Mon, Apr 14, 2014 at 11:38 AM, Baldur Gudbjornsson <
    [email protected]> wrote:

    Just for the record I can crash without the building layer added ... so I
    am not sure if that approach will suffice.

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/52#issuecomment-40381172
    .

  10. hjanetzek commented on Apr 14, 2014

    @hjanetzek
    Member
  11. stleusc commented on Apr 14, 2014

    @stleusc
    Contributor

    Any way to use opengl 3 on these devices? Read this fixed it in other apps.

  12. hjanetzek commented on Apr 15, 2014

    @hjanetzek
    Member

    @stleusc where did you find that?

  13. 9 remaining items

  14. baldur commented on May 6, 2014

    @baldur
    Author

    @hjanetzek we have made some progress here and have identified the culprit:
    https://github.com/opensciencemap/vtm/blob/master/vtm/src/org/oscim/renderer/elements/TextureLayer.java#L192

    By commenting out that GL.glDrawElements we have a running app that doesn't crash ... we found this by looking at which shaders where affected and the app also runs by making main methods in this shader blank:

    https://github.com/opensciencemap/vtm/blob/master/vtm/resources/assets/shaders/texture_layer.glsl
    

    We don't know yet how to fix it but we wanted to give you an update to see if you had thoughts in the light of this discovery.

  15. hjanetzek commented on May 7, 2014

    @hjanetzek
    Member

    When an attribute is not used in the shader it will be optimized out and GL.glGetAttribLocation will return an invalid handle (< 0) So glDrawElements will probably fail before even fetching data from the vbo (fail in the usual GL way - just show nothing).
    If you are sure that only the texture renderer is involved, i.e. the crash happens when the texture renderer is alone active one could try to use dynamic vertex arrays instead of the vbo:
    b729a52

  16. baldur commented on May 7, 2014

    @baldur
    Author

    Awesome thanks so much, this patch appears to be working. Looks like the icons for pois are missing though.

  17. hjanetzek commented on May 7, 2014

    @hjanetzek
    Member

    Good to hear that this works. I've added no-vbo option to SymbolLayer now: bdc63d8

    actually squashed the SymbolLayer change again and added useVBO option to ElementLayers for putting vertex data into a separate buffer. This only works when ElementLayers contains only TextureLayers though.

  18. baldur commented on May 7, 2014

    @baldur
    Author

    Awesome ... poi's are back and the map appears to be running smoothly on affected devices. Thanks again for fixing this.

  19. stleusc commented on May 8, 2014

    @stleusc
    Contributor

    I also gave the fix to my affected users.
    Report back is that the issue is gone!

    Great work!
    Thanks....

  20. hjanetzek commented on May 12, 2014

    @hjanetzek
    Member

    Merged with a check in MapView to enable the workaround for Samsung devices running Kitkat - If you have the exact models for the affected devices this test could be made more specific, but I guess devices running Kitkat are fast enough to have no measurable performance difference using no VBO in this case.

  21. bcamper commented on May 12, 2014

    @bcamper

    Thanks! We know the S4 (Adreno 320) and S5 (Adreno 330) devices are
    affected - those are two of the most popular (maybe most?) Samsung devices
    in the US.

    On Mon, May 12, 2014 at 9:12 AM, Hannes Janetzek
    [email protected]:

    Merged with a check in MapView to enable the workaround for Samsung
    devices running Kitkat - If you have the exact models for the affected
    devices this test could be made more specific, but I guess devices running
    Kitkat are fast enough to have no measurable performance difference using
    no VBO in this case.

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/52#issuecomment-42829673
    .

  22. hjanetzek commented on May 16, 2014

    @hjanetzek
    Member

    I could reproduce the crash with a S5 now. It seems the problem is actually the use of glBufferSubData (which seems to have realiably issues with adreno). Just disabling glBufferSubData makes it work for me. The crash probably shows up in text renderer because its vertex data is most frequently replaced. So I guess a more appropriate fix would be 9c1ae88

  23. baldur commented on Jun 24, 2014

    @baldur
    Author

    @hjanetzek we found another device which has issues
    HTC One (M8) 4.4.2
    HTC Sense version 6.0

    Here is a gist from the logcat if that's useful https://gist.github.com/baldur/9dd383bfba1b83bb9593

    As before we tryied commenting out the GL.glDrawElements call in:
    https://github.com/opensciencemap/vtm/blob/master/vtm/src/org/oscim/renderer/elements/TextureLayer.java
    Which stops the crashing from happening. We are happy to help troubleshoot this problem so feel free to ask us for more details or try things to sort this out.

  24. hjanetzek commented on Jun 24, 2014

    @hjanetzek
    Member

    It seems to be the same problem. I wasnt pleased with the test for Samsung with Kitkat anyway - now I just found that one can get the vendor/renderer info via glGetString to disable use of glBufferSubData for these chips. Could you try https://github.com/opensciencemap/vtm/tree/testing-adreno

  25. baldur commented on Jun 24, 2014

    @baldur
    Author

    awesome that did the trick ... thanks

  26. Bezzu commented on Mar 25, 2015

    @Bezzu

    Hi,
    I have had the same issue on a samsung galaxy s4 mini with android 4.4.2 and i have solved it setting the variable, called "NO_BUFFER_SUB_DATA", in the file vtm/org/oscim/backend/GLAdapter.java to true.

  27. added 2 commits that reference this issue on Nov 18, 2018
    c02cf57
    e74052c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions