tgkill - native error on Android 8.0 Samsung S8
Asked Answered
D

2

18

Recently I started getting Android native crashes (reported in Google Play vitals). They happen only on Samsung Galaxy S8 or S8+ phones with Android 8.

According to the stack trace it is related to the UI renderer thread. However I don't know how to fix it or even where exactly in the app does it happen.

Any idea how to find out where in the app does this happen? And why only Galaxy S8 with Android 8 are affected? Thanks.

backtrace:
  #00  pc 0000000000071854  /system/lib64/libc.so (tgkill+8)
  #01  pc 000000000001e058  /system/lib64/libc.so (abort+88)
  #02  pc 0000000000008248  /system/lib64/liblog.so (__android_log_assert+328)
  #03  pc 0000000000052430  /system/lib64/libhwui.so (_ZN7android10uirenderer12renderthread10EglManager11damageFrameERKNS1_5FrameERK6SkRect+320)
  #04  pc 000000000004f9dc  /system/lib64/libhwui.so (_ZN7android10uirenderer12renderthread14OpenGLPipeline4drawERKNS1_5FrameERK6SkRectS8_RKNS0_12FrameBuilder13LightGeometryEPNS0_16LayerUpdateQueueERKNS0_4RectEbRKNS0_15BakedOpRenderer9LightInfoERKNSt3__16vectorINS_2spINS0_10RenderNodeEEENSM_9allocatorISQ_EEEEPNS0_19FrameInfoVisualizerE+76)
  #05  pc 000000000004d7e0  /system/lib64/libhwui.so (_ZN7android10uirenderer12renderthread13CanvasContext4drawEv+176)
  #06  pc 00000000000511e8  /system/lib64/libhwui.so (_ZN7android10uirenderer12renderthread13DrawFrameTask3runEv+184)
  #07  pc 0000000000058494  /system/lib64/libhwui.so (_ZN7android10uirenderer12renderthread12RenderThread10threadLoopEv+356)
  #08  pc 0000000000011c58  /system/lib64/libutils.so (_ZN7android6Thread11_threadLoopEPv+280)
  #09  pc 00000000000fd688  /system/lib64/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+136)
  #10  pc 000000000006de44  /system/lib64/libc.so (_ZL15__pthread_startPv+36)
  #11  pc 000000000001f9a4  /system/lib64/libc.so (__start_thread+68)
Declinatory answered 15/5, 2018 at 22:56 Comment(9)
I have the same issue, exclusive on android 8. Did you find any solution?Customs
@Deividi Cavarzan Not yet. Sorry.Declinatory
Same for me here :(Miscreance
Same here. It's the #1 issue in out crash reports.Radioluminescence
do you have any EditTexts in your layout? Do you have an actual Samsung device to test?Spinster
@LazarosPapadopoulos The app contains EditTexts. Why do you think it is related to EditTexts? I have Samsung phone but not with the Android 8.0.Declinatory
@Declinatory I have the same backtrace with Samsung devices android 8.0. The crash happens sometimes when the user closes a Dialog which contains EditText. Cannot reproduce in other devices or emulator with Android 8.0.Spinster
@Declinatory did u get solution ?Heterochromatin
@JithishPN No but it no longer appears in the Android Developer Console. So it was probably fixed by Samsung.Declinatory
C
4

Logcat analysis

This is where your code is crashing EglManager.cpp:

void EglManager::damageFrame(const Frame& frame, const SkRect& dirty) {
#ifdef EGL_KHR_partial_update
    if (EglExtensions.setDamage && mSwapBehavior == SwapBehavior::BufferAge) {
        EGLint rects[4];
        frame.map(dirty, rects);
        if (!eglSetDamageRegionKHR(mEglDisplay, frame.mSurface, rects, 1)) {
            LOG_ALWAYS_FATAL("Failed to set damage region on surface %p, error=%s",
                    (void*)frame.mSurface, egl_error_str());
        }
    }
#endif
}

Called from SkiaOpenGLPipeline.cpp:

SkiaOpenGLPipeline::draw //method

mEglManager.damageFrame(frame, dirty);

Why ?

It seems you may have a 'Failed to set damage region on surface', probably after onResume() from screen rotation or onPause() in your Activity. See fixing-common-android-lifecycle-issues

Fixes

I started getting this crash after updating to Oreo, every-time I started my app, with the message "Failed to set damage region on surface" followed by all those lines about libhwui.so and EglManager And it turned out that, for some obscure reason, it was somehow caused by a totally unrelated problem in my app (too many open files [forgot to close them]). After fixing this my own bug, no more crashes on the EglManager. [also note that crashes only happen if hardware acceleration is turned on] Ref: issuetracker.google.com { issue 70259031}

See also: eglCreateWindowSurface {SO problem}, Logging, native-crashes-on-abort-in-developer-console-with-oreo-8-1 {SO problem}, hardware-acceleration, opengl, GLSurfaceView

Cavesson answered 24/1, 2019 at 17:57 Comment(8)
Thanks, very thorough! But, I dont think OP (or I) use any openGL. This issue happens when you have a dialog open, press and hold on a textfield to bring up the textHandlers, and then close the dialog, or change orientation. Only workaround I could find so far was changing all DialogFragments into normal fragments rendered over my activity. Not ideal, as it needs hacks to prevent the user from interacting with the activity, etc. Its almost like it is trying to draw on the dialog before it is available (which would make sense looking at your description), but how does one fix that?Gyniatrics
Did a quick test, disabling hardware acceleration did the trick. Its not ideal, but it is better than a crash. Thanks Jon!Gyniatrics
@Gyniatrics Glad you have a few work-arounds (frags/accel) until Samsung/google fix issue 70259031. EGL ("Embedded-System Graphics Library") where you are crashing, is an interface between Khronos rendering APIs (such as OpenGL, OpenGL ES or OpenVG) and the underlying native platform windowing system. Try using gltracer to see how/if the EGL is using OpenGL (OpenGLPipeline) and all that is going on in your dialog frame. Good luck !.Cavesson
@Gyniatrics See Control hardware acceleration You can control hardware acceleration at the following levels: Application Activity Window ViewCavesson
Thanks! I've been looking into it. I was trying to check the phone model and then deactivating hardware acceleration on the view if it is an s8 or s8+. Unfortunately that did not work. It seems one needs to deactivate it for the entire activity (as one can not deactivate on a window level, only activate) and this can only be done in the manifest. So, that means that certain activities will just be slow for all devices. I'll look into it a bit more. IF I can find something, I'll be sure to update this for anyone else with the same issues!Gyniatrics
@Gyniatrics You could try to deactivate acceleration at the Activity level (in the Manifest) then dynamically re-activate any critical views that would benefit from acceleration (and don't have this bug)...all a bit of a hack, but may be worth it.Cavesson
Ill definitely try that next! Unfortunately some other work has taken priority. But I'll let you know how it went!Gyniatrics
You are a champ!! Managed to get it working like you suggested. In the offending activity, I then put if (!(phoneMake.equalsIgnoreCase("samsung") && (phoneModel.startsWith("SM-G950") || phoneModel.startsWith("SM-G955")))) { getWindow().setFlags( WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); } To enable the acceleration whenever possible. Thanks again SO MUCH for your help!!Gyniatrics
S
-1

This problem seems to be restricted to Samsung devices with Android 8.0, it is some bug about text selection and/or entering text and/or closing a dialog containing EditTexts and/or rotating the screen.

It seems that there is a workaround. Create a xml file in the res/drawable folder defining an empty shape, as follows.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<!-- nothing -->
</shape>

In the layout file, add the following attributes to the EditTexts:

android:textSelectHandle="@drawable/empty"
android:textSelectHandleRight="@drawable/empty"
android:textSelectHandleLeft="@drawable/empty"

source: Samsung developers forum crash Samsung Galaxy S8 libhwui.so

Spinster answered 6/12, 2018 at 19:51 Comment(1)
I was able to reproduce this issue, but the fix doesn't seem to make a difference!Gyniatrics

© 2022 - 2024 — McMap. All rights reserved.