[linux][qt] Add positioning support via GeoClue2 #5823
No reviewers
Labels
No labels
Accessibility
Address
Android
Android Auto
Android Automotive (AAOS)
API
AppGallery
AppStore
Battery and Performance
Blocker
Bookmarks and Tracks
Borders
Bug
Build
CarPlay
Classificator
Community
Core
CrashReports
Cycling
Desktop
DevEx
DevOps
dev_sandbox
Directions
Documentation
Downloader
Drape
Driving
Duplicate
Editor
Elevation
Enhancement
Epic
External Map Datasets
F-Droid
Fonts
Frequently User Reported
Fund
Generator
Good first issue
Google Play
GPS
GSoC
iCloud
Icons
iOS
Legal
Linux Desktop
Linux packaging
Linux Phone
Mac OS
Map Data
Metro
Navigation
Need Feedback
Night Mode
NLnet 2024-06-281
No Feature Parity
Opening Hours
Outdoors
POI Info
Privacy
Public Transport
Raw Idea
Refactoring
Regional
Regression
Releases
RoboTest
Route Planning
Routing
Ruler
Search
Security
Styles
Tests
Track Recording
Translations
TTS
UI
UX
Walk Navigation
Watches
Web
Wikipedia
Windows
Won't fix
World Map
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: organicmaps/organicmaps#5823
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "github/fork/Ferenc-/linux-geoclue"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes https://github.com/flathub/app.organicmaps.desktop/issues/19
requested review from
@biodranik
requested review from
@pastk
{ from the new line and usually we don't use 2-space indent after namespace:
2 spaces
return ?
LOG(LERROR) crashes on Debug.
So if it is a bad, but possible situation, use LOG(LWARNING) here and below.
Review: Commented
LGTM
Documentation should be updated with these dependencies.
This package is needed only for the app, e.g. desktop builds (and maybe for some tests). Does it make sense to use it only when necessary and avoid, for example, on server builds?
Please name the last variable, it's not clear what is it about.
Are there other services except geoclue2? Why is it made as a parameter?
and below for all one-liners.
static_cast is a better C++ way, here and below.
static_cast
In our notation (RTL) should be QString const& everywhere ( a reference to a const QString).
Please do not use C-style type casting in C++ code.
Do you really need this isConnected variable? Won't this work?
When does this function fail? Is it an abnormal situation?
If a "normal" failure can happen in the constructor, and you get a half-valid object, then you need to use a different pattern: some static fabric method that will initialize everything and either fail (and return false or std::optional) or succeeds and returns a valid constructed object.
nit: It would be great to refactor our location service to use unique_ptr and make_unique instead of raw pointers.
Review: Commented
Can you please also temporarily comment current mac os location implementation and enable it also via Qt?
Done
Done
Done
It's an extensible plugin system. So yes, there are many other plugins out there already besides
geoclue2
, some from Qt directly, some from third parties and we could also write our own.For Linux the options that are worth listing are:
Mainly so that if we want to support any from the above list, then we can do so easily.
And theoretically for MacOS we could refactor and simplify the existing positioning to use this new
qt_location_service
with corelocation.And for Windows, there might also be something out there if anyone is even interested.
All right, done.
Can several services be used at the same time for better location updates?
Done
Done
Done
I don't need it. For me it is even better if I eliminate the
isConnected
, it was simply a courtesy to the reader.And yes the goal is to immediately crash, because it is a sign of a developer error if it is not properly connected.
Done
This is not a normal failure, this can only happen if a developer made a mistake.
This can happen if there is a system level issue, permission issue, files got deleted etc.
If
geoclue2
or any other plugin being used is properly installed and configured, then this should not happen.So I would not call this a "normal" failure.
Well yes. Perhaps one can imagine rare corner cases, in which it might make an actual difference. Let's say that
geoclue2
uses the wifi device to get a street level accuracy quickly which allows the user to hit the road already, until agpsd
only high-end receiver boots up and starts providing the much more accurate positioning.It is intended for developers doing the debugging, because in this case if this signal is not properly connected, then it is a developer error.
I agree. And I also think that such a refactor would impact all the platforms, and should go into a separate PR.
Is that OK?
Now, I have made it conditional on
PLATFORM_DESKTOP
.You mean dropping
apple_location_service.mm
and usingqt_location_service
instead? Can it go into a separate PR?Yes, separate PRs for both. Refactoring is a very low priority though.
Done
done
Done
requested review from
@biodranik
requested review from
@vng
Looks like it's not serialized in settings, but I wouldn't change the existing order anyway.
CHECK(false, (...));
Here and below. Crash should be immediate for developers' errors, in debug and in production.
Review: Commented
Did you test it? Does it work?
It is a developer error if this fails.
So can we keep it?
So far I have not found any case in which it doesn't work. That doesn't mean that there can't be any.
In the Qt positioning timeout is definitely an error
And I have checked the existing code, have not found anything, have I missed something?
@biodranik
Can I proceed to the2.
and3.
points?Yes.
From the Qt docs it looks like timeout error can be recoverable and unrecoverable. Looks like some additional logic is needed to properly handle different cases.
It would be better to add comments with a link and text that this is used only in Qt now.
Done. PTAL
requested review from
@biodranik
@biodranik
For your kind reviewShould AUTOMOC be set on all desktop platforms?
Didn't we merge unique_ptr support?
Yes we have, for
CreateDesktopLocationService
and this is not that one, this isCreateQtLocationService
.Here the raw pointer is currently still needed because of
std::vector<LocationService *> m_services;
, which has not been refactored tostd::vector<std::unique_ptr<LocationService>> m_services;
yet.I could do that too in a separate PR, if it is desired and there is capacity for its review.
It was the
bsdiff_tests
which made it necessary here.So far this PR was focusing on linux only,
perhaps as a preparation for the refactoring of the MacOS code, to leverage the
qt_location_service
,Perhaps as such, it could make sense, but in general, IMHO all that would belong to a separate PR.
Here is the PR for that: #5985
Please, rebase, I will check on MacOS.
make_unique?
approved this merge request
Done
Rebased.
@vng
Is there anything else needed here?Well, I tried to use yours QtLocationService in MacOS, but no luck:
There is no Qt6Positioning lib in my Qt package. Whatever ..
I installed all packages added to the INSTALL.md, built and launched the desktop app.
Worked fine until I tried to press the position / crosshair button:
I expect it do nothing or display an error maybe, but not crashing.
A laptop w/o GPS unit, Ubuntu 18.04.
@pastk
This is indicative of geoclue itself being misconfigured. Is there any other application that can use geoclue on your system?
Most importantly, does geobug work well? What is in
/etc/geoclue/geoclue.conf
?Regardless of the first issue this might need attention.
That's what I have observed so far with supported LTS OS like Ubuntu 22.04
A GPS unit is absolutely NOT needed, the vast majority of the tests were without GPS anyway.
Even Ubuntu ended the general support for that, and with the official packages,
organicmaps
doesn't even compile on that system, so I guess the next set of questions could been, how did you even compile it.But before that, back to most imprtant: Is there anything (like geobug) that can work on your system?
Geobug (installed from the flathub) runs and shows my approx location (IP-based I think):
Maybe flatpak runtimes contain some deps which are missing on my system?
I've attached my geoclue.conf (I've changed nothing there).
pastk-geoclue.conf.txt
re Ubunutu 18.04, recently I had to install Qt6 and some related libs from some PPA, otherwise it was fine (but its been long time since I setup OM initially).
I also suspect the same.
Could you try this build?:
In this build nothing happens when I press a location button.
And on startup there are following log lines:
This means that you have incorrect privileges. Copy-paste from the docs:
The connection setup to the remote positioning backend failed because the application lacked the required privileges.
But it is weird, that geobug was able to connect and work properly. Although geobug does not rely on Qt to connect...
Anyhow I might spin up a
18.04
later to see what is going on.Hm its super weird but now I run your test flatpak build again and it crashes upon location button press just like my off-the-master build (just w/o a segfault line):
And there are no startup log lines mentioned in #5823 (comment) anymore.
I don't know why the first run was different, I don't recall changing anything since then...
Upd: I've also tried starting it as a root (to see if extra priviliges help) - no change.
@Ferenc-
is it possible to avoid build errors when NOT building a desktop client target with cmake?tools/unix/build_omim.sh -d generator_tool
Very odd, I have now installed a
18.04
for the sake of this investigation, but for me (so far) there is no crash afterQGeoPositionInfoSource::Error code: 0
.And this is a fresh install.
I will look into this.
mentioned in merge request !6054
mentioned in issue #3870
mentioned in issue #5114
mentioned in issue #6328
mentioned in issue #9728
mentioned in merge request !9981