streetcomplete / StreetComplete

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

NullPointerException on undoing #812

Closed matkoniecz closed 6 years ago

matkoniecz commented 6 years ago

I am not sure whatever dev version of StreetComplete calls home with crash reports so I post it here.

I can trigger crash by selecting undo.

It seems likely that making SC edit, making edit to the same object using Vespucci editor and later using undo in SC caused this problem to appear.

I kept my SC in the same state - I can provide more debug info if that would be useful.

01-28 17:58:31.988 13919-13919/de.westnordost.streetcomplete.debug E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                     Process: de.westnordost.streetcomplete.debug, PID: 13919
                                                                                     java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Map de.westnordost.osmapi.map.data.Element.getTags()' on a null object reference
                                                                                         at de.westnordost.streetcomplete.MainActivity.confirmUndo(MainActivity.java:316)
                                                                                         at de.westnordost.streetcomplete.MainActivity.onOptionsItemSelected(MainActivity.java:350)
                                                                                         at android.app.Activity.onMenuItemSelected(Activity.java:2963)
                                                                                         at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:368)
                                                                                         at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:195)
                                                                                         at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:108)
                                                                                         at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:108)
                                                                                         at android.support.v7.app.ToolbarActionBar$2.onMenuItemClick(ToolbarActionBar.java:65)
                                                                                         at android.support.v7.widget.Toolbar$1.onMenuItemClick(Toolbar.java:202)
                                                                                         at android.support.v7.widget.ActionMenuView$MenuBuilderCallback.onMenuItemSelected(ActionMenuView.java:780)
                                                                                         at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:822)
                                                                                         at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:171)
                                                                                         at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:973)
                                                                                         at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:963)
                                                                                         at android.support.v7.widget.ActionMenuView.invokeItem(ActionMenuView.java:624)
                                                                                         at android.support.v7.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:150)
                                                                                         at android.view.View.performClick(View.java:5207)
                                                                                         at android.view.View$PerformClick.run(View.java:21177)
                                                                                         at android.os.Handler.handleCallback(Handler.java:739)
                                                                                         at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                         at android.os.Looper.loop(Looper.java:148)
                                                                                         at android.app.ActivityThread.main(ActivityThread.java:5441)
                                                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
                                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)
matkoniecz commented 6 years ago

In case that current state of my SC install is not useful - please, tell me so I can reset it (I plan on using SC and making PR for https://github.com/westnordost/StreetComplete/issues/750#issuecomment-361078545 )

matkoniecz commented 6 years ago

Crash was triggered on SC trunk, revision 9f25eeb3

matkoniecz commented 6 years ago

@westnordost Is current state of app likely to be useful? I am keeping it unused for now, but I prefer to be able to install SC into my phone, so if there is any debug info that would be useful I prefer to provide it now.

westnordost commented 6 years ago

To solve this problem for yourself, you can either clear all data for the app of course, or, you click the upload button once. Part of the upload process is to remove any closed quests that are older than yesterday. The error is caused by a closed quest at the top of the undo queue which does not have an element associated with it anymore. This happens always when the element the quest was trying to modify was deleted in the meantime and thus the quest was closed as conflicting. The bug leads to that in the case as experienced by you, you are unable to undo anything, because it leads to a crash, for one day.

The fix is to not close a conflicting quest, but to delete it, so it is not a candidate for the undo-feature.