Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when invoking a second (different) signature of an overloaded method (meta generator cache?) #555

Closed
EddyVerbruggen opened this issue Sep 10, 2016 · 5 comments
Assignees
Milestone

Comments

@EddyVerbruggen
Copy link
Contributor

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

@Plamen5kov
Copy link
Contributor

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.

@EddyVerbruggen
Copy link
Contributor Author

EddyVerbruggen commented Sep 12, 2016

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

@Plamen5kov
Copy link
Contributor

Plamen5kov commented Sep 12, 2016

@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.

@EddyVerbruggen
Copy link
Contributor Author

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

@EddyVerbruggen
Copy link
Contributor Author

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

🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉

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

No branches or pull requests

3 participants