Visitar URL original
NG Android (using Button) crashes with SIGABRT on API Level 21 · Issue #4256 · NativeScript/NativeScript · GitHub
Skip to content

NG Android (using Button) crashes with SIGABRT on API Level 21 #4256

Description

@buuhuu

We faced the issue that our App crashes on Android 5.0 where it is working fine on Android 4.2 and higher versions. I cannot reproduce that on a sample app but here are the crash details:

F/libc    ( 3228): Fatal signal 6 (SIGABRT), code -6 in tid 3228 (eisen.piazza.nc)
I/DEBUG   ( 1163): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   ( 1163): Build fingerprint: 'generic_x86_64/sdk_google_phone_x86_64/generic_x86_64:5.0.2/LSY66K/3729068:eng/test-keys'
I/DEBUG   ( 1163): Revision: '0'
I/DEBUG   ( 1163): ABI: 'x86'
I/DEBUG   ( 1163): pid: 3228, tid: 3228, name: eisen.piazza.nc  >>> ch.myapp.nc <<<
I/DEBUG   ( 1163): signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
I/DEBUG   ( 1163): Abort message: 'art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: can't call void android.view.View.setTranslationZ(float) on null object'
I/DEBUG   ( 1163):     eax 00000000  ebx 00000c9c  ecx 00000c9c  edx 00000006
I/DEBUG   ( 1163):     esi f7756f08  edi 00000002
I/DEBUG   ( 1163):     xcs 00000023  xds 0000002b  xes 0000002b  xfs 00000007  xss 0000002b
I/DEBUG   ( 1163):     eip f76c4446  ebp 00000c9c  esp ff7fe380  flags 00200286
I/DEBUG   ( 1163): 
I/DEBUG   ( 1163): backtrace:
I/DEBUG   ( 1163):     #00 pc 00075446  /system/lib/libc.so (tgkill+22)
I/DEBUG   ( 1163):     #01 pc 00021b1b  /system/lib/libc.so (pthread_kill+155)
I/DEBUG   ( 1163):     #02 pc 00023394  /system/lib/libc.so (raise+36)
I/DEBUG   ( 1163):     #03 pc 0001b874  /system/lib/libc.so (abort+84)
I/DEBUG   ( 1163):     #04 pc 003735e6  /system/lib/libart.so (art::Runtime::Abort()+294)
I/DEBUG   ( 1163):     #05 pc 000ec304  /system/lib/libart.so (art::LogMessage::~LogMessage()+1668)
I/DEBUG   ( 1163):     #06 pc 00101598  /system/lib/libart.so (art::JniAbort(char const*, char const*)+1656)
I/DEBUG   ( 1163):     #07 pc 00101ecc  /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+108)
I/DEBUG   ( 1163):     #08 pc 00102308  /system/lib/libart.so (art::ScopedCheck::CheckVirtualMethod(_jobject*, _jmethodID*)+504)
I/DEBUG   ( 1163):     #09 pc 00112cdf  /system/lib/libart.so (art::CheckJNI::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, char*)+143)
I/DEBUG   ( 1163):     #10 pc 000754c9  /system/lib/libandroid_runtime.so (_JNIEnv::CallVoidMethod(_jobject*, _jmethodID*, ...)+41)
I/DEBUG   ( 1163):     #11 pc 0011f059  /system/lib/libandroid_runtime.so
I/DEBUG   ( 1163):     #12 pc 00089646  /data/dalvik-cache/x86/system@framework@boot.oat

I traced that down to be related to the android.view.Button(). It is instantiated using the default constructor which uses the default style which in turn sets the StateListAnimator of the View. At that point the target property is properly attached to the ObjectAnimator but once setNative is invoked and with it button.android.ts#L117 the StateListAnimator is set to null and with it the target of the ObjectAnimator. This is the causing the error in the Thread handling the animation.

In my application I patched tns-core-modules/ui/button.android.js to use APILEVEL > 21 instead of APILEVEL >= 21 which resolves the crash though its not the root cause I think.

I think that on Button instantiation the animation is queued as pending animation in another thread while setNative is called and resets the target of the ObjectAnimator on the UI thread. A better approach then calling setStateListAnimator(null) would be to instantiate the Button with a style and define it in the style so it is already set to null at instantiation time.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Activity

  1. changed the title [-]Android crashes with SIGABRT on API Level 21[/-] [+]NG Android (using Button) crashes with SIGABRT on API Level 21[/+] on May 23, 2017
  2. NickIliev commented on May 23, 2017

    @NickIliev
    Contributor

    @buuhuu we will try to isolate this case but still without an application to reproduce the error it will hard to uncover what is actually happening. If you can provide a simplified test case which reproduces the thrown error it would be of great help.

  3. buuhuu commented on May 23, 2017

    @buuhuu
    ContributorAuthor

    I have to clarify if we can handle that via enterprise support. It's not reproducible using a simple sample application.

  4. vakrilov commented on May 25, 2017

    @vakrilov
    Contributor

    Hi @buuhuu
    We appreciate you digging into this issue!
    As a clarification the APILEVEL >= 21 check is there because the setStateListAnimator does not exist in pervious versions of android. That said, this issue might be a result of a code that is fixed in latter versions of android (>21).

    Do you think that there is another way to secure that the concurrency issue you explained does not happen in API 21 - perhaps canceling any pending animations for this view?

    In any case, managing to reproduce this issue in a unit test or in a test-app will allow us to make sure that any change in the NativeScript code, fixes the problem. If you have such example/app it would be useful.

  5. NickIliev commented on Jun 5, 2017

    @NickIliev
    Contributor

    Closing this issue due to inactivity.

    @buuhuu if you have a sample app or unit test that can reproduce this do let us know so we can test it on our side and reopen & relabel this issue.

  6. ArdynVex commented on Jun 26, 2019

    @ArdynVex

    Still actual for android 5.0.1 (API 21)
    Here's log:

    A/art: art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: can't call void android.view.View.setTranslationZ(float) on null object art/runtime/check_jni.cc:65] in call to CallVoidMethodV art/runtime/check_jni.cc:65] from void android.animation.PropertyValuesHolder.nCallFloatMethod(java.lang.Object, long, float) art/runtime/check_jni.cc:65] "main" prio=5 tid=1 Runnable art/runtime/check_jni.cc:65] | group="main" sCount=0 dsCount=0 obj=0x75079000 self=0xb7f0b090 art/runtime/check_jni.cc:65] | sysTid=31474 nice=0 cgrp=default sched=0/0 handle=0xb6fd9ec8 art/runtime/check_jni.cc:65] | state=R schedstat=( 24467293580 344405388 3761 ) utm=2343 stm=103 core=0 HZ=100 art/runtime/check_jni.cc:65] | stack=0xbe6f5000-0xbe6f7000 stackSize=8MB art/runtime/check_jni.cc:65] | held mutexes= "mutator lock"(shared held) art/runtime/check_jni.cc:65] native: #00 pc 00004c58 /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+23) art/runtime/check_jni.cc:65] native: #01 pc 000034c1 /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+8) art/runtime/check_jni.cc:65] native: #02 pc 002458bd /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+68) art/runtime/check_jni.cc:65] native: #03 pc 0022acaf /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+146) art/runtime/check_jni.cc:65] native: #04 pc 000b00ef /system/lib/libart.so (art::JniAbort(char const*, char const*)+582) art/runtime/check_jni.cc:65] native: #05 pc 000b081f /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+58) art/runtime/check_jni.cc:65] native: #06 pc 000b1239 /system/lib/libart.so (art::ScopedCheck::CheckVirtualMethod(_jobject*, _jmethodID*)+404) art/runtime/check_jni.cc:65] native: #07 pc 000bab8b /system/lib/libart.so (art::CheckJNI::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)+70) art/runtime/check_jni.cc:65] native: #08 pc 00062e8f /system/lib/libandroid_runtime.so (???) art/runtime/check_jni.cc:65] native: #09 pc 0007156d /data/dalvik-cache/arm/system@framework@boot.oat (Java_android_animation_PropertyValuesHolder_nCallFloatMethod__Ljava_lang_Object_2JF+132) art/runtime/check_jni.cc:65] at android.animation.PropertyValuesHolder.nCallFloatMethod(Native method) art/runtime/check_jni.cc:65] at android.animation.PropertyValuesHolder.access$400(PropertyValuesHolder.java:38) art/runtime/check_jni.cc:65] at android.animation.PropertyValuesHolder$FloatPropertyValuesHolder.setAnimatedValue(PropertyValuesHolder.java:1296) art/runtime/check_jni.cc:65] at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:952) art/runtime/check_jni.cc:65] at android.animation.ValueAnimator.animationFrame(ValueAnimator.java:1207) art/runtime/check_jni.cc:65] at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1248) art/runtime/check_jni.cc:65] at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:659) art/runtime/check_jni.cc:65] at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:682) art/runtime/check_jni.cc:65] at android.view.Choreographer$CallbackRecord.run(Choreographer.java:795) art/runtime/check_jni.cc:65] at android.view.Choreographer.doCallbacks(Choreographer.java:598) art/runtime/check_jni.cc:65] at android.view.Choreographer.doFrame(Choreographer.java:566) art/runtime/check_jni.cc:65] at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:781) art/runtime/check_jni.cc:65] at android.os.Handler.handleCallback(Handler.java:810) art/runtime/check_jni.cc:65] at android.os.Handler.dispatchMessage(Handler.java:99) art/runtime/check_jni.cc:65] at android.os.Looper.loop(Looper.java:189) art/runtime/check_jni.cc:65] at android.app.ActivityThread.main(ActivityThread.java:5529) art/runtime/check_jni.cc:65] at java.lang.reflect.Method.invoke!(Native method) art/runtime/check_jni.cc:65] at java.lang.reflect.Method.invoke(Method.java:372) art/runtime/check_jni.cc:65] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950) art/runtime/check_jni.cc:65] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745) art/runtime/check_jni.cc:65] A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 31474 (ipt.syrexsurvey)

  7. ArdynVex commented on Jun 27, 2019

    @ArdynVex

    Fix APILEVEL > 21 didn't helped.
    But I removed css class btn-outline from all Button elements and now it works!!!

  8. nikoTM commented on Jul 9, 2019

    @nikoTM

    @NickIliev the issue needs to be reopened. Reproduced by (Android 5):

    import { Component, OnInit } from '@angular/core';
    
    @Component({
        selector: 'ns-outline-bug',
        moduleId: module.id,
        template: `
            <GridLayout class="page">
                <Button
                    *ngIf="showButton"
                    class="btn btn-outline"
                    text="Buggy button"
                ></Button>
            </GridLayout>
        `
    })
    export class BuggyComponent implements OnInit {
        public showButton: boolean;
        constructor() {}
    
        ngOnInit(): void {
            setTimeout(() => {
                this.showButton = true;
            }, 2000);
        }
    }

    EDIT:

    F/art     (32096): sart/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: can't call void android.view.View.setTranslationZ(float) on null object
    F/art     (32096): sart/runtime/check_jni.cc:65]     in call to CallVoidMethodV
    F/art     (32096): sart/runtime/check_jni.cc:65]     from void android.animation.PropertyValuesHolder.nCallFloatMethod(java.lang.Object, long, float)
    

    A temporary fix is either to remove btn btn-outline (not sure if btn affects it), or change *ngIf to [visibility]="condition ? 'visible' : 'collapse'".

    The method should obviously check for null before trying to set TranslationZ

  9. NickIliev commented on Jul 10, 2019

    @NickIliev
    Contributor

    Reopening the issue as it is fully reproducible on device/emulator with API 21 - use this playground to reproduce.

  10. jorfranb commented on Jul 13, 2019

    @jorfranb

    Hello NativeScript team!, i have that issue too, for me in my own class type, the css property that was causing the problem was z-index, that get in trouble when the element has involve in some ng tag of Angular!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions