Skip to content

Resolves NPE when opening app without location permission and mobile data #6345

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kamalnathvg
Copy link

@kamalnathvg kamalnathvg commented Jun 9, 2025

Fixes NPE when opening app without location permission and mobile data

Fixes #6330

Added Null Check for NearbyParentFragment.mapFocus to handle the case when Permission dialog is active above NearbyParentFragment leading to null values for nearbyParentFragment.mapFocus, nearbyParentFragment.screenBottomLeft and nearbyParentFragment.screenTopRight.

Reproduce Issue by:

  1. Clear App Cache.
  2. Change location permission to ask every time.
  3. Disable mobile data.
  4. Open the app.

Before Fix

6330-before.mp4

After Fix

6330-after.mp4

Tested on:
Device : Pixel 8
API Level: 35

@@ -569,7 +569,7 @@ class NearbyParentFragmentPresenter
loadPlacesDataAyncJob?.cancel()
localPlaceSearchJob = scope.launch(Dispatchers.IO) {
delay(LOCAL_SCROLL_DELAY)
val mapFocus = nearbyParentFragmentView.mapFocus
val mapFocus = nearbyParentFragmentView.mapFocus ?: return@launch
Copy link
Collaborator

Choose a reason for hiding this comment

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

to handle the case when Permission dialog is active above NearbyParentFragment leading to null values for nearbyParentFragment.mapFocus, nearbyParentFragment.screenBottomLeft and nearbyParentFragment.screenTopRight

Haven't tested yet but the NPE is happening at fetchPlaces() if I understand the logs correctly. Just thinking: can we still have cases where the other two could be null and we end up passing them to this function? Should we handle all of them since these are completely independent values and not calculated using any one of them?

Copy link

github-actions bot commented Jul 7, 2025

✅ Generated APK variants!

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

Successfully merging this pull request may close these issues.

Attempt to invoke virtual method 'double fr.free.nrw.commons.location.LatLng.getLatitude()'
3 participants