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

fix(android): Release the call after reject/resolve #4318

Merged
merged 2 commits into from
Mar 17, 2021

Conversation

jcesarmobile
Copy link
Member

Capacitor calls are being saved when an intent is being launched and then released after the intent returns a result, but before the plugin returns the result, and in cases where there are multiple intents launched by the same plugin call it ends up creating null pointer exceptions in some cases where the call was released sooner than expected and needed later.

This PR removes the early releases of the calls and put it where the call actually rejects or resolves to the JS side.

closes #4307

@carlpoole
Copy link
Member

Will this not regress this fix if the call is saved again before it is resolved? #4281

@jcesarmobile
Copy link
Member Author

I tried and doesn't look like it, if the call is saved again, since it's the same call, with same id, and savedCalls is a Map, it should just save the same call on the Map with no side effects as Maps don't allow duplicate keys.

@carlpoole
Copy link
Member

I understand this now. I do like this a lot better. So basically the life of the call lasts until it is resolved/rejected (aka finished) and if you want the call to last past that, use the keepAlive setting. And it works because the call isn't resolved until the native work has been completed - which can last through multiple intents.

Copy link
Member

@carlpoole carlpoole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and seems to work great

@jcesarmobile jcesarmobile merged commit a9f30a8 into main Mar 17, 2021
@jcesarmobile jcesarmobile deleted the fix-release-call branch March 17, 2021 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants