Mapbox GL Native QML plugin
2 Attachment(s)
This is an announcement of Mapbox GL Native (https://github.com/mapbox/mapbox-gl-native) QML plugin that can be used to display and interact with the maps in QML application. This is a fast, OpenGL accelerated, high-quality rendering-providing map component that should be easy to use for app developers.
It is recommended to use this as QML plugin and use it through QML interface. It is possible to use the developed plugin by incorporating it on C++ source level, but then you will need newer gcc (>=4.9). When using QML interface, older gcc provided with SFOS is sufficient. I am starting this thread to provide simple to find information on this QML plugin and to mark the readiness of the plugin for general development of map applications. This thread could be considered as a continuation of "brainstorm" thread https://talk.maemo.org/showthread.php?t=93358 and the step towards implementation of the original brainstorm request. Project GitHub page: https://github.com/rinigus/mapbox-gl-qml Documentation: https://github.com/rinigus/mapbox-gl.../master/api.md License: LGPL3. For the gesture area interaction component, MIT. Requirements: Qt >= 5.6 SFOS packaging: OBS: https://build.merproject.org/package...s/mapboxgl-qml OpenRepos: https://openrepos.net/content/rinigu...indings-qt-qml C++ development library QMapboxGL for C++ development is packaged using https://github.com/rinigus/pkg-mapbox-gl-native and available at https://build.merproject.org/package...maps/qmapboxgl. Example code As an example, see a QML item that would show a map that can be zoomed and panned Code:
import QtQuick 2.0 Current issues Issues are followed on GitHub project page at https://github.com/rinigus/mapbox-gl-qml/issues Current main issue is crashes on Jolla 1 and Photon Q. Obligatory screenshots Poor Maps prototype showing
|
Re: Mapbox GL Native QML plugin
To test whether very primitive style helps against crashes on Jolla 1, maybe someone could test QML-only app? For that:
* Install https://build.merproject.org/package...s/mapboxgl-qml (download from http://repo.merproject.org/obs/home:...mv7hl/armv7hl/) * Get QML-only demo at https://github.com/rinigus/mapbox-de...aster/qml-only . You would need the both QML files in this directory * run Code:
qmlscene mapbox-gl-qml.qml At present, QML plugin is statically linked with newer stdc++. So, I wonder if that would work on J1. On other devices I don't expect any problems (except Photon Q). |
Re: Mapbox GL Native QML plugin
Quote:
Now for the tests itself: * Played with it for quite some time with this basic red theme, and didn't notice anything wrong. I moved/zoomed around as fast as possible (in the range of "normal use" to "crazy as hell") without any crash. * Seeing at it looks like it was working well, I edited the QML to remove the "jsonStyle" part, to get back to the standard map (it is really easy to do, good job!), and I got it working for quite some time. As a lot is now displayed, it is fun to zoom/move/unzoom/move somewhere else. At the end, I got another crash (segmentation fault). it can work from 10 to 30 seconds before the crash when torturing it (from world to street level and back to another country streets in seconds). Using it a bit less fast (looking around a single city), it can last close to 1 minutes. And if only zooming in a park and not touching it, except to keep it from shutting screen, then it seems to run forever (I stopped after 7 minutes, by moving around as fast as possible and it then crashed). So at this end, the way it is used impacts the time it takes to crash, and the simple red theme, if it could finally crash, does it after a long time of torturing it. Likely some resources exhaustion (network, ram, gpu, handles of something ?), some timing issues (the more it is to do, the more likely a collision can occur), memory/stack corruption, or a specific program path that leads to the crash when a specific item has to be computed/drawn ? Nothing easy to find so... The main differences between the Jolla1 and the other are mainly the gpu driver, and some more limited hardware. There are also different kernel and the like. With full map, the crash can appear anywhere it seems. gdb output is: Code:
Program received signal SIGSEGV, Segmentation fault. Code:
Program received signal SIGSEGV, Segmentation fault. |
Re: Mapbox GL Native QML plugin
Zeta's testing was way more complete than mine. I only played with the red theme a couple of minutes and it seemed fluent until exit
The output: Code:
[nemo@Sailfish mapbox]$ qmlscene mapbox-gl-qml.qml |
Re: Mapbox GL Native QML plugin
@Zeta and @tmi: thank you very much for testing!
Its indeed seems to be hard to debug this one. Since there were stability issues with earlier tests using static stdc++, I'll look into how to provide dynamic build for the plugin. Maybe it will help, although hard to tell. After testing dynamic builds (if I manage to make them), we could ask give a proper feedback to Mapbox GL developers for further tips. Meanwhile I tested the MapboxMap using raster tile sources and it worked quite well. The small blurring that I saw on the desktop was much harder to spot on hiDPI device (you have to really look for it). While I am sure that vector tiles would be preferred, already now the MapboxMap should allow you to mix the sources as you wish. |
Re: Mapbox GL Native QML plugin
Zeta, just in case if the shared stdc++ is better, please try to run with QML plugin from https://build.merproject.org/package...g/mapboxgl-qml
This version is compiled with shared libstdc++ with the corresponding library installed at /usr/lib/qt5/qml/MapboxMap . Now before I'll be breaking my neck and figuring out how to explain to qmlscene that the libs from that directory have a preference, please run with Code:
LD_LIBRARY_PATH=/usr/lib/qt5/qml/MapboxMap qmlscene mapbox-gl-qml.qml If its the same result as with the statically linked stdc++, I'll prefer to use that version. Then, before moving back to the statically linked plugin, please uninstall plugin first. Otherwise you'll leave libstdc++ in the plugin directory. |
Re: Mapbox GL Native QML plugin
Quote:
* Works perfectly with red map * Crash when zooming in/moving fast the normal map However, that must be the first useful error message I got since the start of those tests: Code:
[nemo@Sailfish test]$ LD_LIBRARY_PATH=/usr/lib/qt5/qml/MapboxMap /usr/lib/qt5/bin/qmlscene mapbox-gl-qml.qml Anyone knows a command to follow GPU memory available/used ? |
Re: Mapbox GL Native QML plugin
Zeta, great catch!!!! At least, we could ask for advice now from Mapbox GL developers. Do you want to submit your findings into the issue https://github.com/mapbox/mapbox-gl-native/issues/10029 ?
But would be great to know how to follow GPU memory state, indeed... |
Re: Mapbox GL Native QML plugin
Quote:
|
Re: Mapbox GL Native QML plugin
I have extended cache database handling API to support the expected scenario:
In practice, when defining MapboxMap, its sufficient to set Code:
cacheDatabaseStoreSettings: true API documentation has been updated accordingly. I am planning to start working on offline support for these vector tiles via OSM Scout Server. When issues/requests/ideas will come, I'll work on them as well. Let me know in advance if you wish to use the plugin in practice, I'll upload it into OpenRepos when needed. There is no point in uploading it too early - there were changes almost daily so far in plugin code :) |
Re: Mapbox GL Native QML plugin
As you can see at the end of https://github.com/mapbox/mapbox-gl-native/issues/10029 , Mapbox GL developer suggested that MapboxGL hits memory bottleneck on Jolla 1.
Unfortunately, the callbacks designed to help with the debugging of openGL errors were introduced only in the latest standard, not available for J1 either. So, if you needed an excuse to go out and get a newer device for SFOS - here it is. |
Re: Mapbox GL Native QML plugin
Quote:
Quote:
|
Re: Mapbox GL Native QML plugin
Quote:
To debug properly, we need OpenGL ES API Version 3.2 and use https://www.khronos.org/registry/Ope...Callback.xhtml (blog post continuation) Alternatively, you could use glGetError, as explained in the blog post. As for API versions, OpenGL ES 3.0 corresponds to Android 4.3 (https://en.wikipedia.org/wiki/OpenGL_ES) So, out of luck here as well on older devices like J1 |
Re: Mapbox GL Native QML plugin
Quote:
Interesting to see that debugging is a first class citizen on the newer versions. |
Re: Mapbox GL Native QML plugin
Short update after 1.5 month of silence:
I have been working all this time on importing the planet into Mapbox GL format to offer offline support for this widget. Turned out to be a major undertaking due to the lack or scattered documentation, rather sub-optimal import tools and large CPU requirements. After struggling with the available tools/scripts, I ended up writing my own on the basis of OpenMapTiles schema: https://github.com/rinigus/mapbox-gl-importer As it is, the planet got imported yesterday night and I can confidently say that the offline support for Mapbox GL tiles is coming as well via OSM Scout Server. There is still some code to be written, but I don't foresee any blocking issues on the way. As for vector tile schema, it will probably change in time. Already now there are slight deviations from OpenMapTiles schema to optimize import and I can see that few POIs are missing on the maps. I will document all the differences in due time. Most probably we will optimize the schema in time for our needs. |
Re: Mapbox GL Native QML plugin
Would following https://github.com/rinigus/mapbox-demo-sfos as an example be okay for a project? trying to make a uber port atm
|
Re: Mapbox GL Native QML plugin
Quote:
Simplest demo at https://github.com/rinigus/mapbox-de...y/MainPage.qml Some other demos to consider: Shows how to add your own data to the map (roads, points), add interactive elements: https://github.com/rinigus/mapbox-gl...p/qml/main.qml Full Poor Maps port to Mapbox GL is at https://github.com/rinigus/poor-maps/tree/gl . This is an application that I am using and may have some additional tips on how to make things in practice. Please don't hesitate to ask, I'll try to reply within a day. |
Re: Mapbox GL Native QML plugin
ill try it out tomorrow ta :)
|
Re: Mapbox GL Native QML plugin
hmmm ive installed both opt-gcc6 and qmapboxgl but it still refuses to find the packages, for i486
Quote:
not sure if ive missed anything project is here https://github.com/ghosalmartin/harbour-uber ah ignore me I wasnt installing with Quote:
|
Re: Mapbox GL Native QML plugin
Quote:
not quite sure whats wrong there, maybe something wrong in gcc6 setup. ill take another look tomorrow morning |
Re: Mapbox GL Native QML plugin
Quote:
I would suggest to install https://build.merproject.org/package...s/mapboxgl-qml and just use MapboxMap together with the gesture area as in https://github.com/rinigus/mapbox-de...y/MainPage.qml . Then you don't even need to include MapboxGL as a submodule, can use regular gcc, and its all very simple. mapboxgl-qml would register the module in the system and all should just work. Please report bugs if it doesn't. C++ way, as you did, is also possible, but more complicated and will lead to all apps having different versions of the plugin (since you are compiling it in) and would end up having larger requirements in the root partition (everyone installing plugin under their /usr/share/harbour... folder). Note that QMaboxGL (which plugin interfaces), requires QLocation. So, there is no-go into Jolla Harbour until its allowed (Jolla's soon^TM comes into mind). So, I would suggest to go via QML plugin installation, enjoy programming and using it! As for the error that you get, I think you are very close. You seem to miss c++14 in PRO configuration file, as I can deduce from compile messages. See https://github.com/rinigus/mapbox-de...x-sfos.pro#L15 |
Re: Mapbox GL Native QML plugin
Quote:
I just realised thanks to your gcc6 work I can use Slacks c++ library as well :P hmmm so I've done what you said but the qml component still can't be found :/ |
Re: Mapbox GL Native QML plugin
hmm was missing the import and added it so MapboxMapGestureArea is recognised but not MapboxMap
|
Re: Mapbox GL Native QML plugin
Quote:
https://github.com/ghosalmartin/harb...-uber.yaml#L38 Namely, you need to have this package installed on device (or emulator) where you run the code, not just build. Looking into it, I am missing it as well in Poor Maps port to MapboxGL. I just happened to have this package installed on my device... |
Re: Mapbox GL Native QML plugin
yep working well ta :) theres a ide error but map loads fine :D
|
Re: Mapbox GL Native QML plugin
Quote:
* as mentioned earlier, planet imported * added support for Mapbox GL styles, fonts (glyphs), and icons (sprite). * added support for distribution of tiles, fonts, styles, and icons This means that all the main parts are in place, now I need to hook it all to GUI and test on device. After that, testing and releases with increased amount of polish :) |
Re: Mapbox GL Native QML plugin
Quote:
|
Re: Mapbox GL Native QML plugin
As of today, offline support for Mapbox GL vector tiles has been released as a part of OSM Scout Server and the first full-blown application using the widget has been released as a temporary fork of Poor Maps. So, it should be possible to use it daily and the infrastructure for this maps widget is all in place.
|
Re: Mapbox GL Native QML plugin
Quote:
|
Re: Mapbox GL Native QML plugin
Quote:
From my understanding, location can be provided by many different sources and its up to Qt configuration to deal with such details as GPS lock. We can just use the data as given and not worry whether it was obtained via GPS or some other technique. |
Re: Mapbox GL Native QML plugin
Looking on how modRana does it (warning: modRana does some extra stuff there so the code is ore complex than necessarily needed) & trying to remember how I programmed it:
That seems to work reasonably well. But it also depend how you define "has a fix" as by default the location backend on Sailfish OS first uses data from the mobile network and WiFi to get a rough position estimate while getting and actual GPS lock. This is why you might see you position jump every 30 seconds for tens or hundreds of meters before it actually starts to track you position. It's the location backend sending data about local WiFi access points every 30 seconds to estimate your position while GPS is still acquiring the GPS lock. The Info -> Location page in modRana displays detailed location data and you can nicely see the location converge from WiFi estimation to GPS fix there. :) |
Re: Mapbox GL Native QML plugin
Quote:
|
Re: Mapbox GL Native QML plugin
Quote:
I am following your instructions but there is an error when opening the map page: Code:
[ERROR] {QSGRenderThread}[Setup]: loading style failed: Problem with the SSL CA cert (path? access rights?): error setting certificate verify locations: - installed mapboxgl-qml-1.1.0-10.27.1.jolla.armv7hl.rpm on the device (Oneplus X) - took your basic example from here Maybe there is a problem with the access token? |
Re: Mapbox GL Native QML plugin
Quote:
For now, you could use OSM Scout Server. For that, install it, configure for use of Mapbox GL tiles by selecting a profile with the vector tiles, download the region of interest and replace style URL in the simple example by http://localhost:8553/v1/mbgl/style?style=osmbright That should make it possible to use and test the widget. The access key is not required then, but you could just keep it as it is. |
Re: Mapbox GL Native QML plugin
Looks like an issue is in HTTPS certs. Namely, it seems not to find the certificates needed for HTTPS access to Mapbox. I don't know whether they just now switched to HTTPS or not, but I can get Poor Maps GL working by
* download https://raw.githubusercontent.com/ba.../ca-bundle.crt * in the directory where ca-bundle.crt is stored, run sailfish-qml harbour-poor-maps-gl Now I wonder, whether it happened when I moved QMapboxGL plugin to libcurl or was anyone able to access Mapbox online maps AFTER updating mapbox-qml plugin to 1.1.0? The simple example QML that I posted seems still need some additional Silica wrapper. While it nicely downloads all required maps/fonts when started from directory with the certificates (as shown using urlDebug switch), map is not displayed and it complains about the absence of __silica_applicationwindow_instance. So, don't forget to wrap it into some Silica app QMLs. PS I will look into the certificate problem and resolve it within few days |
Re: Mapbox GL Native QML plugin
OK thanks, I will try to make it work with OSM Scout server. Just a few more questions:
- Jolla 1 won't work with MapBox, right? - OSM Scout Server: user has to decide if he wants to keep the classic map or a vector map for MapBox. Is it possible to keep both maps on the phone (although that would need very much space on the SD card)? - if I want to release my app with the MapBox QML component, the users also need mapboxgl-qml-1.1.0-10.27.1.jolla.armv7hl.rpm on their devices. How can I deliver it to them? Do they have to install it manually? - does a user of my app need to enter his own token for MapBox? |
Re: Mapbox GL Native QML plugin
Quote:
Quote:
Quote:
So, you could ask them to add my repository into their list of repositories and add mapboxgl-qml (name of the package) as dependency. This is probably the best way since it allows them to get the latest version with the bugs fixed (as the one I am fixing now). The package is built at OBS, so they or you can take it from there (https://build.merproject.org/package...s/mapboxgl-qml). You could also add this package into your repository. But that would require that you would be updating it as well. Quote:
However, there are alternatives. In addition to OSM Scout Server, @otsaloma setup his own server as a part of Poor Maps package. You could ask him for access key and suggest users to donate to him for this service. In addition, there are also other providers for map tiles which have free tier as well (Mapzen, for example). And an update regarding the SSL bug. Looks like I missed testing online sources when we were searching for solution for localhost connection in offline mode. When switched to CURL-based downloads, the online sources broke if they use HTTPS. Its caused by adding hard-coded certificate file by Mapbox GL (https://github.com/mapbox/mapbox-gl-...ource.cpp#L249). In our phones (and on my Linux PC), the file with such name is missing. Now I am testing a patch without this hard-coded filename and checking if the default libcurl settings are good enough. On PC, it fixed an issue. On phone, I'll learn later tonight. |
Re: Mapbox GL Native QML plugin
Quote:
|
Re: Mapbox GL Native QML plugin
Quote:
If you take Poor Maps GL as an example, I can add POIs (dots with text), route as a line, and widgets that will follow geo-location of the point of interest. I'll copy-and-paste description of it from OSM Scout Server thread: Example codes:
Vector maps are different from raster in the interactivity with them, you can insert/remove/modify your objects. So, API has to be richer than before. To learn, I would suggest to
How well does the learning process go, I don't know. I am pretty sure @jdrescher and maybe others can tell better from their experience. In particular, where do we have to document more or better. |
Re: Mapbox GL Native QML plugin
Bugfix release published, please update on OpenRepos (https://openrepos.net/content/rinigu...indings-qt-qml). Online and offline servers should work now, as intended. Please let me know if it fixed for you as well and surely report issues that you have with the widget.
|
All times are GMT. The time now is 14:06. |
vBulletin® Version 3.8.8