NativeScript / nativescript-facebook

NativeScript plugin, wrapper of native Facebook SDK for Android and iOS
Apache License 2.0
79 stars 50 forks source link

Crash after login #177

Closed Stanteq closed 5 years ago

Stanteq commented 5 years ago

Hi

CLI: 5.2.3 Runtime(s): tns-android 5.2.1 Plugin(s): nativescript-facebook 2.5.0

After login it crash with the error:

An uncaught Exception occurred on "main" thread.
com.tns.NativeScriptException: 
Calling js method run failed

Error: java.lang.IllegalArgumentException: View=DecorView@8fa39f7[] not attached to window manager
    android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:497)
    android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:406)
    android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:125)
    android.app.Dialog.dismissDialog(Dialog.java:443)
    android.app.Dialog.dismiss(Dialog.java:426)
    com.tns.Runtime.callJSMethodNative(Native Method)
    com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1203)
    com.tns.Runtime.callJSMethodImpl(Runtime.java:1083)
    com.tns.Runtime.callJSMethod(Runtime.java:1070)
    com.tns.Runtime.callJSMethod(Runtime.java:1050)
    com.tns.Runtime.callJSMethod(Runtime.java:1042)
    com.tns.gen.java.lang.Runnable.run(Runnable.java:15)
    android.os.Handler.handleCallback(Handler.java:789)
    android.os.Handler.dispatchMessage(Handler.java:98)
    android.os.Looper.loop(Looper.java:164)
    android.app.ActivityThread.main(ActivityThread.java:6710)
    java.lang.reflect.Method.invoke(Native Method)
    com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
File: "file:///data/data/com.mobelup.app/files/app/vendor.js, line: 103558, column: 24

StackTrace: 
    Frame: function:'push.../node_modules/nativescript-loading-indicator/src/android/progress-dialog.js.LoadingIndicator.hide', file:'file:///data/data/com.mobelup.app/files/app/vendor.js', line: 109383, column: 34
    Frame: function:'', file:'file:///data/data/com.mobelup.app/files/app/bundle.js', line: 3434, column: 26
    Frame: function:'push.../node_modules/nativescript-angular/zone-js/dist/zone-nativescript.js.ZoneDelegate.invokeTask', file:'file:///data/data/com.mobelup.app/files/app/vendor.js', line: 103824, column: 31
    Frame: function:'push.../node_modules/nativescript-angular/zone-js/dist/zone-nativescript.js.Zone.runTask', file:'file:///data/data/com.mobelup.app/files/app/vendor.js', line: 103591, column: 47
    Frame: function:'push.../node_modules/nativescript-angular/zone-js/dist/zone-nativescript.js.ZoneTask.invokeTask', file:'file:///data/data/com.mobelup.app/files/app/vendor.js', line: 103899, column: 34
    Frame: function:'ZoneTask.invoke', file:'file:///data/data/com.mobelup.app/files/app/vendor.js', line: 103888, column: 48
    Frame: function:'timer', file:'file:///data/data/com.mobelup.app/files/app/vendor.js', line: 104964, column: 29
    Frame: function:'invoke', file:'file:///data/data/com.mobelup.app/files/app/vendor.js', line: 143593, column: 48
    Frame: function:'push.../node_modules/nativescript-angular/zone-js/dist/zone-nativescript.js.ZoneDelegate.invoke', file:'file:///data/data/com.mobelup.app/files/app/vendor.js', line: 103791, column: 26
    Frame: function:'push.../node_modules/nativescript-angular/zone-js/dist/zone-nativescript.js.Zone.runGuarded', file:'file:///data/data/com.mobelup.app/files/app/vendor.js', line: 103554, column: 47
    Frame: function:'', file:'file:///data/data/com.mobelup.app/files/app/vendor.js', line: 103532, column: 29
    Frame: function:'run', file:'file:///data/data/com.mobelup.app/files/app/vendor.js', line: 143597, column: 13

    at com.tns.Runtime.callJSMethodNative(Native Method)
    at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1203)
    at com.tns.Runtime.callJSMethodImpl(Runtime.java:1083)
    at com.tns.Runtime.callJSMethod(Runtime.java:1070)
    at com.tns.Runtime.callJSMethod(Runtime.java:1050)
    at com.tns.Runtime.callJSMethod(Runtime.java:1042)
    at com.tns.gen.java.lang.Runnable.run(Runnable.java:15)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6710)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
Caused by: java.lang.IllegalArgumentException: View=DecorView@8fa39f7[] not attached to window manager
    at android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:497)
    at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:406)
    at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:125)
    at android.app.Dialog.dismissDialog(Dialog.java:443)
    at android.app.Dialog.dismiss(Dialog.java:426)
    ... 14 more
DimitarTodorov commented 5 years ago

Hi, @csi-stasik I've tested all our demos in the repo and they works fine. Can you share exact steps to reproduce the issue, the login type you are using and if it is possible a sample project where we can reproduce the issue you are describing.

Stanteq commented 5 years ago

Hi @DimitarTodorov, Thx.

Sorry is my fault. Immediately after facebook login I show LoadingIndicator for another request and this combination crashes. Strange with the previous version of nativescript-facebook I did not have this issue (the code was the same).

Facebook.login((error: any, fbData: any) => {
      if (error) {
        console.log(error);
      } else {
        setTimeout(() => {   // <-- this fixed my issue.
           // Other stuff
       });
      }
})
DimitarTodorov commented 5 years ago

Hi @csi-stasik, Nice to hear that you have resolved the issue you observe. I've tested our angular app and placed code in the login success part of the method and it seems to work without a hitch. Can you share sample example where we can reproduce the issue or if it is already solved with the mentioned solution we can proceed to close this issue.