Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Working towards GlyphAtlas safety - #995

Merged
jfirebaugh merged 5 commits into
masterfrom
957-glyph-atlas
Mar 13, 2015
Merged

jfirebaugh merged 5 commits into
masterfrom
957-glyph-atlas

Conversation

@jfirebaugh

Copy link
Copy Markdown
Contributor

Refs #957

First part: move atlas ownership to Style. This follows gl-js and just makes sense -- whenever the style changes the atlases should be blown away.

@kkaefer, is it safe yet to pass Style by reference into Source::update ⇢ VectorTileData ⇢ TileParser as I've done here? I'm still not clear on what parts are running in a different thread that's not guaranteed to be shut down before the Style is deallocated. If this isn't safe I can fall back to a shared_from_this solution.

Second part: Index glyph use by tile pointer value, not tile ID. There can be multiple tiles with the same ID, but from different sources.

@incanus

incanus commented Mar 13, 2015

Copy link
Copy Markdown
Contributor

Awesome, this totally solves my use case (which you can try via https://gist.github.com/incanus/43d0faa730347a3a5d01 BTW; start in DC at z10 or higher).

@kkaefer

kkaefer commented Mar 13, 2015

Copy link
Copy Markdown
Member

is it safe yet to pass Style by reference into Source::update ⇢ VectorTileData ⇢ TileParser as I've done here?

I don't think it is right now. If the user changes the Stylesheet, we'll destruct the current stylesheet and swap it with another one. This is the reason we've held the Style object as a shared_ptr so far. However, this isn't a good solution either. Instead, we should abort all tile parsing (not sure if there's a good way to do this quickly) since we won't need the old parsed tiles anyway when switching the style.

@mb12

mb12 commented Mar 13, 2015

Copy link
Copy Markdown

The following approach should work in the current start/stop scheme.

We can store a weak Style pointer. Before using it any time convert it to a shared pointer using weak_ptr.lock(). If the Style object is destroyed in Map::stop, this conversion would fail and return a nullptr. However this also means that any data member in Style object should not be cached in other classes. Any time a data member of Style needs to be accessed, it would have to be done via .lock() on this weak_ptr.

This follows gl-js and just makes sense -- whenever the style changes
the atlases should be blown away.

Refs #957
There can be multiple tiles with the same ID, but from different
sources.

Fixes #957
@jfirebaugh

Copy link
Copy Markdown
Contributor Author

I'd prefer to figure out how to abort all asynchronous operations before deallocating the style, rather than a weak-pointer based solution.

For now I just reverted to shared pointers and shared_from_this().

@jfirebaugh

Copy link
Copy Markdown
Contributor Author

Build failure is likely unrelated to this change. Ticketed: #1001, going to merge.

@jfirebaugh
jfirebaugh merged commit 6325f1e into master Mar 13, 2015
@jfirebaugh
jfirebaugh deleted the 957-glyph-atlas branch March 13, 2015 19:20
@jfirebaugh

Copy link
Copy Markdown
Contributor Author

I spoke too soon, the glyph atlas ownership changes looked like they were destabilizing. I backed them out in 0c985c0 and will open a refactoring ticket for post-beta.

@incanus

incanus commented Mar 13, 2015

Copy link
Copy Markdown
Contributor

Just to clarify, because I wanted to be sure, backing out that change in 0c985c0 doesn't affect the bug fix for my setup, which I believe is addressed by 6325f1e and remains in master.

@incanus incanus mentioned this pull request Mar 15, 2015
6 of 7 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants