Android-runtime: Crash when invoking a second (different) signature of an overloaded method (meta generator cache?)

Created on 10 Sep 2016  路  5Comments  路  Source: NativeScript/android-runtime

Tell us about the problem

I'm trying to extend the Firebase plugin with the ability to remove listeners. On Android the Firebase SDK offers the following method signatures (found here):

screen shot 2016-09-10 at 20 49 36

So these methods either expect an implementation of the ChildEventListener or ValueEventListener Interface.

Whichever is called first succeeds!, so when first calling removeEventListener(myValueEventListener) all is fine, but if I then call removeEventListener(myChildEventListener) the app will crash (and vice versa!) with the following stacktrace:

JNI ERROR (app bug): attempt to pass an instance of com.tns.gen.com.google.firebase.database.ChildEventListener as argument 1 to void com.google.firebase.database.Query.removeEventListener(com.google.firebase.database.ValueEventListener)

My guess is something is cached and the runtime expects the same signature for the same method the next time.. which is not what the Firebase SDK wants me to pass in..

Please provide the following version numbers that your issue occurs with:

  • CLI: 2.2.1
  • Runtime(s): 2.1.1 as well as 2.4.0-next-2016-09-10-1135 (exactly the same behaviour)
  • Firebase Android SDK: 9.4.0

    Please tell us how to recreate the issue in as much detail as possible.

  • Clone the Firebase plugin demo repo.

  • Important: Instead of using the plugin from npm (as the demo app does), grab it from https://github.com/EddyVerbruggen/nativescript-plugin-firebase, just use the master branch, that's where I've added the code that will reproduce the crash (the 'remove listener' feature is new and undocumented so it won't bother others).
  • Follow the instructions on how to configure Firebase from the demo app's readme.
  • Open the app, go to the second tab, click 'init' at the top.
  • Now hit the yellow 'add child listener' button (see below), then 'remove childlistener' (should be OK)
  • Then hit the red 'add valuelistener' button, then 'remove valuelistener' (crash!)

Those last two steps can be reversed with the same outcome.

screen shot 2016-09-10 at 21 28 07

done bug

All 5 comments

Hi @EddyVerbruggen, I coulnd't reproduce your problem.
After building following your instructions I did:

  • Hit the button: "INIT FIREBASE - DO THIS FIRST"
  • Hit the button: "ADD CHILDLISTENER"
  • Hit the big button: "REMOVE CHILD LISTENER"
  • Hit the big button: "ADD VALUE LISTENER"
  • Hit the button "REMOVE VALUELISTENER"
Calling js method onClick failed
TypeError: firebase.removeEventListener is not a function
File: "/data/data/org.nativescript.firebasedemo/files/app/main-view-model.js, line: 448, column: 13

which looks like an application error.

Ah snap, that's because I removed that method and didn't yet adjust the demo app. Please pull the demo app again and do exactly the same to see the crash (hope you still have it on your machine!).

screen shot 2016-09-12 at 15 31 36

@EddyVerbruggen, thank you for the feedback, I managed to reproduce your problem and we'll take a look.

EDIT: @EddyVerbruggen, thanks for reporting this issue, the fix will make it into the next release.

That's fantastic! Thanks for checking and fixings this so incredibly quickly! 馃帀

2.3.0 FTW!

JS: firebase.addChildEventListener added
JS: firebase.addValueEventListener added
JS: Removing listener at path /users: com.tns.gen.com.google.firebase.database.ChildEventListener@52be7010
JS: firebase.doRemoveChildEventListenerForUsers success
JS: Removing listener at path /companies: com.tns.gen.com.google.firebase.database.ValueEventListener@52b5d2c0
JS: firebase.doRemoveValueEventListenersForCompanies success

馃帀馃帀馃帀馃帀馃帀馃帀馃帀馃帀馃帀馃帀馃帀馃帀馃帀

Was this page helpful?
0 / 5 - 0 ratings