UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    GPS positioning stops working after a random duration

    Scheduled Pinned Locked Moved Unsolved Support
    13 Posts 4 Posters 1.3k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
      Reply
      • Reply as topic
      Log in to reply
      This topic has been deleted. Only users with topic management privileges can see it.
      • S Offline
        slowcyclist
        last edited by slowcyclist

        When an app actively uses gps (e.g. PureMaps, SensorStatus ...), I find that the location is no longer updated after a random duration ranging from a couple of minutes to well over one hour.

        When that happens
        -the app no longer receives position updates, as if you were not moving anymore (the app itself is fine, it's not frozen),
        -the white location icon is no longer visible in the top toolbar, and if you open the positioning setting panel, positioning is "on" but no longer green and you can't toggle it.
        -SensorStatus reports "AccessError"

        The only way to recover gps positioning is to reboot the phone. Needless to say this bug is particularly annoying when you are depending on your phone for routing while driving. It's also quite frustrating since PureMaps would route me for hours without any problem on my previous phone (Xperia X under 20.04).

        When the loss of positioning occurs, the journal shows :
        Mar 01 17:02:39 ubuntu-phablet systemd[1]: lomiri-location-service.service: Main process exited, code=killed, status=11/SEGV
        Mar 01 17:02:39 ubuntu-phablet systemd[1]: lomiri-location-service.service: Failed with result 'signal'.
        Mar 01 17:02:39 ubuntu-phablet systemd[1]: lomiri-location-service.service: Consumed 1.165s CPU time.

        and the service invokes ExecStart=/usr/bin/lomiri-location-serviced --bus system --provider gps::Provider --provider remote::Provider

        so it's lomiri-location-serviced which segfaults after a random duration, requiring reboot.

        I did not worry too much about the issue earlier because I do not use the GPS heavily, but I believe this issues was already present when got my FP5 back in October. I'm presently on daily channel, running 24.04-1.x (2026-02-13/2), and lomiri-location-service is 3.3.0+0~20250628184827.14+ubports~dev~1.gbp8c98a8

        Am I the only one having this issue?

        KenedaK G W 3 Replies Last reply Reply Quote 0
        • KenedaK Keneda moved this topic from Fairphone 5
        • KenedaK Offline
          Keneda @slowcyclist
          last edited by

          @slowcyclist
          I moved thread so it gets more views, because it may not be device specific.

          2015-2023 : Meizu MX4 ☠️⚰️✝️
          2023-2024 : Nexus 5 ☠️⚰️✝️
          2024-***** : FPOS Fairphone 5
          🇲🇫🇬🇧

          1 Reply Last reply Reply Quote 0
          • KenedaK Keneda marked this topic as a question
          • G Offline
            gpatel-fr @slowcyclist
            last edited by gpatel-fr

            @slowcyclist

            I don't see anything of the sort in my logs of the preceding month, however I am not really using the feature, I have posted that the behaviour was too unreliable (hit and miss, sometimes it works very well, sometimes not at all.

            I tested it a bit at some time to see if AGPS could be made to work, without success so far, however in the process I had found this command:

            sudo lomiri-location-serviced-cli --bus system --test
            

            that allows to follow the activity of the satellite detection in the Halium container; IIRC this command was terminating regularly if left to run continuously, maybe this is related ? it could be linked to a restart of the container or something.

            Looking at the service (systemctl cat lomiri-location-service), I see that no automatic restart has been configured like there is for services such as ofono, for example.
            Maybe you could add an overlay to the service to see if it brings some more reliability ? Beware that an overlay already exists, you would have to take care of that somehow by naming the overlay file such as it comes after the existing one.

            S 1 Reply Last reply Reply Quote 0
            • S Offline
              slowcyclist @gpatel-fr
              last edited by slowcyclist

              @gpatel-fr Except for the bug I report here, I find that GPS on the FP5 works reliably outdoors, although it may take up to a few minutes to get the first fix ( hence maybe the hit-or-miss impression if one is not patient enough). The problem I report here is that, once you get a fix, you can't use the GPS for an arbitrarily long period: at some point (it can be after 5 minutes, 20 minutes or 2 hours) you'll hit this bug and you'll need to reboot to recover usage of the gps (the phone still works well besides that).

              I've also been monitoring what goes on on the android side when the bug occurs:
              LocSvc_GnssAPIClient tries to deliver an NMEA sentence via gnssNmeaCb callback to the UBports hybris layer
              The binder call fails with DEAD_OBJECT because the ubuntu_application_gps_hidl_for_hybris process on the UBports side has died
              LocSvc_GnssInterface detects serviceDied and calls cleanup
              It sends QMI_LOC_STOP_REQ_V02 to the modem — actively stopping GPS at the hardware level
              Then QMI_LOC_SET_ENGINE_LOCK_REQ_V02 — locking the engine
              From this point isGpsEnabled:0 — the session is permanently dead until reboot

              It seems rather clear that the root cause is the UBports process ubuntu_application_gps_hidl_for_hybris that bridges the Android GNSS HAL to the Linux side dying, at which point the Android HAL correctly detects the dead binder and shuts everything down. The GPS hardware itself is fine — it's the UBports bridge process that's crashing due to the segfault.

              If the termination of the lomiri-location-serviced-cli that you observed was due to the same issue, then GPS would seem disabled afterwards, until reboot. And AFAIU having the service auto-restarting would not resucitate the GPS, but I'll give it a try.

              G 1 Reply Last reply Reply Quote 0
              • G Offline
                gpatel-fr @slowcyclist
                last edited by

                @slowcyclist

                I never used GPS a lot , but now that you are speaking of it, I'm beginning to vaguely remember that there could be one or 2 times when GPS stopped mysteriously indeed.

                I'd say that with a process calling back into another, the first process locking everything just because one time it did not get a reply from the client layer would be a fragile design, maybe Google has done this but this does not look like something people designing a system for billions of users would do.
                If there is some retry mechanism, restarting the UT service could be of help.

                S 1 Reply Last reply Reply Quote 0
                • S Offline
                  slowcyclist @gpatel-fr
                  last edited by

                  @gpatel-fr Hey, you were right! By merely restarting the service, positioning becomes available again (no need to reboot!), and adding Restart=on-failure in the service file does the job automatically.
                  Alas, it's not really a fix for the problem : all the applications that were using the gps at the time of the service failure/restart quit as soon as you try to get back to them. Restarting PureMaps is much faster than rebooting, but you still need to acquire a new gps fix...

                  I've seen other errors than segfaults in the same piece of code :

                  Mar 03 15:01:50 ubuntu-phablet lomiri-location-serviced-wrapper[6592]: malloc(): unaligned fastbin chunk detected
                  Mar 03 15:01:50 ubuntu-phablet systemd[1]: lomiri-location-service.service: Main process exited, code=killed, status=6/ABRT
                  Mar 03 15:01:50 ubuntu-phablet systemd[1]: lomiri-location-service.service: Failed with result 'signal'.
                  
                  Mar 03 15:08:19 ubuntu-phablet lomiri-location-serviced-wrapper[7546]: malloc_consolidate(): unaligned fastbin chunk detected
                  Mar 03 15:08:19 ubuntu-phablet systemd[1]: lomiri-location-service.service: Main process exited, code=killed, status=6/ABRT
                  Mar 03 15:08:19 ubuntu-phablet systemd[1]: lomiri-location-service.service: Failed with result 'signal'.
                  

                  It seems this daemon's code did not evolve much lately. It was working well on my Xperia X which was armhf while now I have random alignment errors or segfaults on the FP5 which is arm64. But if the architecture is the reason, it should likely affect all arm64 phones running UBports, unless compilations options/checks are set differently on the FP5...

                  I guess I'll try to rebuild this piece of code with debug symbols, but then guidance for running it with gdb would be welcome.

                  G 1 Reply Last reply Reply Quote 0
                  • G Offline
                    gpatel-fr @slowcyclist
                    last edited by

                    @slowcyclist

                    I don't recall ever having things like that in my logs. I am not running the same version as you, I stick to stable. Not sure if it could make a difference since AFAIK your daily version was the same as the 24.04-1.2 stable 12 days ago, I take it that the problem is older than that for you ? I never tried the daily, do you really upgrade your phone every day ?

                    1 Reply Last reply Reply Quote 0
                    • W Offline
                      WillemHexspoor @slowcyclist
                      last edited by WillemHexspoor

                      @slowcyclist You're not the only one... I'm having the exact same issue, also on FP5. I'm running 24.04-1.2 stable

                      G 1 Reply Last reply Reply Quote 0
                      • G Offline
                        gpatel-fr @WillemHexspoor
                        last edited by

                        @WillemHexspoor said:

                        I'm having the exact same issue, also on FP5. I'm running 24.04-1.2 stable

                        hum, do you have only the same symptoms, or do you also have segfaults and unaligned errors in your logs ?

                        I have the same phone with the exact same version, I may have had the same symptoms (not sure), but definitely not the unaligned errors, at least for the 5 weeks worth of journal data that I have on my phone. @slowcyclist don't use the same version of UT I think, it's daily instead of stable.

                        W 1 Reply Last reply Reply Quote 0
                        • W Offline
                          WillemHexspoor @gpatel-fr
                          last edited by

                          @gpatel-fr

                          My apologies, I replied to the initial post of @slowcyclist, and while re-reading my own post it is indeed not very clear.
                          I'm having the both mallooc and segfaults. Especially the segfaults result into freezing navigation apps.

                          Mar 07 09:42:25 ubuntu-phablet lomiri-location-serviced-wrapper[1708]: malloc(): unaligned fastbin chunk detected
                          Mar 07 09:42:25 ubuntu-phablet systemd[1]: lomiri-location-service.service: Main process exited, code=killed, status=6/ABRT
                          Mar 07 09:42:25 ubuntu-phablet systemd[1]: lomiri-location-service.service: Failed with result 'signal'.
                          Mar 07 09:42:25 ubuntu-phablet systemd[1]: lomiri-location-service.service: Consumed 6.437s CPU time.
                          
                          Mar 08 20:48:56 ubuntu-phablet systemd[1]: lomiri-location-service.service: Main process exited, code=killed, status=11/SEGV
                          Mar 08 20:48:56 ubuntu-phablet systemd[1]: lomiri-location-service.service: Failed with result 'signal'.
                          Mar 08 20:48:56 ubuntu-phablet systemd[1]: lomiri-location-service.service: Consumed 3.987s CPU time.
                          
                          G 1 Reply Last reply Reply Quote 0
                          • G Offline
                            gpatel-fr @WillemHexspoor
                            last edited by

                            @WillemHexspoor

                            thanks for the precisions, now my guess is that I have yet not seen this problem because I have not used GPS a lot in the recent past.

                            1 Reply Last reply Reply Quote 0
                            • S Offline
                              slowcyclist
                              last edited by slowcyclist

                              I finally nailed it! After a simple change and recompiling a package, I could have gps working continuously for over 3 hours, which had never happened previously on my FP5.

                              The problem was indeed in ubuntu_application_gps_hidl_for_hybris.cpp part of the package libubuntu-platform-hardware-api3 whose repo is at https://gitlab.com/ubports/development/core/platform-api, and lomiri-location-services calls this library to access the android drivers (through hybris). The problem was that the code continued to use a chunk of memory that had been supposedly freed (use-after-free) and the memory corruption only became visible when the allocator reused that freed memory chunk for a new allocation. At that point two pieces of code competed for the same memory, leading to crashing. The issue is more likely to happen quickly when many applications are running, explaining the somewhat random duration before the crash.

                              On my Xperia X, a different piece of code was used (ubuntu_application_gps_for_hybris.cpp, not ubuntu_application_gps_hidl_for_hybris.cpp) which explains why it never had this problem.

                              That gps_hidl piece of code has not been touched since 2020 and I believe UBports uses it in all phones running running Android 10+ vendor blobs, meaning that the problem should not be specific to the FP5. Yet, I find it really strange that no one reported the issue previously and that only @WillemHexspoor confirmed it here. Does that mean that UBports users either never use their gps for extended periods (e.g. routing with PureMaps or uNav) or that they only do so under waydroid, or that other phones access the gps through a different scheme (another library)?

                              I have filed a merge request to that package.

                              EDIT: I take back all what I said yesterday, it eventually crashed all the same after (except after a very long time (~10h), and then this morning again after only 3h... So the root cause is not yet found... I'm digging further.

                              G 1 Reply Last reply Reply Quote 1
                              • G Offline
                                gpatel-fr @slowcyclist
                                last edited by

                                @slowcyclist

                                Interesting find, thanks for the effort.

                                @slowcyclist said:

                                never use their gps for extended periods

                                Yes that's the case for me, although these last days I just tried that, and I got effectively 2 occurences of GPS not updating any more (launched Puremaps and Gps app together to make it more interesting). For me the reason is that the FP5 is gulping energy at such a rate that I try to stop services when not actually in use.

                                The only difference is that the GPS service (lomiri-location-service) never stopped for me (according to systemctl status) so no crash with unaligned errors, although I got the second time (did not think to check for that first time) segfaults and several restarts of sensorfwd service, maybe caused by this problem.

                                1 Reply Last reply Reply Quote 0
                                • S slowcyclist referenced this topic

                                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                With your input, this post could be even better 💗

                                Register Login
                                • First post
                                  Last post