penguin86 / nextcloud-maps-client

Manage Nextcloud Maps Geobookmarks on your Android phone
GNU General Public License v3.0
36 stars 3 forks source link

App crashes immediately after opening if bookmarks contain entry with empty name #14

Closed smihael closed 2 years ago

smihael commented 2 years ago

Immediately after launching the app and choosing the account, the app's interface shows only for a brief while (with no entries) and the app closes.

I am using Nextcloud 23.0.2, but the issue was there with 22.2.5 as well as 21.x and 20.x (I did the updates today) and Maps 0.1.10 on the server side and Geobookmarks app 0.3.4 from F-Droid on Android 10 (EMUI 10.0.0). Clearing the app data, and reinstalling it doesn't help.

I have multiple NC accounts synced on the phone and over 410 bookmarks in the Maps in multiple categories on the affected account. The app interface stays open when the phone is not connected to the internet.

Manual query with curl --user USER:TOKEN https://SERVER/index.php/apps/maps/api/1.0/favorites is also successful. There are some "peculiarities" in the API response, that might cause the issue. The entries are mostly imported from Google Maps and also contain non-ASCII letters if this might be an issue. Comments include HTML syntax, so quotation marks are escaped.

The app interface also stays open if i sync it with a dummy account with no data on server.

smihael commented 2 years ago

Turns out the problem was indeed with several items imported from Google Maps' bookmarks. It has nothing to do with non-ASCII letters, but with missing name tag (which might as well be a bug in Google Maps Takeout). If I remove such entries or add the names in the WebGUI the client app works.

So, to reproduce the bug - save the code bellow as places.kml and upload it to out nextcloud instance.

xml
<?xml version="1.0" encoding="UTF-8"?>
<kml
  xmlns="http://www.opengis.net/kml/2.2"
  xmlns:gx="http://www.google.com/kml/ext/2.2">
  <Document id="10">
      <name>Favourite places</name>
      <Placemark id="2017">
          <name></name>
          <description>
          <![CDATA[

            <a href="https://www.google.com/maps/place//data=!4m2!3m1!1s0x14cab99162d70527:0x64c8680b5ac198ab">https://www.google.com/maps/place//data=!4m2!3m1!1s0x14cab99162d70527:0x64c8680b5ac198ab</a>
          ]]>
          </description>
          <address>Beyazıt, Kalpakçılar Cd. No:22, 34126 Fatih/İstanbul, Turkey</address>
          <Point id="1017">
          <coordinates>28.968068,41.010685,0.0</coordinates>
          </Point>
      </Placemark>
  </Document>
</kml>

Then go to Nexcloud Maps WebGUI, navigate to the menu and select "import from file".

After the entry has been imported, open the client app on the phone and it should crash after it fetches the updated list of favorites.

If you delete that item, the app will work again.

penguin86 commented 2 years ago

Hello @smihael , thank you for reporting. I loved to receive such a detailed report, please go on like this! It helped me to have the problem pinpointed in a couple of minutes. Honestly I think it's a bug of the importer, I don't think a geofavorite with null category is a valid one in Nextcloud Maps (they explicitly set a default value when creating one from the web interface). I think it should be reported, can you do it?

In the meanwhile, I hope this ad hoc release can keep you on the road until it is fixed: https://ichibi.eu/index.php/s/F7gxJgMb89fy4sr Unfortunately I could not sign this app with the F-Droid key, so you have to uninstall your current verson in order to install this. This fix will be included in the next app version, along with other minor fixes.

Thank you again, have a nice day :)

smihael commented 2 years ago

Yeah, it seems that the problem is with importer. Adding entries with empty names from Web (Right click on any place, select Add Favorite, leave name empty) does not crash the app.

image

Before I report it there, I'll need some spare time to inspect this in detail, and compare what gets written into the database. For some reasons the imported entries were assigned to some category in the Web UI (probably on the basis of the filename of the .kml file).

Thanks for the ad-hoc release. I'll try it in the next few days with a dummy account once I get into inspecting the database.

penguin86 commented 2 years ago

Hello @smihael , I released the changes in v0.3.5. I'm going to close this. Thank you for your cooperation. Have a nice day!