Repository navigation
fix(android): ignore permission results without a saved call - #121
Open
Mobiletainment wants to merge 1 commit into
Open
Mobiletainment wants to merge 1 commit into
Mobiletainment wants to merge 1 commit into
Conversation
Capacitor's Plugin#triggerPermissionCallback passes the call it saved before the permission request. That call only lives in memory and can be null, for example if Android recreated the app process while the location permission dialog was open. The callbacks passed null on to getPosition/startWatch, which matches the NullPointerException on PluginCall.getCallbackId() reported in ionic-team#87. Accept a nullable call in both permission callbacks and return early. Closes ionic-team#87 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
completeCurrentPositionandcompleteWatchPositionnow accept a nullablePluginCalland return early when it is null.Context
Closes #87.
Capacitor calls
@PermissionCallbackmethods fromPlugin#triggerPermissionCallbackwithbridge.getPermissionCall(...), which can returnnulland is passed on without a check. The saved call only lives in memory, so one way to lose it is Android recreating the app process while the location permission dialog is open. The reports in #87 come from Crashlytics, so the exact trigger is not confirmed. Either way, the plugin passed thenullon tostartWatch/getPosition, which matches the reported crash:There is no call left to resolve or reject, so returning is the only option. The JavaScript side that made the request is already gone at that point.
I have carried an equivalent guard in a local patch for my Android apps since May 2026.
Type of changes
Platforms affected
Tests
PermissionCallbackTest, a JVM unit test that checks that both methods carry@PermissionCallbackand invokes them by reflection with anullcall, the way Capacitor does. Without the fix both tests fail with aNullPointerException. With the fix they pass.cd android && ./gradlew clean build testpasses (JDK 21).npm run build,npm run eslintandnpm run prettier -- --checkpass.next(9.0.0-next.5), where the callbacks are unchanged.🤖 Generated with Claude Code