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

Commit

Permalink
Handling GeometryTileWorker edge cases:
Browse files Browse the repository at this point in the history
 - If redoLayout completes without a placementConfig, move to NeedPlacement
 - If setPlacementConfig called while in NeedPlacement, attemptPlacement
 - If setPlacementConfig called while in NeedLayout and there are not other dependencies, attemptPlacement

The idea with these changes is that waiting on the first placementConfig is essentially similar to a symbol dependency, and we need to make sure we do layout/placement in response to it being satisfied. However, we only want to trigger activity the first time, to avoid short circuiting the coalescing logic.

 - Don't re-trigger layout when symbol dependencies arrive unless all of our prior dependencies have been satisfied first

This avoids a case where we can have multiple "different" sets of dependencies in flight at the same time, and we could end up rendering with the wrong set.
  • Loading branch information
ChrisLoer committed Mar 31, 2017
1 parent ad286ec commit d174da6
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/mbgl/tile/geometry_tile_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ void GeometryTileWorker::setLayers(std::vector<std::unique_ptr<Layer>> layers_,

void GeometryTileWorker::setPlacementConfig(PlacementConfig placementConfig_, uint64_t correlationID_) {
try {
bool firstPlacement = !placementConfig;
placementConfig = std::move(placementConfig_);
correlationID = correlationID_;

Expand All @@ -135,7 +136,14 @@ void GeometryTileWorker::setPlacementConfig(PlacementConfig placementConfig_, ui
break;

case NeedPlacement:
if (firstPlacement) {
attemptPlacement();
}
break;
case NeedLayout:
if (firstPlacement && !hasPendingSymbolDependencies()) {
redoLayout();
}
break;
}
} catch (...) {
Expand Down Expand Up @@ -196,7 +204,12 @@ void GeometryTileWorker::coalesced() {
break;

case NeedLayout:
redoLayout();
if (!hasPendingSymbolDependencies()) {
// Don't re-trigger layout if we have outstanding symbol dependencies
// Redoing layout could invalidate the outstanding dependencies, but
// when they arrived we would treat them as valid
redoLayout();
}
break;

case NeedPlacement:
Expand Down Expand Up @@ -234,7 +247,6 @@ bool GeometryTileWorker::hasIconDependencies(const IconDependencyMap &iconDepend

void GeometryTileWorker::redoLayout() {
if (!data || !layers) {
// Waiting for initial configuration
return;
}

Expand Down Expand Up @@ -333,7 +345,7 @@ void GeometryTileWorker::redoLayout() {
correlationID
});

if (hasPendingSymbolDependencies()) {
if (!placementConfig || hasPendingSymbolDependencies()) {
state = NeedPlacement;
} else {
attemptPlacement();
Expand Down

0 comments on commit d174da6

Please sign in to comment.