Code Monkey home page Code Monkey logo

Comments (3)

rinigus avatar rinigus commented on May 26, 2024

I agree, there is a delay which, while short, is sometimes observable by the user. And it should be reduced as much as possible.

The delay is essentially caused by the fact that QMapboxGL "lives" in a thread (or threads) that is different from the GUI thread. So, wherever we want to get something out of Mapbox GL, we need to send signals between threads, one for request from GUI to OpenGL rendering and one back to the GUI.

In case of the bubbles with the WhoGo example:

  • On click, MapboxMapGestureArea requests queryCoordinateForPixel from the map object.

  • queryCoordinateForPixel is a signal that is sent over queued connection to QSGMapboxGLTextureNode and activates OpenGL rendering update to wakeup the thread where QSGMapboxGLTextureNode is.

  • QSGMapboxGLTextureNode calculates the result and emits replyCoordinateForPixel back to GUI thread via queued connection.

  • replyCoordinateForPixel is received by MapboxMapGestureArea and forwarded to the main code via emitted clickedGeo. The latter signal should be direct (aka fast) since it is in the same thread.

  • clickedGeo is followed by WhoGo maps and, on receiving it, there is a loop that runs through all POIs to check if any of them was clicked.

As you could see, there is some processing involved and some of the delays could be induced due to
connections between threads. I am not sure whether I can significantly reduce for occasional click. But for POIs that we know beforehand, maybe its possible to figure out something.

We do have location tracking facility. However, I doubt that it maybe too expensive to keep an eye on all POIs at each frame refresh.

I'll think what I can do to reduce the delay.

from mapbox-gl-qml.

otsaloma avatar otsaloma commented on May 26, 2024

Sounds complicated. I figured it was due to the separation, but was hoping there was maybe something simple like a polling frequency. Have you checked how QtLocation's Mapbox GL plugin handles this?

We do have location tracking facility. However, I doubt that it maybe too expensive to keep an eye on all POIs at each frame refresh.

It could be done so that each frame refresh would just mark the map as changed and a timer would run e.g. every 500 ms and update the tracking cache if the map is changed. Then if the user waits that 500 ms between panning and tapping, which is likely to be the usual case, it would work fast, otherwise as currently. But, of course, that would likely require app-specific code, so it's probably more a workaround than a fix.

from mapbox-gl-qml.

rinigus avatar rinigus commented on May 26, 2024

Not much I can do about it; closing

from mapbox-gl-qml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.