Maproom / qmapshack

Consumer grade GIS software
GNU General Public License v3.0
287 stars 64 forks source link

Special fit file crashes QMS #628

Open googol42 opened 1 year ago

googol42 commented 1 year ago

Describe the bug

Importing the attachted fit file crashes QMS. The file was created with Garmin Connect.

What have you done to circle down the problem?

Nothing

To Reproduce

  1. Download the file and change the extension to fit (I renamed the file to "zip" because I could not upload fit files).
  2. Open the file (via drag and drop or via file explorer)
  3. Segmentation Fault

Expected behavior

Don't crash :-)

Screenshots

None

Attachments

COURSE_182954785.zip - change the extension to fit

Tracebacks

comment: # (Add your backtrace below if you have one. If QMapshack crashes the fastest way to get help is a backtrace. For Linux see: https://github.com/Maproom/qmapshack/wiki/TroubleShooting#create-a-backtrace-of-a-crash-on-linux. For Windows it would need a debug build and running QMapshack in Visual Studio.)

None

Desktop

Additional context

The same track just downloaded as gpx from Garmin Connect can be imported.

wthaem commented 1 year ago

No crash on Windows - but very strange behavior of QMS:

frankystone commented 1 year ago

Can't confirm all of the mentioned behavior. After renaming from .zip to .fit it loads fine and all is displayed: Screenshot_20230806_163202

wthaem commented 1 year ago

Workspace after loading FIT file:

capture_002_06082023_170526

The blue line seems to belong to a nameless object

QMS not correctly closed: GUI no more visible, starting QMS again:

2023-08-06 17:00:18.326 [debug] Sent parameters to primary instance. Result false
2023-08-06 17:00:18.326 [debug] There can only be one. Exit.
frankystone commented 1 year ago

I forgot to mention that i am also on archlinux, but my display manager is kwin (just to mention it). I have loaded the file from within QMS.

wthaem commented 1 year ago

Additional information:

The behavior described in my previous comments is valid if FIT file is loaded with drag-and-drop.

If loading this file with the File -Load GIS Data QMS crashes immediately.

Call stack:

    Qt5Core.dll!00007ffde1339d43()  Unbekannt
>   qmapshack.exe!readFitCoursePoint(const CFitMessage & mesg, IGisItem::wpt_t & wpt) Zeile 141 C++
    qmapshack.exe!CGisItemWpt::CGisItemWpt(CFitStream & stream, IGisProject * project) Zeile 165    C++
    qmapshack.exe!CFitProject::createGisItems(QFile & file) Zeile 120   C++
    qmapshack.exe!CFitProject::tryOpeningFitFile(const QString & filename) Zeile 80 C++
    qmapshack.exe!CFitProject::loadFitFromFile(const QString & filename, bool showErrorMsg) Zeile 46    C++
    qmapshack.exe!CFitProject::CFitProject(const QString & filename, CGisListWks * parent) Zeile 33 C++
    qmapshack.exe!IGisProject::create(const QString filename, CGisListWks * parent) Zeile 123   C++
    qmapshack.exe!CGisWorkspace::loadGisProject(const QString & filename) Zeile 124 C++
    qmapshack.exe!CMainWindow::loadGISData(const QStringList & filenames) Zeile 1178    C++
    qmapshack.exe!CMainWindow::slotLoadGISData() Zeile 1172 C++
    [Externer Code] 
    qmapshack.exe!main(int argc, char * * argv) Zeile 75    C++
    [Externer Code] 
wthaem commented 1 year ago

Are there any special rules for preparing & compiling the FIT support in QMS (update FIT SDK, update ...\src\qmapshack\gis\fit\defs\*.csv, run ...\src\qmapshack\gis\fit\defs\profiles.py, ...?)

Is there somewhere a check that FIT file complies with data generated from mentioned CSV files?

kiozen commented 1 year ago

The reason for the crash are the waypoint symbols stored in the file. QMapShack knows 26 different symbols:

QString wptIconNames[26]{"Default",     "Summit",      "Valley",       "Water",       "Food",        "Danger",
                         "Left",        "Right",       "Straight",     "FirstAid",    "4thCategory", "3rdCategory",
                         "2ndCategory", "1stCategory", "HorsCategory", "Sprint",      "LeftFork",    "RightFork",
                         "MiddleFork",  "SlightLeft",  "SharpLeft",    "SlightRight", "SharpRight",  "UTurn",
                         "Start",       "End"};

They are accessed by index. The file uses these index:

2023-08-07 13:06:40.015 [debug] 34
2023-08-07 13:06:40.015 [debug] 52
2023-08-07 13:06:40.016 [debug] 28
2023-08-07 13:06:40.016 [debug] 27
2023-08-07 13:06:40.016 [debug] 36
2023-08-07 13:06:40.016 [debug] 38
2023-08-07 13:06:40.016 [debug] 48

Either there is a new coding, unkown to QMapShack, or Garmin extended the symbol table for FIT files. I suspect the later. In that case I would need all icons that use a code larger than 25 to append the array. This has to be revers engineered by those owning a device that uses these extended symbol tables. For example create a FIT file that contains all symbols possible.

If I do not get that table I can fix the crash and replace any unknown symbol by the ugly default symbol.

wthaem commented 1 year ago

@kiozen: compare src\qmapshack\gis\fit\defs\HowToFitGenerator.txt and there the line

These csv files are the export from the Excel "Profiles.xlsx" within the FIT SDK (Current Version 20.27).

The Excel file delivered with the recent FIT SDK has most likely the missing symbols and it can be used to create new CSV files (the text file doesn't give sufficient information how to do this, but trial-and-error could reveal the necessary steps). Then proceed as described in the text file (run Python script and insert results into CPPs). This information should be used to update (with an extended Python script?) the wptIconNames list you mentioned, too. No idead wrt icons.

And its remains the question asked in my previous comment: Is there somewhere a check that FIT file complies with data generated from mentioned CSV files?

kiozen commented 1 year ago

The SDK - good idea. That is the table. Now we need a volunteer to map the symbols to existing icons in QMapShack or to draw new ones for those not matching any existing. The exiting icons are all listed in CWptIconManager.cpp. The SVG files for the waypoint icons are in ``CWptIconManager.cpp

generic | 0
summit | 1
valley | 2
water | 3
food | 4
danger | 5
left | 6
right | 7
straight | 8
first_aid | 9
fourth_category | 10
third_category | 11
second_category | 12
first_category | 13
hors_category | 14
sprint | 15
left_fork | 16
right_fork | 17
middle_fork | 18
slight_left | 19
sharp_left | 20
slight_right | 21
sharp_right | 22
u_turn | 23
segment_start | 24
segment_end | 25
campsite | 27
aid_station | 28
rest_area | 29
general_distance | 30
service | 31
energy_gel | 32
sports_drink | 33
mile_marker | 34
checkpoint | 35
shelter | 36
meeting_spot | 37
overlook | 38
toilet | 39
shower | 40
gear | 41
sharp_curve | 42
steep_incline | 43
tunnel | 44
bridge | 45
obstacle | 46
crossing | 47
store | 48
transition | 49
navaid | 50
transport | 51
alert | 52
info | 53
mitxel-m commented 1 year ago

I could create the icons and extend the list in CWptIconManager.cpp., (from next week)

wthaem commented 1 year ago

@mitxel-m, @kiozen:

I tested the following approach:

With these changes no problems with the discussed FIT file anymore.

icons

If a better icon file is available, it can simply be used to replace the yellow-square one.

mitxel-m commented 1 year ago

@wthaem thanks a lot for that check. ... this adds extra motivation to draw the missing icons, and I'll do them next week.