streetcomplete / StreetComplete

Easy to use OpenStreetMap editor for Android
https://streetcomplete.app
GNU General Public License v3.0
3.85k stars 352 forks source link

Error message: Searching for Quests #2220

Closed Norwi closed 3 years ago

Norwi commented 3 years ago

Because I was told, I tested a bit more :smile: While using the App, I got an error message: "Fehler beim Suchen nach Aufgaben". It happened twice and I think that it happened both times directly after opening the app. I already had the quests loaded and I don't think I pressed anything, so I don't know how it happened. Loading quests still works. So it does not have any negative effects except for showing the error message.

Detailed error message:

java.lang.NullPointerException: Attempt to invoke virtual method 'de.westnordost.osmapi.map.data.Element$Type de.westnordost.streetcomplete.data.osm.osmquest.OsmQuest.getElementType()' on a null object reference
at de.westnordost.streetcomplete.data.osm.osmquest.OsmQuestController.replaceInBBox(OsmQuestController.kt:108)
at de.westnordost.streetcomplete.data.osm.osmquest.OsmApiQuestDownloader.download(OsmApiQuestDownloader.kt:102)
at de.westnordost.streetcomplete.data.download.QuestDownloader.downloadOsmElementQuestTypes(QuestDownloader.kt:86)
at de.westnordost.streetcomplete.data.download.QuestDownloader.downloadQuestTypes(QuestDownloader.kt:62)
at de.westnordost.streetcomplete.data.download.QuestDownloader.download(QuestDownloader.kt:45)
at de.westnordost.streetcomplete.data.download.QuestDownloadService.onHandleIntent(QuestDownloadService.kt:107)
at de.westnordost.streetcomplete.data.download.SingleIntentService$ServiceHandler.handleMessage(SingleIntentService.kt:27)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.os.HandlerThread.run(HandlerThread.java:67) 

How to Reproduce I don't know because I can't reproduce it.

Versions affected Android 10 Streetcomplete v26.0-beta1

westnordost commented 3 years ago

I was out today too, but couldn't reproduce it. But it occured before yesterday during testing. I looked at the point in the code and thought that this couldn't be so I must have imagined it (or some weird build problem that would be solved if I trigger a rebuild).

But apparently, this is a real bug.

The error happens during download - after the data has been downloaded and the quests created, they are persisted into database.

westnordost commented 3 years ago

So the error is in this line

            val e = ElementKey(quest.elementType, quest.elementId)

and it says that quest is null. However, it can't really be that it is null because quests is passed as List<OsmQuest> (not List<OsmQuest?> to this function.

westnordost commented 3 years ago

Which is also what the IDE advises me if I tried to add a null check there

image

westnordost commented 3 years ago

Hopfefully this was the problem.

xax commented 3 years ago

Having updated from v25.1 to v26.0 (Google Play distribution) for a period of time (5 minutes trying again and again once in a while) I consistently got a brief display of the "search spinner" followed by a toast showing error message mentioned by @Norwi: "Fehler beim Suchen nach Aufgaben. Versuchen Sie es später wieder." (="Error searching for quests. Try again later.").

Eventually the loading of quests was successful and remains being successful trying loading quests in different bboxes.

So the problem isn't fixed 100%.

westnordost commented 3 years ago

This may be another error. Can you please state at which location exactly you searched for quests? Is it reproducable at this location?

xax commented 3 years ago

No, it"s not reproducible anymore.

When the error message appeared, it was independent of locations I tried (~200 km apart) and seemingly independent of zoom level, ie bbox. Incidentally when the loading of quests finally succeeded, it was at virtually the exact same position I tried in the first place.

I'd bet on some race condition (– or temporary connectivity issues on either my end or OSM's side, if those get handled with an error message as cited).

westnordost commented 3 years ago

That will have been the problem I think. The message you mentioned should only be shown in case of a connection error, or the server returned any 5xx HTTP error code, or the response from the server is unintelligable, or the HTTP error code is 408. So, in case the OSM API doesn't seem to work correctly or is not reachable.

In all other cases, you are asked to send an email with the stacktrace to me.