Skip to content

Shows "Location not available" despite GPS being on in Nearby tab #3924

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

Closed
heinrich5991 opened this issue Sep 11, 2020 · 28 comments
Closed

Shows "Location not available" despite GPS being on in Nearby tab #3924

heinrich5991 opened this issue Sep 11, 2020 · 28 comments
Labels

Comments

@heinrich5991
Copy link

heinrich5991 commented Sep 11, 2020

Summary:

The app shows "Location not available" in the Nearby tab, even though location is enabled for the app and the precise location is also available (another app can display the exact position).

Steps to reproduce:

  1. Make sure that you have accurate location enabled and available, e.g. by starting a navigation on osmand.
  2. Clear data of the app, start it.
  3. Go through introduction screens.
  4. Log in.
  5. Click on "Nearby".
  6. "Allow Commons to access this device's location?" → Allow
  7. See the toast "Nearby might not work properly, Location not available"

Device and Android version:

Nexus 5X, Android 8.1.0, LineageOS 15.1, without Google Play Services and MicroG.

Commons app version:

2.13.1~917a94472 via F-Droid.

Would you like to work on the issue?

No.

@nicolas-raoul
Copy link
Member

I noticed that too. It happens only the first time you open Nearby, right?

@ashishkumar468
Copy link
Collaborator

Actually yes, this happens when the last known location is null. Enabling location does not always mean that we have the location. So in that case, when we do receive the location, which happens almost instantly if the permission is enabled, we use the location to show nearby pins.

@heinrich5991
Copy link
Author

I noticed that too. It happens only the first time you open Nearby, right?

No, this happens every time. This is not a new phenomenon, it also happened when I tried using the app 1-2 years ago.

Enabling location does not always mean that we have the location. So in that case, when we do receive the location,

In my test, another app (osmand) was constantly showing the correct location.

@ashishkumar468
Copy link
Collaborator

Hey @heinrich5991 , so even after allowing location permission, nearby does not work for you?

@heinrich5991
Copy link
Author

Yes, this is correct.

@ashishkumar468
Copy link
Collaborator

@nicolas-raoul Do you face the same issue?.
@heinrich5991 Would it be possible for you to share the app logs?

@heinrich5991
Copy link
Author

Had to figure out how to filter it to just that app. From the point when I click on "Nearby" (I do it twice in the log). Looks interesting, an exception is thrown.

09-11 05:26:21.039 18284 18284 D NearbyParentFragment: Checking permission and perfoming action
09-11 05:26:21.055 18284 18284 D MainActivity: Nearby tab selected
09-11 05:26:21.066 18284 18284 D MainActivity: Nearby fragment list sheet menu item is visible
09-11 05:26:21.072 18284 18284 V Mbgl-ConnectivityReceiver: connected - true
09-11 05:26:21.075 18284 18284 D NearbyParentFragment: Location service manager unregistered and removed
09-11 05:26:23.970 18284 18284 D NearbyParentFragmentPresenter: Presenter updates map and list
09-11 05:26:23.971 18284 18284 D NearbyParentFragmentPresenter: Network connection is not established
09-11 05:26:23.976 18284 18284 E LocationServiceManager: Illegal argument exception
09-11 05:26:23.976 18284 18284 E LocationServiceManager: java.lang.IllegalArgumentException: provider doesn't exist: network
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at android.os.Parcel.readException(Parcel.java:2017)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at android.os.Parcel.readException(Parcel.java:1959)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:691)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at android.location.LocationManager.requestLocationUpdates(LocationManager.java:888)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at android.location.LocationManager.requestLocationUpdates(LocationManager.java:470)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.location.LocationServiceManager.requestLocationUpdatesFromProvider(LocationServiceManager.java:63)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.location.LocationServiceManager.registerLocationManager(LocationServiceManager.java:50)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.nearby.fragments.NearbyParentFragment.registerUnregisterLocationListener(NearbyParentFragment.java:1472)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.nearby.fragments.NearbyParentFragment.lambda$performMapReadyActions$4$NearbyParentFragment(NearbyParentFragment.java:313)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.nearby.fragments.-$$Lambda$NearbyParentFragment$Xc-p4-xzz9CvPARPhVSElkWXrmo.run(Unknown Source:2)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.utils.PermissionUtils$1.onPermissionGranted(PermissionUtils.java:114)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.MultiplePermissionsListenerToPermissionListenerAdapter.onPermissionsChecked(Unknown Source:35)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.MultiplePermissionListenerThreadDecorator$1.run(Unknown Source:8)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.MainThread.execute(Unknown Source:6)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.MultiplePermissionListenerThreadDecorator.onPermissionsChecked(Unknown Source:7)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.DexterInstance.onPermissionsChecked(Unknown Source:57)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.DexterInstance.updatePermissionsAsGranted(Unknown Source:26)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.DexterInstance.onPermissionRequestGranted(Unknown Source:0)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.Dexter.onPermissionsRequested(Unknown Source:4)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.DexterActivity.onRequestPermissionsResult(Unknown Source:51)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7429)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at android.app.Activity.dispatchActivityResult(Activity.java:7280)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at android.app.ActivityThread.deliverResults(ActivityThread.java:4264)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at android.app.ActivityThread.handleSendResult(ActivityThread.java:4312)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at android.app.ActivityThread.-wrap19(Unknown Source:0)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1644)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at android.os.Handler.dispatchMessage(Handler.java:106)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at android.os.Looper.loop(Looper.java:164)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at android.app.ActivityThread.main(ActivityThread.java:6494)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at java.lang.reflect.Method.invoke(Native Method)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
09-11 05:26:23.976 18284 18284 E LocationServiceManager: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
09-11 05:26:23.977 18284 18284 D NearbyParentFragment: Location service manager added and registered
09-11 05:26:24.021 18284 18514 D OkHttp  : --> GET https://commons.wikimedia.org/w/api.php?format=json&formatversion=2&errorformat=plaintext&action=query&meta=notifications&notformat=model&notlimit=max&notwikis=wikidatawiki%7Ccommonswiki%7Cenwiki&notfilter=%21read
09-11 05:26:24.023 18284 18514 D CookieManager: Domain:commons.wikimedia.org
09-11 05:26:24.023 18284 18284 E LocationServiceManager: Illegal argument exception
09-11 05:26:24.023 18284 18284 E LocationServiceManager: java.lang.IllegalArgumentException: provider doesn't exist: network
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at android.os.Parcel.readException(Parcel.java:2017)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at android.os.Parcel.readException(Parcel.java:1959)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:691)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at android.location.LocationManager.requestLocationUpdates(LocationManager.java:888)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at android.location.LocationManager.requestLocationUpdates(LocationManager.java:470)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.location.LocationServiceManager.requestLocationUpdatesFromProvider(LocationServiceManager.java:63)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.location.LocationServiceManager.registerLocationManager(LocationServiceManager.java:50)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.contributions.ContributionsFragment.onLocationPermissionGranted(ContributionsFragment.java:449)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.contributions.ContributionsFragment.checkPermissionsAndShowNearbyCardView(ContributionsFragment.java:429)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.contributions.ContributionsFragment.onResume(ContributionsFragment.java:410)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at androidx.fragment.app.Fragment.performResume(Fragment.java:2649)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:922)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at androidx.fragment.app.FragmentManagerImpl.dispatchResume(FragmentManagerImpl.java:2625)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at androidx.fragment.app.FragmentController.dispatchResume(FragmentController.java:268)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at androidx.fragment.app.FragmentActivity.onResumeFragments(FragmentActivity.java:479)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at androidx.fragment.app.FragmentActivity.onPostResume(FragmentActivity.java:468)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at androidx.appcompat.app.AppCompatActivity.onPostResume(AppCompatActivity.java:195)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at android.app.Activity.performResume(Activity.java:7141)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3556)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3621)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1638)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at android.os.Handler.dispatchMessage(Handler.java:106)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at android.os.Looper.loop(Looper.java:164)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at android.app.ActivityThread.main(ActivityThread.java:6494)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at java.lang.reflect.Method.invoke(Native Method)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
09-11 05:26:24.023 18284 18284 E LocationServiceManager: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
09-11 05:26:24.025 18284 18284 D ContributionsPresenter: fetch  Contributions
09-11 05:26:24.034 18284 18284 D ContributionsPresenter: last fetch timestamp: 1599794775439
09-11 05:26:24.035 18284 18284 E ContributionsFragment: onFragmentResumed fr.free.nrw.commons.contributions.ContributionsListFragment
09-11 05:26:24.039 18284 18284 D NearbyParentFragment: Checking permission and perfoming action
09-11 05:26:24.054 18284 18284 D NearbyParentFragmentPresenter: Presenter updates map and list
09-11 05:26:24.056 18284 18284 D NearbyParentFragmentPresenter: Skipping update of nearby places as location is unavailable
09-11 05:26:24.058 18284 18284 E LocationServiceManager: Illegal argument exception
09-11 05:26:24.058 18284 18284 E LocationServiceManager: java.lang.IllegalArgumentException: provider doesn't exist: network
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at android.os.Parcel.readException(Parcel.java:2017)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at android.os.Parcel.readException(Parcel.java:1959)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:691)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at android.location.LocationManager.requestLocationUpdates(LocationManager.java:888)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at android.location.LocationManager.requestLocationUpdates(LocationManager.java:470)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.location.LocationServiceManager.requestLocationUpdatesFromProvider(LocationServiceManager.java:63)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.location.LocationServiceManager.registerLocationManager(LocationServiceManager.java:50)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.nearby.fragments.NearbyParentFragment.registerUnregisterLocationListener(NearbyParentFragment.java:1472)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.nearby.fragments.NearbyParentFragment.lambda$performMapReadyActions$4$NearbyParentFragment(NearbyParentFragment.java:313)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.nearby.fragments.-$$Lambda$NearbyParentFragment$Xc-p4-xzz9CvPARPhVSElkWXrmo.run(Unknown Source:2)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.utils.PermissionUtils$1.onPermissionGranted(PermissionUtils.java:114)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.MultiplePermissionsListenerToPermissionListenerAdapter.onPermissionsChecked(Unknown Source:35)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.DexterInstance$1.run(Unknown Source:43)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.MainThread.execute(Unknown Source:6)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.DexterInstance.checkMultiplePermissions(Unknown Source:56)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.DexterInstance.checkPermissions(Unknown Source:0)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.Dexter.check(Unknown Source:10)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.utils.PermissionUtils.checkPermissionsAndPerformAction(PermissionUtils.java:144)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.nearby.fragments.NearbyParentFragment.checkPermissionsAndPerformAction(NearbyParentFragment.java:853)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.nearby.fragments.NearbyParentFragment.performMapReadyActions(NearbyParentFragment.java:297)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.nearby.fragments.NearbyParentFragment.startTheMap(NearbyParentFragment.java:1500)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.nearby.fragments.NearbyParentFragment.onResume(NearbyParentFragment.java:326)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at androidx.fragment.app.Fragment.performResume(Fragment.java:2649)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:922)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at androidx.fragment.app.FragmentManagerImpl.dispatchResume(FragmentManagerImpl.java:2625)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at androidx.fragment.app.FragmentController.dispatchResume(FragmentController.java:268)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at androidx.fragment.app.FragmentActivity.onResumeFragments(FragmentActivity.java:479)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at androidx.fragment.app.FragmentActivity.onPostResume(FragmentActivity.java:468)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at androidx.appcompat.app.AppCompatActivity.onPostResume(AppCompatActivity.java:195)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at android.app.Activity.performResume(Activity.java:7141)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3556)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3621)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1638)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at android.os.Handler.dispatchMessage(Handler.java:106)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at android.os.Looper.loop(Looper.java:164)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at android.app.ActivityThread.main(ActivityThread.java:6494)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at java.lang.reflect.Method.invoke(Native Method)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
09-11 05:26:24.058 18284 18284 E LocationServiceManager: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
09-11 05:26:24.059 18284 18284 D NearbyParentFragment: Location service manager added and registered
09-11 05:26:24.066 18284 18294 I zygote64: Do full code cache collection, code=244KB, data=164KB
09-11 05:26:24.067 18284 18294 I zygote64: After code cache collection, code=195KB, data=111KB
09-11 05:26:24.579 18284 18514 D OkHttp  : <-- 200 https://commons.wikimedia.org/w/api.php?format=json&formatversion=2&errorformat=plaintext&action=query&meta=notifications&notformat=model&notlimit=max&notwikis=wikidatawiki%7Ccommonswiki%7Cenwiki&notfilter=%21read (557ms, unknown-length body)
09-11 05:26:24.585 18284 18284 D MainActivity: Number of notifications is 0
09-11 05:26:29.066 18284 18284 D MainActivity: Contributions tab selected
09-11 05:26:29.081 18284 18284 D MainActivity: Contributions fragment notifications menu item is visible
09-11 05:26:29.986 18284 18284 D NearbyParentFragment: Checking permission and perfoming action
09-11 05:26:29.994 18284 18284 D NearbyParentFragmentPresenter: Presenter updates map and list
09-11 05:26:29.996 18284 18284 D NearbyParentFragmentPresenter: Skipping update of nearby places as location is unavailable
09-11 05:26:30.000 18284 18284 E LocationServiceManager: Illegal argument exception
09-11 05:26:30.000 18284 18284 E LocationServiceManager: java.lang.IllegalArgumentException: provider doesn't exist: network
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at android.os.Parcel.readException(Parcel.java:2017)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at android.os.Parcel.readException(Parcel.java:1959)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:691)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at android.location.LocationManager.requestLocationUpdates(LocationManager.java:888)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at android.location.LocationManager.requestLocationUpdates(LocationManager.java:470)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.location.LocationServiceManager.requestLocationUpdatesFromProvider(LocationServiceManager.java:63)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.location.LocationServiceManager.registerLocationManager(LocationServiceManager.java:50)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.nearby.fragments.NearbyParentFragment.registerUnregisterLocationListener(NearbyParentFragment.java:1472)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.nearby.fragments.NearbyParentFragment.lambda$performMapReadyActions$4$NearbyParentFragment(NearbyParentFragment.java:313)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.nearby.fragments.-$$Lambda$NearbyParentFragment$Xc-p4-xzz9CvPARPhVSElkWXrmo.run(Unknown Source:2)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.utils.PermissionUtils$1.onPermissionGranted(PermissionUtils.java:114)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.MultiplePermissionsListenerToPermissionListenerAdapter.onPermissionsChecked(Unknown Source:35)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.DexterInstance$1.run(Unknown Source:43)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.MainThread.execute(Unknown Source:6)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.DexterInstance.checkMultiplePermissions(Unknown Source:56)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.DexterInstance.checkPermissions(Unknown Source:0)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at com.karumi.dexter.Dexter.check(Unknown Source:10)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.utils.PermissionUtils.checkPermissionsAndPerformAction(PermissionUtils.java:144)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.nearby.fragments.NearbyParentFragment.checkPermissionsAndPerformAction(NearbyParentFragment.java:853)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.nearby.fragments.NearbyParentFragment.performMapReadyActions(NearbyParentFragment.java:297)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.nearby.fragments.NearbyParentFragment.startTheMap(NearbyParentFragment.java:1500)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.nearby.fragments.NearbyParentFragment.setUserVisibleHint(NearbyParentFragment.java:1486)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at androidx.fragment.app.FragmentPagerAdapter.setPrimaryItem(FragmentPagerAdapter.java:225)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1234)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at androidx.viewpager.widget.ViewPager.setCurrentItemInternal(ViewPager.java:669)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at androidx.viewpager.widget.ViewPager.setCurrentItemInternal(ViewPager.java:631)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at androidx.viewpager.widget.ViewPager.setCurrentItem(ViewPager.java:612)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at fr.free.nrw.commons.contributions.MainActivity$2.onTabSelected(MainActivity.java:205)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at com.google.android.material.tabs.TabLayout.dispatchTabSelected(TabLayout.java:1756)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at com.google.android.material.tabs.TabLayout.selectTab(TabLayout.java:1749)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at com.google.android.material.tabs.TabLayout.selectTab(TabLayout.java:1709)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at com.google.android.material.tabs.TabLayout$Tab.select(TabLayout.java:2054)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at com.google.android.material.tabs.TabLayout$TabView.performClick(TabLayout.java:2239)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at android.view.View$PerformClick.run(View.java:24770)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at android.os.Handler.handleCallback(Handler.java:790)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at android.os.Handler.dispatchMessage(Handler.java:99)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at android.os.Looper.loop(Looper.java:164)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at android.app.ActivityThread.main(ActivityThread.java:6494)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at java.lang.reflect.Method.invoke(Native Method)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
09-11 05:26:30.000 18284 18284 E LocationServiceManager: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
09-11 05:26:30.000 18284 18284 D NearbyParentFragment: Location service manager added and registered
09-11 05:26:30.001 18284 18284 D MainActivity: Nearby tab selected
09-11 05:26:30.007 18284 18284 D MainActivity: Nearby fragment list sheet menu item is visible

@heinrich5991
Copy link
Author

Oh, might also be interesting (don't know if this makes a WONTFIX): The device doesn't have Play Services or MicroG installed.

@heinrich5991
Copy link
Author

Exception seems to be expected by the code

private boolean requestLocationUpdatesFromProvider(String locationProvider) {
try {
locationManager.requestLocationUpdates(locationProvider,
MIN_LOCATION_UPDATE_REQUEST_TIME_IN_MILLIS,
MIN_LOCATION_UPDATE_REQUEST_DISTANCE_IN_METERS,
this);
return true;
} catch (IllegalArgumentException e) {
Timber.e(e, "Illegal argument exception");
return false;
} catch (SecurityException e) {
Timber.e(e, "Security exception");
return false;
}
}

called at

public void registerLocationManager() {
if (!isLocationManagerRegistered) {
isLocationManagerRegistered = requestLocationUpdatesFromProvider(LocationManager.NETWORK_PROVIDER)
&& requestLocationUpdatesFromProvider(LocationManager.GPS_PROVIDER);
}
}

@heinrich5991
Copy link
Author

But it seems that the GPS provider isn't called when the network provider fails due to the short-circuiting of &&. Is that the bug?

@nicolas-raoul
Copy link
Member

@ashishkumar468 not same as it only happens the first time for me, sorry for the noise! 😅

@heinrich5991
Copy link
Author

public void registerLocationManager() {
if (!isLocationManagerRegistered) {
isLocationManagerRegistered = requestLocationUpdatesFromProvider(LocationManager.NETWORK_PROVIDER)
&& requestLocationUpdatesFromProvider(LocationManager.GPS_PROVIDER);
}
}

I think the fix might be as simple as changing this && to a & so that both operands are always executed.

@4D17Y4
Copy link
Contributor

4D17Y4 commented Dec 12, 2020

Can I work on this one ?

The mentioned issue happens for the first time you login.

As written in the steps to reproduce this bug @heinrich5991

  1. Clear data of the app, start it.

This clears all the data from the app also the last location from the app, so when you login again the app tries to fetch the last location which is not available .

Thus the call to last location of the app returns null causing the app to show the message.

According to me,
The solution to this is Adding a if statement before toasting to check weather the location Providers are enabled
if at least one of them is enabled then we can show a toast to notify user that the location is being updated .
otherwise show the aforementioned toast.

Correct me if I missed something. @ashishkumar0207 @nicolas-raoul
Thanks.

@heinrich5991
Copy link
Author

According to me,
The solution to this is Adding a if statement before toasting to check weather the location Providers are enabled

The problem is not that the error message is shown. The problem is that the location is never determined. Removing the error message would not fix my issue.

@4D17Y4
Copy link
Contributor

4D17Y4 commented Dec 22, 2020

The problem is that the location is never determined. Removing the error message would not fix my issue.

I totally agree with it, but the problem is that it can't be determined either, as this is the first time the fragment is being loaded.

Refining the test conditions would be my shot on it.

Really want to fix this, would be really nice if I get some input on other possible ways to handle this situation. @ashishkumar468 @nicolas-raoul

Thx.

@ashishkumar468
Copy link
Collaborator

ashishkumar468 commented Jan 19, 2021

@4D17Y4

public void registerLocationManager() {
if (!isLocationManagerRegistered) {
isLocationManagerRegistered = requestLocationUpdatesFromProvider(LocationManager.NETWORK_PROVIDER)
&& requestLocationUpdatesFromProvider(LocationManager.GPS_PROVIDER);
}
}

Fixing this is really worth trying, the '&&' should be replaced by '||' IMO

@misaochan
Copy link
Member

Hi @4D17Y4 , please see Ashish's comment. :) Feel free to submit a PR for this and we will review.

@4D17Y4
Copy link
Contributor

4D17Y4 commented Jan 21, 2021

I'm on it @misaochan,
@ashishkumar0207 solution although intriguing does not help.
I'm making progress and will send a PR soon.

@ashishkumar468
Copy link
Collaborator

I am not sure about the other issue, or if this would solve the issue for this , but

@4D17Y4

public void registerLocationManager() {
if (!isLocationManagerRegistered) {
isLocationManagerRegistered = requestLocationUpdatesFromProvider(LocationManager.NETWORK_PROVIDER)
&& requestLocationUpdatesFromProvider(LocationManager.GPS_PROVIDER);
}
}

Fixing this is really worth trying, the '&&' should be replaced by '||' IMO

I am not sure about the other issue, or if this would solve the issue completely(since the device does not have play-services), but the short-circuiting is clearly a bug, I will be raising a PR for that, soon, once that goes to beta (and if we are not able to solve this by then), rolling this out will help for sure and we would at least know that if the network provider does not work in @heinrich5991 ' s device, are the GPS providers working as expected

@4D17Y4
Copy link
Contributor

4D17Y4 commented Jan 21, 2021

I am not sure about the other issue, or if this would solve the issue completely(since the device does not have play-services), but the short-circuiting is clearly a bug, I will be raising a PR for that, soon, once that goes to beta (and if we are not able to solve this by then), rolling this out will help for sure and we would at least know that if the network provider does not work in @heinrich5991 ' s device, are the GPS providers working as expected

I've tried replacing && with || but as the network provider returns true, the second GPS providers are never asked for updates and we can't see the location icon on the status bar ( which typically shows that location is being accessed ).

I do agree with the issue that GPS one won't be called if the Network turns out to be false.

For that, I can change && to | this way GPS providers would be called and as I have tested it on your last suggestion, I can add a commit to the PR addressing this change.

Thanks.

@ashishkumar468
Copy link
Collaborator

Thanks @4D17Y4 , have you been able to reproduce this issue in your device, if yes will it be possible to share the steps to reproduce this?

@4D17Y4
Copy link
Contributor

4D17Y4 commented Jan 21, 2021

Sure @ashishkumar0207,
Try this

  1. Remove the app from the background and fresh start it.
  2. Switch to the nearby tab.
  3. You'll see the mentioned toast "Location not available"
  4. Wait for some time, you'll see the location getting updated and the map showing your current location.

@ashishkumar468
Copy link
Collaborator

@4D17Y4 Thanks for sharing the steps, although this issue seems different, @heinrich5991 's issue is that Nearby never updates the location in his device.

@4D17Y4
Copy link
Contributor

4D17Y4 commented Jan 22, 2021

Apparently, I overlooked the discussion that followed the issue.
Thanks, @ashishkumar0207.

@4D17Y4
Copy link
Contributor

4D17Y4 commented Jan 22, 2021

Should I open a new issue for fixing the mentioned bug, as I have the PR ready and linked here? and I think the issue would be quite similar to this one.
@misaochan @neslihanturan

@misaochan
Copy link
Member

misaochan commented Feb 2, 2021

@4D17Y4 sorry for the slow response. Yes, I think it's OK to submit a new PR. Generally we try to have a one-new-PR-at-a-time rule, however this is higher priority than #4186 so perhaps it is better to submit this one first.

@Ayan-10
Copy link
Contributor

Ayan-10 commented Sep 4, 2021

@misaochan @4D17Y4 @ashishkumar468 Is this issue still there in the latest master. I can't reproduce it by the above-mentioned steps.

@nicolas-raoul
Copy link
Member

I also haven't seen this in a while.
I close for now, but if anyone is seeing this again please comment to let us know :-)
Thanks @Ayan-10 for flagging!

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