nstudio / nativescript-floatingactionbutton

Material Design Floating Action Button in NativeScript apps.
Other
137 stars 33 forks source link

[Android] Exception and crash during resume #36

Closed michelebombardi closed 8 years ago

michelebombardi commented 8 years ago

I'm using this plugin in my NativeScript Angular 2 project and when resuming the app often an exception is thrown causing an app crash.

My html:

<GridLayout rows="auto, *">
    <StackLayout row="1">
        <location></location>

        <CardView shadowColor="#FE00FC" elevation="10" margin="10">
            <StackLayout orientation="vertical">
                <Label text="Numeri Personali" verticalAlignment="center" horizontalAlignment="left" textWrap="true" class="card-header"></Label>
                <StackLayout class="hr-light"></StackLayout>

                [...ListView....]

            </StackLayout>
        </CardView>
    </StackLayout>

    <Fab row="1" class="fab-button"
        (tap)="showAddContactModal()"
        icon="res://ic_add_white_48dp"
        rippleColor="#f1f1f1"
        verticalAlignment="bottom"
        horizontalAlignment="right"
        hideOnSwipeOfView="contactsList">
    </Fab>
</GridLayout>

The full stacktrace:

java.lang.RuntimeException: Unable to resume activity {it.bmsoftware.sosnumbers/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: 
Calling js method onStart failed
TypeError: Cannot read property 'getViewById' of null
File: "/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/nativescript-floatingactionbutton/fab-common.js, line: 43, column: 41
StackTrace: 
    Frame: function:'FloatingActionButton.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/nativescript-floatingactionbutton/fab-common.js', line: 43, column: 42
    Frame: function:'eachChild', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 616, column: 23
    Frame: function:'LayoutBase._eachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/layouts/layout-base-common.js', line: 146, column: 22
    Frame: function:'View._loadEachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 619, column: 18
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 14
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view.js', line: 82, column: 35
    Frame: function:'eachChild', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 616, column: 23
    Frame: function:'LayoutBase._eachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/layouts/layout-base-common.js', line: 146, column: 22
    Frame: function:'View._loadEachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 619, column: 18
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 14
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view.js', line: 82, column: 35
    Frame: function:'eachChild', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 616, column: 23
    Frame: function:'ContentView._eachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/content-view/content-view.js', line: 65, column: 13
    Frame: function:'View._loadEachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 619, column: 18
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 14
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view.js', line: 82, column: 35
    Frame: function:'eachChild', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 616, column: 23
    Frame: function:'LayoutBase._eachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/layouts/layout-base-common.js', line: 146, column: 22
    Frame: function:'View._loadEachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 619, column: 18
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 14
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view.js', line: 82, column: 35
    Frame: function:'eachChild', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 616, column: 23
    Frame: function:'TabView._eachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/tab-view/tab-view-common.js', line: 243, column: 26
    Frame: function:'View._loadEachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 619, column: 18
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 14
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view.js', line: 82, column: 35
    Frame: function:'eachChild', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 616, column: 23
    Frame: function:'LayoutBase._eachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/layouts/layout-base-common.js', line: 146, column: 22
    Frame: function:'View._loadEachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 619, column: 18
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 14
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view.js', line: 82, column: 35
    Frame: function:'eachChild', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 616, column: 23
    Frame: function:'ContentView._eachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/content-view/content-view.js', line: 65, column: 13
    Frame: function:'Page._eachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/page/page-common.js', line: 265, column: 41
    Frame: function:'View._loadEachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 619, column: 18
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 14
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view.js', line: 82, column: 35
    Frame: function:'Page.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/page/page-common.js', line: 45, column: 35
    Frame: function:'eachChild', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 616, column: 23
    Frame: function:'Frame._eachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/frame/frame-common.js', line: 335, column: 13
    Frame: function:'View._loadEachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 619, column: 18
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 14
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view.js', line: 82, column: 35
    Frame: function:'ActivityCallbacksImplementation.onStart', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/frame/frame.js', line: 708, column: 22
    Frame: function:'NativeScriptActivity.onStart', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/frame/activity.js', line: 18, column: 25
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3400)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3440)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1510)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6077)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Caused by: com.tns.NativeScriptException: 
Calling js method onStart failed
TypeError: Cannot read property 'getViewById' of null
File: "/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/nativescript-floatingactionbutton/fab-common.js, line: 43, column: 41
StackTrace: 
    Frame: function:'FloatingActionButton.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/nativescript-floatingactionbutton/fab-common.js', line: 43, column: 42
    Frame: function:'eachChild', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 616, column: 23
    Frame: function:'LayoutBase._eachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/layouts/layout-base-common.js', line: 146, column: 22
    Frame: function:'View._loadEachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 619, column: 18
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 14
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view.js', line: 82, column: 35
    Frame: function:'eachChild', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 616, column: 23
    Frame: function:'LayoutBase._eachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/layouts/layout-base-common.js', line: 146, column: 22
    Frame: function:'View._loadEachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 619, column: 18
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 14
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view.js', line: 82, column: 35
    Frame: function:'eachChild', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 616, column: 23
    Frame: function:'ContentView._eachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/content-view/content-view.js', line: 65, column: 13
    Frame: function:'View._loadEachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 619, column: 18
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 14
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view.js', line: 82, column: 35
    Frame: function:'eachChild', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 616, column: 23
    Frame: function:'LayoutBase._eachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/layouts/layout-base-common.js', line: 146, column: 22
    Frame: function:'View._loadEachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 619, column: 18
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 14
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view.js', line: 82, column: 35
    Frame: function:'eachChild', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 616, column: 23
    Frame: function:'TabView._eachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/tab-view/tab-view-common.js', line: 243, column: 26
    Frame: function:'View._loadEachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 619, column: 18
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 14
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view.js', line: 82, column: 35
    Frame: function:'eachChild', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 616, column: 23
    Frame: function:'LayoutBase._eachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/layouts/layout-base-common.js', line: 146, column: 22
    Frame: function:'View._loadEachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 619, column: 18
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 14
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view.js', line: 82, column: 35
    Frame: function:'eachChild', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 616, column: 23
    Frame: function:'ContentView._eachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/content-view/content-view.js', line: 65, column: 13
    Frame: function:'Page._eachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/page/page-common.js', line: 265, column: 41
    Frame: function:'View._loadEachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 619, column: 18
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 14
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view.js', line: 82, column: 35
    Frame: function:'Page.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/page/page-common.js', line: 45, column: 35
    Frame: function:'eachChild', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 616, column: 23
    Frame: function:'Frame._eachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/frame/frame-common.js', line: 335, column: 13
    Frame: function:'View._loadEachChildView', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 619, column: 18
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view-common.js', line: 609, column: 14
    Frame: function:'View.onLoaded', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/core/view.js', line: 82, column: 35
    Frame: function:'ActivityCallbacksImplementation.onStart', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/frame/frame.js', line: 708, column: 22
    Frame: function:'NativeScriptActivity.onStart', file:'/data/data/it.bmsoftware.sosnumbers/files/app/tns_modules/ui/frame/activity.js', line: 18, column: 25
        at com.tns.Runtime.callJSMethodNative(Native Method)
        at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:865)
        at com.tns.Runtime.callJSMethodImpl(Runtime.java:730)
        at com.tns.Runtime.callJSMethod(Runtime.java:716)
        at com.tns.Runtime.callJSMethod(Runtime.java:697)
        at com.tns.Runtime.callJSMethod(Runtime.java:687)
        at com.tns.NativeScriptActivity.onStart(android.app.Activity.java)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1248)
        at android.app.Activity.performStart(Activity.java:6681)
        at android.app.Activity.performRestart(Activity.java:6755)
        at android.app.Activity.performResume(Activity.java:6760)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3377)
        ... 8 more
bradmartin commented 8 years ago

So this line: https://github.com/bradmartin/nativescript-floatingactionbutton/blob/master/fab-common.js#L43. I'll have to find some time to fix this piece, it's not a major issue to fix but I don't have time right now to fix and test.

bradmartin commented 8 years ago

Publishing 2.2.6 soon with the fix, it's here https://github.com/bradmartin/nativescript-floatingactionbutton/blob/master/fab-common.js#L43

jeremypele commented 7 years ago

@bradmartin We're using the latest version of the plugin and we've got the same issue on Android

Could it be that there is a regression somewhere?

Unable to resume activity {com.chronogolf.booking.chronogolf/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: 
Calling js method onStart failed

TypeError: Cannot read property 'getVisibility' of null
File: "<embedded>, line: 815, column: 6107

StackTrace: 
    Frame: function:'View.(anonymous function)', file:'<embedded>', line: 815, column: 6108
    Frame: function:'S', file:'<embedded>', line: 1447, column: 13221
    Frame: function:'e', file:'<embedded>', line: 1447, column: 12304
    Frame: function:'t.onResumeNativeUpdates', file:'<embedded>', line: 2239, column: 12480
    Frame: function:'t._resumeNativeUpdates', file:'<embedded>', line: 2239, column: 3637
    Frame: function:'t.onLoaded', file:'<embedded>', line: 2239, column: 3145
    Frame: function:'View.onLoaded', file:'<embedded>', line: 815, column: 1335
    Frame: function:'', file:'<embedded>', line: 2239, column: 3279
    Frame: function:'t.eachChildView', file:'<embedded>', line: 2394, column: 2546
    Frame: function:'t.eachChild'...
bradmartin commented 7 years ago

Could be, not sure. I have the FAB in multiple apps in production on app stores and haven't had this crash occur. So I'm really not sure. Do you know what file is referenced by the <embedded> tag in the exception?

jeremypele commented 7 years ago

I don't know what the <embedded> tag refers to. Fab button is included on my homepage and it looks like that:


<GridLayout column="*" rows="*">
  <GridLayout row="0" columns="*", rows="*, auto">
    <ScrollView row="0">
      [....]
    </ScrollView>
  </GridLayout>

  <FAB
    *ngIf="user?.id"
    row="0"
    [class.no-margin]="FABNoMargin"
    (tap)="goToBookingWidget()"
    icon="res://ic_add_white"
    backColor="#159c28"
    rippleColor="#e2f2e6"
    class="fab-action">
  </FAB>
</GridLayout>
bradmartin commented 7 years ago

I bet it's an angular type thing with the ngIf. If you remove that what happens?

On Mon, Aug 28, 2017, 9:48 AM Jeremy notifications@github.com wrote:

I don't know what the tag refers to. Fab button is included on my homepage and it looks like that:

[....]

<FAB *ngIf="user?.id" row="0" [class.no-margin]="FABNoMargin" (tap)="goToBookingWidget()" icon="res://ic_add_white" backColor="#159c28" rippleColor="#e2f2e6" class="fab-action">

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bradmartin/nativescript-floatingactionbutton/issues/36#issuecomment-325374901, or mute the thread https://github.com/notifications/unsubscribe-auth/AFulhP67YTk4mMr5VK28O1_unn2WCdtiks5sctMzgaJpZM4KkK6A .

jeremypele commented 7 years ago

I can't always reproduce it in local. The issue is raised in Sentry for an app I just released last week.

I'll try to dig into that way. Thanks for the feedback 👍

bradmartin commented 7 years ago

Cool, keep me posted. Just a guess that when the ngIf is determining to show or not (visibility) it's not happening at the right time. If you keep having issues, it might be worth mentioning this on the NS core repo to see if they have an idea but they'll prob need a better stacktrace with out the <embedded> tag. I wonder if that's from webpack/uglify on a release build.

As a quick test, I'd try using the NS visibility instead of ngIf and see if that helps any. If so then the core team should have an idea on a correct fix or someone more knowledgable about angular than I 😄