-
Notifications
You must be signed in to change notification settings - Fork 1k
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
bug: phonegap-launch-navigator plugin navigate method stopped working after migrating to capacitor 4 #6002
Comments
This issue may need more information before it can be addressed. In particular, it will need a reliable Code Reproduction that demonstrates the issue. Please see the Contributing Guide for how to create a Code Reproduction. Thanks! |
Here is the repository with the app demonstrating the problem - see https://github.com/ryaa/launch-navigator-plugin-navigate-not-working When you run the app, please tap the button on the main page. It will trigger an error at this line in the plugin https://github.com/dpa99c/phonegap-launch-navigator/blob/master/src/android/lib/LaunchNavigator.java#L344 (please also see the screenshot below) and log the error in the browser/webkit console The problem is 100% reproducible. |
Thanks for the sample app, I've been able to reproduce.
We have a feature request for allowing to configure the bridge so people can keep using the old one, that should solve this issue too for now |
I confirm that the above change fixes the problem for phonegap-launch-navigator plugin navigate method and does not break any other plugin functionalities. Questions - is there any specific reason why it was changed to make the plugin methods to be executed on the main thread? Do you think that it would be better to change to execute plugin methods on a different/not the main thread? Do you think that this change will be done in future Capacitor releases? Thank you very much for a very prompt response on the above. |
We changed the bridge to use a new bridge provided by google, it's the new bridge what executes code in the main thread while the old one did it in a background thread (because the call came from js and calls from js to native use a background thread). We will discuss internally, but options are a and b can happen in a minor or patch releases respectively, c might need to wait for a major release, but both a and b should fix this problem |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out. |
Bug Report
Capacitor Version
Platform(s)
Android
Current Behavior
Invoking phonegap-launch-navigator plugin navigate method with an address param (start param - see https://github.com/dpa99c/phonegap-launch-navigator#navigate-to-a-destination-with-specified-start-location) started to always fail after migration to Capacitor 4. The problem is that the plugin tries to geocoder the address to coordinates (see https://github.com/dpa99c/phonegap-launch-navigator/blob/master/src/android/lib/LaunchNavigator.java#L1698) by sending http request and it always fails with android.os.NetworkOnMainThreadException because the plugin method is executed on the main thread.
My assumption is that this is because in Capacitor 4 there was the change made which executes postMessage on the main thread (https://github.com/ionic-team/capacitor/pull/5427/files#diff-7d14ff84aa5a03137668f3f22aa00981610317e3afbf5dcee8bb2c41bb31591bR30). The problem does not exist with Capacitor 3 so my assumption is that this is kind of a breaking change, which might make some plugins stop working
Expected Behavior
The existing plugins must work as before after migration to Capacitor 4
Code Reproduction
I hope that the above description is self explanatory however, i can create the required github repository showing the issue.
Additional Context
N/A
The text was updated successfully, but these errors were encountered: