Notices


Reply
Thread Tools
Posts: 52 | Thanked: 195 times | Joined on Apr 2017 @ Germany
#51
@rinigus is there a way to refresh the map after the style was changed?
 

The Following 2 Users Say Thank You to jdrescher For This Useful Post:
Posts: 480 | Thanked: 2,287 times | Joined on Aug 2016 @ Estonia
#52
Originally Posted by jdrescher View Post
@rinigus is there a way to refresh the map after the style was changed?
You shouldn't need to do anything, just specify new style with styleJson or styleUrl and it should update itself automatically. Same goes for new layers, data, ...

For example, see https://github.com/rinigus/poor-maps...l/Map.qml#L654

If it doesn't work, please show example.
 

The Following 3 Users Say Thank You to rinigus For This Useful Post:
Posts: 52 | Thanked: 195 times | Joined on Apr 2017 @ Germany
#53
I have a problem in my app regarding the mapbox plugin.

After loading an autosave file, I would go through all recorded positions and then add each coordinate to an array. You can see the for statement in line 118.
Then in line 632, I would add each coordinate point to the map track.

And this line 632 is the problem. If the autosave is big enough e.g. >7000 coordinate points, the app will crash. Sometimes my phone even reboots then. Do you have an idea what could cause the problem?
 

The Following User Says Thank You to jdrescher For This Useful Post:
Posts: 480 | Thanked: 2,287 times | Joined on Aug 2016 @ Estonia
#54
Originally Posted by jdrescher View Post
I have a problem in my app regarding the mapbox plugin.

After loading an autosave file, I would go through all recorded positions and then add each coordinate to an array. You can see the for statement in line 118.
Then in line 632, I would add each coordinate point to the map track.

And this line 632 is the problem. If the autosave is big enough e.g. >7000 coordinate points, the app will crash. Sometimes my phone even reboots then. Do you have an idea what could cause the problem?
Without digging too deep into the code - do you add each point as a separate layer or all points go as a vector into a single layer? So, whether you end up having 7000 layers or just few with many points?
 

The Following User Says Thank You to rinigus For This Useful Post:
Posts: 52 | Thanked: 195 times | Joined on Apr 2017 @ Germany
#55
Originally Posted by rinigus View Post
Without digging too deep into the code - do you add each point as a separate layer or all points go as a vector into a single layer? So, whether you end up having 7000 layers or just few with many points?
I use a single layer. This is the place where the layer is created:
Code:
//Start new trackline here
//Create fresh temp line array
vLineArray = [];
//Write first coordinate of new track segment to line array
vLineArray.push(coordinate);
//Save that to global array
vTrackLinePoints = vLineArray;

sTrackLine = "lineTrack" + iPausePositionsIndex.toString();

//We have to create a track line here.
map.addSourceLine(sTrackLine, vTrackLinePoints)
map.addLayer("layerTrack" + iPausePositionsIndex.toString(), { "type": "line", "source": sTrackLine })
map.setLayoutProperty("layerTrack" + iPausePositionsIndex.toString(), "line-join", "round");
map.setLayoutProperty("layerTrack" + iPausePositionsIndex.toString(), "line-cap", "round");
map.setPaintProperty("layerTrack" + iPausePositionsIndex.toString(), "line-color", "red");
map.setPaintProperty("layerTrack" + iPausePositionsIndex.toString(), "line-width", 2.0);
Then every new coordinate is pushed to the array vTrackLinePoints. And then I use
Code:
updateSourceLine
to redraw the track line:
Code:
//Create temp line array and set current points array to it. Must use a JS array here necause QML arrays don't allow for push!
vLineArray = vTrackLinePoints;
//Write first coordinate to line array
vLineArray.push(coordinate);
//Save that to global array
vTrackLinePoints = vLineArray;

map.updateSourceLine(sTrackLine, vTrackLinePoints);
 

The Following User Says Thank You to jdrescher For This Useful Post:
Posts: 480 | Thanked: 2,287 times | Joined on Aug 2016 @ Estonia
#56
Originally Posted by jdrescher View Post
I use a single layer. This is the place where the layer is created:
Code:
//Start new trackline here
//Create fresh temp line array
vLineArray = [];
//Write first coordinate of new track segment to line array
vLineArray.push(coordinate);
//Save that to global array
vTrackLinePoints = vLineArray;

sTrackLine = "lineTrack" + iPausePositionsIndex.toString();

//We have to create a track line here.
map.addSourceLine(sTrackLine, vTrackLinePoints)
map.addLayer("layerTrack" + iPausePositionsIndex.toString(), { "type": "line", "source": sTrackLine })
map.setLayoutProperty("layerTrack" + iPausePositionsIndex.toString(), "line-join", "round");
map.setLayoutProperty("layerTrack" + iPausePositionsIndex.toString(), "line-cap", "round");
map.setPaintProperty("layerTrack" + iPausePositionsIndex.toString(), "line-color", "red");
map.setPaintProperty("layerTrack" + iPausePositionsIndex.toString(), "line-width", 2.0);
Then every new coordinate is pushed to the array vTrackLinePoints. And then I use
Code:
updateSourceLine
to redraw the track line:
Code:
//Create temp line array and set current points array to it. Must use a JS array here necause QML arrays don't allow for push!
vLineArray = vTrackLinePoints;
//Write first coordinate to line array
vLineArray.push(coordinate);
//Save that to global array
vTrackLinePoints = vLineArray;

map.updateSourceLine(sTrackLine, vTrackLinePoints);
I do wonder how can I help with debugging it... Is there any trace available that I can try to load?

sTrackLine = "lineTrack" + iPausePositionsIndex.toString();

seems to suggest that there are several layer tracks or is iPausePositionsIndex always the same?
 

The Following User Says Thank You to rinigus For This Useful Post:
Posts: 480 | Thanked: 2,287 times | Joined on Aug 2016 @ Estonia
#57
And one more question: does it mean that you call updateSourceLine 7000 times (once per each point) during startup or is it all factored into one call?
 

The Following User Says Thank You to rinigus For This Useful Post:
Posts: 52 | Thanked: 195 times | Joined on Apr 2017 @ Germany
#58
Originally Posted by rinigus View Post
And one more question: does it mean that you call updateSourceLine 7000 times (once per each point) during startup or is it all factored into one call?
That's correct, 7000 times during startup. And then somewhere in between it gets stuck and crashs.

While during workout it is called once every second. And it seems that this also leads to the crash after 2 hours or something.

You know, I think the amount of calls of the updatesourceline function is limited. Maybe it helps to split the track points to multiple layers of track lines. I will do some more tests tomorrow.

Last edited by jdrescher; 2018-01-08 at 20:18.
 

The Following 2 Users Say Thank You to jdrescher For This Useful Post:
Posts: 480 | Thanked: 2,287 times | Joined on Aug 2016 @ Estonia
#59
Originally Posted by jdrescher View Post
That's correct, 7000 times during startup. And then somewhere in between it gets stuck and crashs.

While during workout it is called once every second. And it seems that this also leads to the crash after 2 hours or something.

You know, I think the amount of calls of the updatesourceline function is limited. Maybe it helps to split the track points to multiple layers of track lines. I will do some more tests tomorrow.
I have added your case as an issue at https://github.com/rinigus/mapbox-gl-qml/issues/28

Its suggests memory leak somewhere and I'll look into it. Note that maybe you could refactor your startup calls into one. Namely, there are several threads involved in this widget - GUI thread and OpenGL threads - that have to communicate to transfer data from QML to Mapbox GL. As a result, all add/update/... are first accumulated in a stack by GUI thread and then played back through Mapbox GL functions when Qt gives allows OpenGL rendering to run. So, I wouldn't be surprised if these 7000 calls are waiting in the stack until you finish init of your QML code. From the design point of view, I would suggest to call with the full data if you have it already anyway.

As for a crash during workout, that's not too good either. Please don't split the data into several smaller layers, its better than I fix it on the widget side properly. At least give me a chance to work on it first before we start doing workarounds for bugs. So, with the workout part, maybe put deltaT for data saving for 3 seconds, or run faster, or just accept crashes for time being.

I will look into this issue this week. I am preparing new maps (generating tiles right now) for uploads and can work on Mapbox GL as well. But it may take few days to find the source for it and I would have to get it crashing on my device first as well.
 

The Following 4 Users Say Thank You to rinigus For This Useful Post:
Posts: 52 | Thanked: 195 times | Joined on Apr 2017 @ Germany
#60
Originally Posted by rinigus View Post
Note that maybe you could refactor your startup calls into one.
I already did this and it works. The startup issue is solved with this solution.

Originally Posted by rinigus View Post
or run faster


Originally Posted by rinigus View Post
But it may take few days to find the source for it and I would have to get it crashing on my device first as well.
Thanks for looking into that. I will do no workarounds for the during workout issue and wait what you come up with.
 

The Following 3 Users Say Thank You to jdrescher For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 00:05.