Improve tile lifecycle determinism (#2819)
This commit is contained in:
@@ -1698,6 +1698,12 @@ TEST(Map, ObserveTileLifecycle) {
|
||||
};
|
||||
std::mutex tileMutex;
|
||||
std::vector<TileEntry> tileOps;
|
||||
// We expect to see a valid lifecycle for every tile in this list.
|
||||
const std::vector<OverscaledTileID> expectedTiles = {
|
||||
{10, 0, 10, 163, 395}, {10, 0, 10, 163, 396}, {10, 0, 10, 164, 395}, {10, 0, 10, 164, 396},
|
||||
// Lower zooms can also be seen, but not always, so we
|
||||
// ignore them.
|
||||
};
|
||||
|
||||
struct ShaderEntry {
|
||||
shaders::BuiltIn id;
|
||||
@@ -1762,17 +1768,14 @@ TEST(Map, ObserveTileLifecycle) {
|
||||
}
|
||||
}
|
||||
|
||||
// We expect to see a valid lifecycle for every tile in this list.
|
||||
const std::vector<OverscaledTileID> expectedTiles = {
|
||||
{10, 0, 10, 163, 395}, {10, 0, 10, 163, 396}, {10, 0, 10, 164, 395}, {10, 0, 10, 164, 396},
|
||||
// Lower zooms can also be seen, but not always, so we
|
||||
// ignore them.
|
||||
};
|
||||
|
||||
for (const auto& tile : expectedTiles) {
|
||||
TileOperation stage = TileOperation::NullOp;
|
||||
bool parsing = false;
|
||||
|
||||
for (const auto& op : tileOps) {
|
||||
// Suppressing warning-as-error to use range-based for. Index is desired for debugging context.
|
||||
// NOLINTNEXTLINE
|
||||
for (size_t i = 0; i < tileOps.size(); i++) {
|
||||
const auto& op = tileOps[i];
|
||||
if (op.id != tile) continue;
|
||||
switch (op.op) {
|
||||
case TileOperation::RequestedFromCache: {
|
||||
@@ -1781,26 +1784,34 @@ TEST(Map, ObserveTileLifecycle) {
|
||||
break;
|
||||
}
|
||||
case TileOperation::RequestedFromNetwork: {
|
||||
EXPECT_THAT(
|
||||
stage,
|
||||
testing::AnyOf(
|
||||
TileOperation::StartParse, TileOperation::EndParse, TileOperation::RequestedFromCache));
|
||||
// Parsing happens concurrently with the file source request and can start and stop between requests
|
||||
EXPECT_THAT(stage,
|
||||
testing::AnyOf(
|
||||
TileOperation::StartParse, TileOperation::EndParse, TileOperation::LoadFromCache));
|
||||
stage = TileOperation::RequestedFromNetwork;
|
||||
break;
|
||||
}
|
||||
case TileOperation::LoadFromNetwork: {
|
||||
EXPECT_THAT(stage, TileOperation::RequestedFromNetwork);
|
||||
// Parsing happens concurrently with the file source request and can start and stop between requests
|
||||
EXPECT_THAT(
|
||||
stage,
|
||||
testing::AnyOf(
|
||||
TileOperation::StartParse, TileOperation::EndParse, TileOperation::RequestedFromNetwork));
|
||||
stage = TileOperation::LoadFromNetwork;
|
||||
break;
|
||||
}
|
||||
case TileOperation::LoadFromCache: {
|
||||
EXPECT_EQ(stage, TileOperation::RequestedFromCache);
|
||||
EXPECT_THAT(stage, testing::AnyOf(TileOperation::RequestedFromCache, TileOperation::StartParse));
|
||||
stage = TileOperation::LoadFromCache;
|
||||
break;
|
||||
}
|
||||
case TileOperation::StartParse: {
|
||||
EXPECT_THAT(stage, testing::AnyOf(TileOperation::LoadFromNetwork, TileOperation::LoadFromCache));
|
||||
// Parsing is expected to be started early during the request process by a call to `setLayers`
|
||||
EXPECT_THAT(stage,
|
||||
testing::AnyOf(TileOperation::RequestedFromCache, TileOperation::RequestedFromNetwork));
|
||||
EXPECT_FALSE(parsing); // We must not already be parsing when seeing this marker.
|
||||
stage = TileOperation::StartParse;
|
||||
parsing = true;
|
||||
break;
|
||||
}
|
||||
case TileOperation::Cancelled: {
|
||||
@@ -1811,6 +1822,7 @@ TEST(Map, ObserveTileLifecycle) {
|
||||
TileOperation::LoadFromCache,
|
||||
TileOperation::StartParse));
|
||||
stage = TileOperation::Cancelled;
|
||||
parsing = false;
|
||||
break;
|
||||
}
|
||||
case TileOperation::EndParse: {
|
||||
@@ -1831,6 +1843,8 @@ TEST(Map, ObserveTileLifecycle) {
|
||||
testing::AnyOf(TileOperation::StartParse,
|
||||
TileOperation::LoadFromNetwork,
|
||||
TileOperation::RequestedFromNetwork));
|
||||
EXPECT_TRUE(parsing); // We must have been parsing to see the EndParse marker.
|
||||
parsing = false;
|
||||
stage = TileOperation::EndParse;
|
||||
break;
|
||||
}
|
||||
@@ -1844,5 +1858,6 @@ TEST(Map, ObserveTileLifecycle) {
|
||||
}
|
||||
|
||||
EXPECT_THAT(stage, testing::AnyOf(TileOperation::EndParse, TileOperation::Cancelled));
|
||||
EXPECT_FALSE(parsing);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user