ubipo / osmfocus

Open source tool for examining OpenStreetMap elements by moving around on a map.
Apache License 2.0
43 stars 5 forks source link

Unhandled exception: List is empty. #34

Closed Ansbaradigeidfran closed 2 years ago

Ansbaradigeidfran commented 2 years ago

Exception details

Message: List is empty.

What happened / what actions did you take before the bug occurred?

-- Please fill here -- Opened application, but failed to load. Probably due to an issue loading something at the last-viewed location.

Comments

A recent update started displaying tick and cross markers on the default map layer. When scrolling through the area of Llandudno, North Wales, the program started crashing silently on occasion. Attempts to scroll past this problem area left the program crashing with a last-viewed location that it was unable to load at, giving the above error on startup.

Uninstalling and reinstalling OSMfocus allowed the program to load properly, because the default view was reset to a location in Germany. On scrolling back to the Llandudno area, the same symptoms returned.

This appears to me to be a bug in how OSMfocus handles some erroneous or incomplete information in the OSM map layer.

Stack trace

java.util.NoSuchElementException: List is empty.
    at kotlin.collections.CollectionsKt___CollectionsKt.first(_Collections.kt:8)
    at net.pfiers.osmfocus.service.osmapi.NotesDownloadManager.processDownload(NotesDownloadManager.kt:25)
    at net.pfiers.osmfocus.service.osmapi.EnvelopeDownloadManager$download$result$1$1.invokeSuspend(EnvelopeDownloadManager.kt:2)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:3)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:18)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:1)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:10)

System / app info

App version: 1.4.0-fdroid
App version code: 140
App build type: release
Android version: 27
Device name: BlackBerry BBB100-2
Ansbaradigeidfran commented 2 years ago

Changing the default map layer has no effect on the issue. From un/reinstalling, and scrolling towards Llandudno from different directions, it appears to be an issue with interpreting a note left on OSM in the area of Llandudno town itself. (I'm not going to pursue this issue in the OSM dataset immediately, as it would make it harder to fix the issue in OSMfocus.)

(p.s. No, that default map location wasn't in Germany. That's me being inattentive and just scrolling west immediately!)

Ansbaradigeidfran commented 2 years ago

While repeatledly scrolling around the faulty area (zoomed in), I got the following different error:

"Invalid URL: SUCCESS for https://api.openstreetmap.org/api/0.6/map?bbox=-3.83105,53.31785,-3.82007,53.32731"

The co-ordinates in the URL may help pin down the location of the erroneous data that's making OSMfocus sulk. I believe it's on the northern or western edge of this screen (I was scrolling north-west when the errors started).

ubipo commented 2 years ago

Well, this is quite the elusive bug for me 😄

I cannot find the exact location in code where that first List is empty. exception occurred. I did find a nearby spot where .first() is used (the method in which the exception occurred), however I doubt it could have triggered the exception there. In any case I made it so it's completely impossible to occur there in 18728aa just to be sure.

As for the second bug (Invalid URL: SUCCESS for https://api.openstreetmap.org/api/0.6/map?bbox=-3.83105,53.31785,-3.82007,53.32731): this one is even more mysterious, as I don't have a string like that in the code. It must've been raised from some dependency, but I cannot figure out which.

I did look up the area from the URL (http://geojson.io/#id=gist:ubipo/d0a6b5c739ae719d5f5e95cd6f6ffb70&map=14/53.3200/-3.8276) but could not reproduce either one of those bugs.

I've released v1.5.0 now so you can have a look if you can reproduce it in that version. I'll keep this open until then.

Thanks for reporting!

Ansbaradigeidfran commented 2 years ago

Hi,

As the 1.5.0 update wasn't pushed to the fdroid database within a few days, I downloaded and manually installed the 1.5.0 apk to test.

I'm happy to say that scrolling to the same geographical area no longer causes the application to crash in 1.5.0.

I reinstalled 1.4.0-FDROID in case this error was caused be a transient OSM database artifact which had been removed in the meantime. The 1.4.0-FDROID version still crashed in the original manner, so it was your recent patch that fixed the issue.

If you could push the 1.5.0 update to the fdroid database, I'd be most grateful.

Thank you for looking into the error, and resolving it.

ubipo commented 2 years ago

Great to hear! And thanks for the coffee ;)

The F-Droid build server actually pulls from this repo and builds it itself. The whole process is still a bit of a mystery to me, but from experience it's not unusual to take this long.