apps-android-commons icon indicating copy to clipboard operation
apps-android-commons copied to clipboard

[Bug]: crash when attempting to take picture on nearby without Internet

Open mnalis opened this issue 2 months ago • 10 comments

Summary

app crashes when trying to take picture in Nearby when Internet is not present.

Steps to reproduce

  1. open the app
  2. go to Nearby tab
  3. click on the location
  4. disable Internet in phone testing (or, in real life, have flaky internet connection)
  5. click on + and choose camera to take picture
  6. confirm picture with OK
  7. app crashes

Expected behaviour

app would not crash in step 7, instead it would ask me to proceed (i.e. type description etc. - of course it would complain when trying to add categories and depicts which need Internet connection, so I would have to wait for them to work again, but I would not lose work and could continue with uploading picuture later when Internet access become available)

Actual behaviour

app crashes, losing picture

Device name

Samsung Galaxy S23+

Android version

Android 15 (stock Samsung ROM, but degooglified, i.e. no GMS)

Commons app version

6.0.2~a283ffe2b (latest F-droid)

Device logs

USER_COMMENT=trying to add camera picture to object in Nearby with no internet connection.
APP_VERSION_CODE=1058
APP_VERSION_NAME=6.0.2
ANDROID_VERSION=15
PHONE_MODEL=SM-S916B
STACK_TRACE=java.lang.NullPointerException: Attempt to invoke virtual method 'double fr.free.nrw.commons.location.LatLng.getLatitude()' on a null object reference
        at fr.free.nrw.commons.nearby.PlacesLocalDataSource.fetchPlaces(PlacesLocalDataSource.java:60)
        at fr.free.nrw.commons.nearby.PlacesRepository.fetchPlaces(PlacesRepository.java:51)
        at fr.free.nrw.commons.nearby.presenter.NearbyParentFragmentPresenter$handleMapScrolled$2.invokeSuspend(NearbyParentFragmentPresenter.kt:573)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
        at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111)
        at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:585)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:802)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:706)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:693)
        Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@3b9e738, Dispatchers.IO]

IS_SILENT=false
USER_CRASH_DATE=2025-10-09T17:38:21.804+02:00
REPORT_ID=52b63fbe-5a6d-41f6-8217-1118e5007953
USER_EMAIL=

Screen-shots

https://github.com/user-attachments/assets/e033e014-1619-437f-a286-d420bc95f5af

Would you like to work on the issue?

None

mnalis avatar Oct 09 '25 15:10 mnalis

invoke virtual method 'double fr.free.nrw.commons.location.LatLng.getLatitude()' on a null object reference sounds like it might be possibly related to Commons app not having GPS (maybe due to https://github.com/commons-app/apps-android-commons/issues/6468 and Stock Samsung Camera having disabled recording GPS to EXIF), but if I have Internet available when I take picture, the app does not crash immediately, so perhaps unrelated.

App should not crash in any case 🥲


Also, if I try to add a picture via Contributions tab and + without Internet connection; it takes a picture, and correctly opens a dialog saying "Connection Error / The upload process requires active internet access. Please check your network connection. / CANCEL UPLOAD / OK" (instead of crashing). It should work like that for images taken via Nearby tab too.

mnalis avatar Oct 09 '25 16:10 mnalis

At first, two times:

❌ I cannot reproduce using 6.0.2~a283ffe2b with both location enabled and disabled.

I do get the dialog saying "Connection Error / The upload process requires active internet access. Please check your network connection. / CANCEL UPLOAD / OK".

And then, two other times:

✔️ I can reproduce using 6.0.2~a283ffe2b with both location enabled and disabled.

I don't get the dialog saying "Connection Error / The upload process requires active internet access. Please check your network connection. / CANCEL UPLOAD / OK". The app crashes instead.

Sooo, yeah!

As you said, the app doesn't immediately crash when Internet is on, so I don't think this is related to the GPS being enabled or not.

I think it's related to getting the Latitude and the Longitude of the point on the map, and not the actual user position. For me, this refers to a request being done to the OpenStreetMap API in order to get the coordinates of the object.

The two behaviours have occured to me several times, at maybe a 50% ratio and I couldn't find a reason whether or not it would work.

PetitPotiron avatar Oct 10 '25 08:10 PetitPotiron

Hi @PetitPotiron, are you working on this issue?

rohit9625 avatar Oct 11 '25 13:10 rohit9625

Hi @PetitPotiron, are you working on this issue?

Hi @rohit9625. No, unfortunately, I have nearly zero knowledge in android development. And I have no time to learn for now.

It is yours if you want!

PetitPotiron avatar Oct 11 '25 14:10 PetitPotiron

It is yours if you want!

Thanks, I'll be fixing this issue :)

rohit9625 avatar Oct 11 '25 14:10 rohit9625

Hi @rohit9625 Are you working on this issue ?

Kota-Jagadeesh avatar Nov 13 '25 12:11 Kota-Jagadeesh

Hi @Kota-Jagadeesh, thanks for asking. Actually, I started working on this issue and reached the code causing the issue. But I didn't get enough time to continue working on a fix. If you have time and are willing to fix this issue, then I can link the code here, so that you can continue the work from there. Otherwise, I'll be able to work on this after Tuesday.

Let me know :)

rohit9625 avatar Nov 14 '25 16:11 rohit9625

Hi @Kota-Jagadeesh, thanks for asking. Actually, I started working on this issue and reached the code causing the issue. But I didn't get enough time to continue working on a fix. If you have time and are willing to fix this issue, then I can link the code here, so that you can continue the work from there. Otherwise, I'll be able to work on this after Tuesday.

Let me know :)

Hi @rohit9625, Thanks for the update! No worries about the time, I actually went ahead and implemented a fix for this issue. I have opened the PR related to this issue : ) Thanks again!

Kota-Jagadeesh avatar Dec 09 '25 05:12 Kota-Jagadeesh

That's good @Kota-Jagadeesh. But, I'll suggest that you get the issue assigned to you first from the next time. I hope you understand :)

rohit9625 avatar Dec 09 '25 06:12 rohit9625

That's good @Kota-Jagadeesh. But, I'll suggest that you get the issue assigned to you first from the next time. I hope you understand :)

Yeah, Sure 👍🏻

Kota-Jagadeesh avatar Dec 09 '25 06:12 Kota-Jagadeesh