Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make symbol placement information transferrable between workers #2624

Merged
merged 3 commits into from
Jun 6, 2016

Conversation

mollymerp
Copy link
Contributor

@mollymerp mollymerp commented May 25, 2016

first step in the quest to make cross-source label placement a reality! re: #2516

next actions:

  • code review @lucaswoj @ansis
  • tests! I have no idea how to do this, so I will spend some time poking around the existing tests and try to crib from those to make sure the correct data is getting transferred. this is basically a refactor, no new functionality to test
  • create a process to transfer the symbol_buffer data to a new worker where it could be processed together with symbol_buffers from other sources using placeFeatures() at that time.

also:

  • does it make sense to pass -1 as the index for the symbolquads that do not exist in a tile?
return this.symbolInstancesBuffer.emplaceBack(
     startGlyphIndex || -1,
     endGlyphIndex || -1,
     iconQuadIndex || -1,
     symbolInstance.x,
     symbolInstance.y,
     symbolInstance.index);
  • similarly, I was getting symbol buckets that had neither glyphs or icons... why would that be happening? or am I missing something?

@@ -29,6 +29,8 @@ function SymbolBucket(options) {
this.showCollisionBoxes = options.showCollisionBoxes;
this.overscaling = options.overscaling;
this.collisionBoxArray = options.collisionBoxArray;
this.symbolQuadsBuffer = options.symbolQuadsBuffer;
this.symbolInstancesBuffer = options.symbolInstancesBuffer;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call these Arrays instead of Buffers? We generally use the term Buffer exclusively in the context of a WebGL buffer (though I'd like to phase that out too)

@lucaswoj
Copy link
Contributor

This is looking great! The code is tight and idiomatic. I made a couple superficial comments and am feeling 👍 about the direction here.

@mollymerp mollymerp force-pushed the transferrable-symbol-buffer branch from 387a23a to c68e579 Compare May 25, 2016 19:09
@mollymerp
Copy link
Contributor Author

getting some interesting rendering test failures 💭

screen shot 2016-05-25 at 5 36 52 pm

@lucaswoj
Copy link
Contributor

Try re-installing mapbox-gl-test-suite. I've seen that failure when using v1 tiles with earcut.

rm -rf node_modules/mapbox-gl-test-suite && npm install

@mollymerp
Copy link
Contributor Author

Ah yep, that was it @lucaswoj!

@ansis
Copy link
Contributor

ansis commented May 31, 2016

Looks good

does it make sense to pass -1 as the index for the symbolquads that do not exist in a tile?

It might be nice to not need a special value for the empty case. Sync the startGlyphIndex and endGlyphIndex represent a range, there are no elements if both values are the same. For example, if the start index is 52 and the end index is 52 then there are zero things between 52 and 52.

similarly, I was getting symbol buckets that had neither glyphs or icons... why would that be happening? or am I missing something?

It could be that the tile doesn't have any features matching the bucket's filter.


A good next step would be to get rid of the original symbolInstances array completely and use the new struct array version in placeFeatures

@mollymerp mollymerp force-pushed the transferrable-symbol-buffer branch from b58061c to 3f4d3a2 Compare June 3, 2016 01:32
@mollymerp
Copy link
Contributor Author

mollymerp commented Jun 3, 2016

Update:
As @ansis suggested, I'm refactoring to allow the total removal of the symbolInstances array to remove data duplication.

Seems like the sort function I implemented for the StructArray for placement of overlapping symbols isn't working. Also the render tests make me think that tile boundary clipping isn't working as expected.

Also, I think I should treat the texture varables in the symbolQuadArray as floats because the hamburgers look funny and I think it has to do with imprecise texture coordinates? 💭

@mollymerp mollymerp force-pushed the transferrable-symbol-buffer branch from f5b4a64 to 75032c5 Compare June 3, 2016 02:44
@mollymerp
Copy link
Contributor Author

mollymerp commented Jun 3, 2016

I fixed the sort issue, and all but 2 of the remaining render tests pass if I set all the anchor point offset variables (tl, tr, bl, br) in the structArray to Float32 so I can either update the render tests to match this loss of precision, or keep the floats.

The tests that still fail are symbol-placement point and symbol-visibility visible

@lucaswoj
Copy link
Contributor

lucaswoj commented Jun 3, 2016

What is the downside to setting the anchor point offset variables to Float32?

@mollymerp mollymerp force-pushed the transferrable-symbol-buffer branch from 343d93a to 6496115 Compare June 3, 2016 18:18
@mollymerp
Copy link
Contributor Author

mollymerp commented Jun 3, 2016

@lucaswoj I'm not sure what the downside is, but I would guess it has to do with memory usage and/or speed of transfer from worker --> main thread. I ran all the bench marking tests and didn't get any warnings. Looks like it got significantly faster actually.
Buffer bench on master: 1,132 ms
Buffer bench on this branch: 830ms

The last remaining piece of this puzzle is figuring out why cross-tile collision detection is not working
screen shot 2016-06-03 at 11 15 49 am

more art:
master
screen shot 2016-06-03 at 1 33 40 pm
this branch
screen shot 2016-06-03 at 1 32 15 pm

I have a feeling it has to do with the fact that we're not passing a true CollisionFeature to the functions CollisionTile.placeCollisionFeature and CollisionTile.insertCollisionFeature but I haven't figured out how :(

@mollymerp
Copy link
Contributor Author

Seems to be an issue with how the CollisionTile.grid is being populated. The fully populated grids on this branch have fewer keys and bboxes than those on master. When I console collisionTile.grid in the done () function in WorkerTile I get very different resultant grids:

master
screen shot 2016-06-03 at 4 56 22 pm

this branch
screen shot 2016-06-03 at 4 56 28 pm

😭

@mollymerp mollymerp force-pushed the transferrable-symbol-buffer branch from 37ba3c7 to 6d3923f Compare June 6, 2016 22:01
}
});

map.addLayer({
"id": "route",
"type": "line",
"source": "geojson",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert your changes to this file

Molly Lloyd added 3 commits June 6, 2016 15:53
…Instances and SymbolQuads

create SymbolInstancesArray StructArrayType

add symbolinstances and quads to struct arrays

populate symbolInstanceBuffer and symbolQuadsBuffer

transfer symbol buffers from worker --> main thread

add symbolInstances and symbolQuads to tile.js
…ransferred back to the worker

transferrable-symbol-buffer: refactor placeFeatures to use the structArrays

add tex getter to symbol_quads StructArrayType

add sort method to StructArray in order to sort overlapping symbols during label placement

store structArray info for placeFeatures

use structArray to render labels -- collision detection not working

fix typo in collision boxes

move sorting function, handle overlaps

fix symbolQuad sort

remove all this.symbolInstances array completely, change offset coordinates to Float32

fix formatting
…e the structArrays only to place symbol features on the map

revert debug page

rearrange methods for converting a StructArray into an array of StructTypes
@mollymerp mollymerp force-pushed the transferrable-symbol-buffer branch from 5a51853 to e268120 Compare June 6, 2016 22:56
@mollymerp mollymerp changed the title [wip] transferrable symbol buffer make symbol placement information transferrable between workers Jun 6, 2016
@mollymerp mollymerp merged commit e268120 into master Jun 6, 2016
@mollymerp mollymerp deleted the transferrable-symbol-buffer branch June 6, 2016 23:31
@jfirebaugh jfirebaugh mentioned this pull request Oct 28, 2016
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants