Skip to content

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

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
Collaborator

Choose a reason for hiding this comment

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

@kamalnathvg did you get a chance to review this comment? We're returning in the beginning itself so it covers the case you mentioned but map centre calculation is a bit different from the corners and even retrieved from the kv store in the later runs. Just wanted to ensure we're not missing any case and then I'll merge this PR :)

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