jdrescher2006 / Laufhelden

Sport tracker for Sailfish OS
GNU General Public License v3.0
16 stars 17 forks source link

Saved activities are not preserved across app restarts #175

Open rebos opened 1 year ago

rebos commented 1 year ago

After upgrading an Xperia XA2 to Sailfish OS 4.5.0.18 (Struven ketju) I encountered a problem with the process of saving activites using Laufhelden 1.1.4-1: Although the saving process seems to have been successful I do not see any saved activites after closing the app and starting it again.

To reproduce the observed behaviour I followed these steps:

Trying to get some more information about this I launched a terminal session and started the app by calling the corresponding command to get some debug messages: harbour-laufhelden

I was suprised to discover that this session of Laufhelden started via terminal worked perfectly as suspected: Saving an activity led to an existing file which persisted even after closing the app and starting it again: grafik

Performing further attempts to find the differences between both starting methods I realized, that it has something to do with the variable HOME. Unsetting HOME within the terminal session leads to the problem that saved activities are not preserved across app restarts. I could reproduce this by issuing these commands in a terminal session:

unset HOME
harbour-laufhelden

Maybe these observations help to fix the root cause.

Regards, rebos

martonmiklos commented 1 year ago

Hmm. I have checked the code and the activities are saved to the QStandardPaths::writableLocation(QStandardPaths::HomeLocation) folder which should be correct. In your first attempt did the log files created in the $HOME/Laufhelden?

rebos commented 1 year ago

Unfortunately I did not find any log files created by the app.

To get some interactive logging I started the app by clicking the icon und tried to identify the corresponding process in a console session by using "ps". That led me to an invocation of "firejail" which seems to have started "harbor-laufhelden". I then transformed that command and it's arguments to a more readable variant and removed the argument "--quiet". This gave me the following command, which I saved in a script file:

/usr/bin/firejail \
--private-bin=harbour-laufhelden  \
--whitelist=/usr/share/harbour-laufhelden  \
--whitelist=/usr/share/applications/harbour-laufhelden.desktop  \
--mkdir=${HOME}/.local/share/harbour-laufhelden  \
--whitelist=${HOME}/.local/share/harbour-laufhelden  \
--mkdir=${HOME}/.config/harbour-laufhelden  \
--whitelist=${HOME}/.config/harbour-laufhelden  \
--mkdir=${HOME}/.cache/harbour-laufhelden  \
--whitelist=${HOME}/.cache/harbour-laufhelden  \
--profile=/etc/sailjail/permissions/Audio.permission  \
--profile=/etc/sailjail/permissions/Bluetooth.permission  \
--profile=/etc/sailjail/permissions/Camera.permission  \
--profile=/etc/sailjail/permissions/Compatibility.permission  \
--profile=/etc/sailjail/permissions/Internet.permission  \
--profile=/etc/sailjail/permissions/Location.permission  \
--profile=/etc/sailjail/permissions/MediaIndexing.permission  \
--profile=/etc/sailjail/permissions/Microphone.permission  \
--profile=/etc/sailjail/permissions/NFC.permission  \
--profile=/etc/sailjail/permissions/RemovableMedia.permission  \
--profile=/etc/sailjail/permissions/UserDirs.permission  \
--profile=/etc/sailjail/permissions/WebView.permission  \
--profile=/etc/sailjail/permissions/Base.permission  \
-- /usr/bin/harbour-laufhelden

Executing this script when no instance of "harbour-laufhelden" was running started a new process and showed a lot of messages. I think the most interesting ones could be those, which I saw directly after saving an activity:


[D] unknown:0 - Exporting track to gpx
[D] unknown:0 - File: "/home/defaultuser" / "Laufhelden" / "walking-Di. März 14 12:25:51 2023-0.0km.gpx"
[D] unknown:0 - Directory does not exist, creating
[D] unknown:0 - Directory created
[D] unknown:0 - i:  "0"
[D] unknown:0 - i:  "1"
[D] unknown:0 - i:  "2"
[D] unknown:0 - i:  "3"
[D] unknown:0 - i:  "4"
[D] unknown:0 - i:  "5"
[D] unknown:0 - i:  "6"
[D] unknown:0 - i:  "7"
[D] unknown:0 - i:  "8"
[D] unknown:0 - i:  "9"
[D] unknown:0 - i:  "10"
[D] unknown:0 - i:  "11"
[D] unknown:0 - i:  "12"
[D] unknown:0 - i:  "13"
[D] unknown:0 - i:  "14"
[D] unknown:0 - i:  "15"
[D] unknown:0 - i:  "16"
[D] unknown:0 - i:  "17"
[D] unknown:0 - i:  "18"
[D] unknown:0 - i:  "19"
[D] unknown:0 - i:  "20"
[D] unknown:0 - i:  "21"
[D] unknown:0 - i:  "22"
[D] unknown:0 - i:  "23"
[D] unknown:0 - i:  "24"
[D] unknown:0 - i:  "25"
[D] unknown:0 - i:  "26"
[D] unknown:0 - i:  "27"
[D] unknown:0 - i:  "28"
[W] unknown:0 - QFileDevice::flush: No file engine. Is IODevice open?
[D] unknown:0 - GPX file successfully written
[D] onStatusChanged:246 - Active MainPage
[D] unknown:0 - Stopping GPS
[D] onStatusChanged:259 - vMainPageObject: MainPage_QMLTYPE_69(0x4901cf8)
[D] expression for onSigAmountGPXFiles:424 - Amount of tracks: 1
[D] unknown:0 - Loading "walking-Di. März 14 12:25:51 2023-0.0km.gpx"
[D] unknown:0 - Setting filename "walking-Di. März 14 12:25:51 2023-0.0km.gpx"
[D] unknown:0 - m_distance first calculated:  "3.24972"
[D] unknown:0 - m_distance second calculated:  "3.24972"
[W] unknown:21 - file:///usr/share/harbour-laufhelden/qml/pages/SaveDialog.qml:21:1: QML SaveDialog: Binding loop detected for property "_navigation"
[D] unknown:0 - Finished loading "walking-Di. März 14 12:25:51 2023-0.0km.gpx"
[D] unknown:0 - Data loading finished
[D] unknown:0 - Writing helper file: "/home/defaultuser/Laufhelden/AccelerationHelper.dat"
[W] unknown:0 - QQmlExpression: Expression file:///usr/share/harbour-laufhelden/qml/pages/MainPage.qml:822:31 depends on non-NOTIFYable properties:
[W] unknown:0 -     Settings::measureSystem
[W] unknown:0 - QQmlExpression: Expression file:///usr/share/harbour-laufhelden/qml/pages/MainPage.qml:805:31 depends on non-NOTIFYable properties:
[W] unknown:0 -     Settings::measureSystem
[W] unknown:0 - QQmlExpression: Expression file:///usr/share/harbour-laufhelden/qml/pages/MainPage.qml:750:38 depends on non-NOTIFYable properties:
[W] unknown:0 -     Settings::stUsername
[D] fncSetWorkoutFilter:77 - sCurrentDate: Di. März 14 12:26:20 2023 GMT+0100, sWeekYear: 11.2023
[D] fncCheckAutosave:94 - recorder.isEmpty: true

Two aspects caught my attention: One message suggests, that the directory "/home/defaultuser/Laufhelden" does not exist. But it does exist and contains to files created the day before yesterday:

[defaultuser@XperiaXA2-DualSIM ~]$ ls -lh /home/defaultuser/Laufhelden/
total 20K
-rw-rw-r--    1 defaultu defaultu     326 Mar 12 17:23 AccelerationHelper.dat
-rw-rw-r--    1 defaultu defaultu    6.3K Mar 12 16:44 walking-So. März 12 16:44:15 2023-0.0km.gpx
-rw-rw-r--    1 defaultu defaultu    6.3K Mar 12 17:23 walking-So. März 12 17:23:04 2023-0.0km.gpx
[defaultuser@XperiaXA2-DualSIM ~]$

Another messages suggests, that the file "walking-Di. März 14 12:25:51 2023-0.0km.gpx" was successfully written. So I should be able to find it, but unfortunately I can't:

[defaultuser@XperiaXA2-DualSIM ~]$ pwd
/home/defaultuser
[defaultuser@XperiaXA2-DualSIM ~]$ find . -name "walking-Di. März 14 12:25:51 2023-0.0km.gpx"
find: ./.config/signond: Permission denied
find: ./.local/share/system/privileged: Permission denied
[defaultuser@XperiaXA2-DualSIM ~]$

I can't even find it running "find" on the whole filesystem after using "devel-su".

So, as far as I can put it together now, starting "harbour-laufhelden" in a terminal session works as expected, but starting it in a terminal session using the firejail invocation does not (at least on my system).