test: record STEP-117 PBF R cache admission blockers
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
This commit is contained in:
@@ -1,19 +1,24 @@
|
||||
#include <mln/actor/scheduler.hpp>
|
||||
#include <mln/gfx/uniform_buffer.hpp>
|
||||
#include <mln/renderer/layer_group.hpp>
|
||||
#include <mln/renderer/change_request.hpp>
|
||||
#include <mln/renderer/render_orchestrator.hpp>
|
||||
#include <mln/renderer/renderer_observer.hpp>
|
||||
#include <mln/renderer/retained_underlay_cache.hpp>
|
||||
#include <mln/renderer/particle_fast_path.hpp>
|
||||
#include <mln/renderer/update_parameters.hpp>
|
||||
#include <mln/renderer/render_source.hpp>
|
||||
#include <mln/renderer/render_source_observer.hpp>
|
||||
#include <mln/renderer/tile_render_data.hpp>
|
||||
#include <mln/style/sources/geojson_source_impl.hpp>
|
||||
#include <mln/style/layers/symbol_layer.hpp>
|
||||
#include <mln/tile/tile.hpp>
|
||||
#include <mln/tile/tile_observer.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <initializer_list>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace mln;
|
||||
@@ -24,6 +29,10 @@ struct RenderOrchestratorTeardownTestAccess {
|
||||
source->setObserver(&orchestrator);
|
||||
orchestrator.renderSources.emplace(source->baseImpl->id, std::move(source));
|
||||
}
|
||||
|
||||
static void enqueue(RenderOrchestrator& orchestrator, UniqueChangeRequestVec& changes) {
|
||||
orchestrator.addChanges(changes);
|
||||
}
|
||||
};
|
||||
} // namespace mln
|
||||
|
||||
@@ -249,3 +258,180 @@ TEST(RenderOrchestratorTeardown, PendingTileCancellationAndSecondDrainRepeatSafe
|
||||
EXPECT_EQ(renderJobs.load(), iteration + 1);
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
std::shared_ptr<UpdateParameters> step117TreeParameters(
|
||||
const Immutable<std::vector<Immutable<style::Layer::Impl>>>& layers,
|
||||
const Immutable<std::vector<Immutable<style::Source::Impl>>>& sources,
|
||||
const std::shared_ptr<RetainedUnderlayRuntimeState>& runtime,
|
||||
TimePoint now) {
|
||||
TransformState state;
|
||||
state.setSize({640, 480});
|
||||
static const style::Light light; // Keep unrelated light revisions fixed across sourceDiff steps.
|
||||
return std::make_shared<UpdateParameters>(UpdateParameters{
|
||||
.styleLoaded = true,
|
||||
.mode = MapMode::Continuous,
|
||||
.pixelRatio = 1.0f,
|
||||
.debugOptions = MapDebugOptions::NoDebug,
|
||||
.timePoint = now,
|
||||
.transformState = state,
|
||||
.glyphURL = {},
|
||||
.fontFaces = {},
|
||||
.spriteLoaded = true,
|
||||
.transitionOptions = {Milliseconds(0), std::nullopt, false},
|
||||
.light = light.impl,
|
||||
.images = makeMutable<std::vector<Immutable<style::Image::Impl>>>(),
|
||||
.sources = sources,
|
||||
.layers = layers,
|
||||
.annotationManager = {},
|
||||
.fileSource = {},
|
||||
.prefetchZoomDelta = 0,
|
||||
.stillImageRequest = false,
|
||||
.crossSourceCollisions = true,
|
||||
.retainedUnderlayState = runtime,
|
||||
});
|
||||
}
|
||||
} // namespace
|
||||
|
||||
TEST(Step117Safety, RealMissingSourceTreeHasNoRenderItemButStillFailsClosed) {
|
||||
TaggedScheduler scheduler{Scheduler::GetBackground(), {}};
|
||||
RenderOrchestrator orchestrator(false, scheduler, std::nullopt);
|
||||
auto runtime = std::make_shared<RetainedUnderlayRuntimeState>();
|
||||
ASSERT_TRUE(runtime->setRenderSegmentPlan({1, {{RenderSegmentStrategy::Retained, std::nullopt}}}));
|
||||
style::SymbolLayer symbol("step117-symbol", "step117-source");
|
||||
const Immutable<std::vector<Immutable<style::Layer::Impl>>> layers =
|
||||
makeMutable<std::vector<Immutable<style::Layer::Impl>>>(
|
||||
std::initializer_list<Immutable<style::Layer::Impl>>{symbol.baseImpl});
|
||||
const Immutable<std::vector<Immutable<style::Source::Impl>>> absent =
|
||||
makeMutable<std::vector<Immutable<style::Source::Impl>>>();
|
||||
const auto now = TimePoint{} + Seconds(10);
|
||||
auto tree = orchestrator.createRenderTree(step117TreeParameters(layers, absent, runtime, now), nullptr);
|
||||
ASSERT_TRUE(tree);
|
||||
EXPECT_TRUE(tree->getLayerRenderItemMap().empty());
|
||||
EXPECT_EQ(orchestrator.numLayerGroups(), 0u);
|
||||
auto missing = orchestrator.retainedSegmentSourceState(0, 1);
|
||||
EXPECT_STREQ(missing.reason, "missing-source");
|
||||
EXPECT_FALSE(missing.ready);
|
||||
EXPECT_EQ(missing.revision, 0u);
|
||||
EXPECT_TRUE(orchestrator.retainedRangeHasPlacementCapableLayer(0, 1));
|
||||
const auto fingerprint = orchestrator.retainedRangeContentFingerprint(0, 1);
|
||||
tree.reset(); // Match Renderer: release reference-based render items before source replacement.
|
||||
|
||||
const auto sourceList = []() -> Immutable<std::vector<Immutable<style::Source::Impl>>> {
|
||||
return makeMutable<std::vector<Immutable<style::Source::Impl>>>(
|
||||
std::initializer_list<Immutable<style::Source::Impl>>{
|
||||
makeMutable<style::GeoJSONSource::Impl>("step117-source", style::GeoJSONOptions::defaultOptions())});
|
||||
};
|
||||
// An unsubmitted test-only source exercises actual sourceDiff creation and
|
||||
// same-ID replacement. It supplies no fake tide or production data.
|
||||
tree = orchestrator.createRenderTree(step117TreeParameters(layers, sourceList(), runtime, now + Seconds(1)), nullptr);
|
||||
ASSERT_TRUE(tree);
|
||||
ASSERT_EQ(tree->getLayerRenderItemMap().size(), 1u);
|
||||
const auto added = orchestrator.retainedSegmentSourceState(0, 1);
|
||||
EXPECT_STRNE(added.reason, "missing-source");
|
||||
EXPECT_NE(added.revision, missing.revision);
|
||||
EXPECT_EQ(orchestrator.retainedRangeContentFingerprint(0, 1), fingerprint);
|
||||
EXPECT_FALSE(renderSegmentPlacementGatePassed(true, tree->getParameters().placementChanged,
|
||||
tree->getParameters().symbolFadeChange, orchestrator.retainedPlacementTransitionActive(now + Seconds(1))));
|
||||
tree.reset();
|
||||
tree = orchestrator.createRenderTree(step117TreeParameters(layers, sourceList(), runtime, now + Seconds(2)), nullptr);
|
||||
ASSERT_TRUE(tree);
|
||||
const auto replaced = orchestrator.retainedSegmentSourceState(0, 1);
|
||||
EXPECT_NE(replaced.revision, added.revision);
|
||||
tree.reset();
|
||||
tree = orchestrator.createRenderTree(step117TreeParameters(layers, absent, runtime, now + Seconds(3)), nullptr);
|
||||
ASSERT_TRUE(tree);
|
||||
EXPECT_TRUE(tree->getLayerRenderItemMap().empty());
|
||||
missing = orchestrator.retainedSegmentSourceState(0, 1);
|
||||
EXPECT_STREQ(missing.reason, "missing-source");
|
||||
EXPECT_FALSE(missing.ready); // Source tombstone does not supply readiness.
|
||||
EXPECT_EQ(missing.revision, 0u);
|
||||
// No Renderer/backend draw is invoked; zero RenderItems is not a GPU certificate.
|
||||
}
|
||||
|
||||
TEST(Step117Safety, QueuedGroupRemovalIsNotAppliedUntilProcessChanges) {
|
||||
TaggedScheduler scheduler{Scheduler::GetBackground(), {}};
|
||||
RenderOrchestrator orchestrator(false, scheduler, std::nullopt);
|
||||
auto symbolGroup = std::make_shared<TestLayerGroup>(2);
|
||||
auto collisionGroup = std::make_shared<TestLayerGroup>(2);
|
||||
ASSERT_TRUE(orchestrator.addLayerGroup(symbolGroup));
|
||||
ASSERT_TRUE(orchestrator.addLayerGroup(collisionGroup));
|
||||
UniqueChangeRequestVec changes;
|
||||
changes.emplace_back(std::make_unique<RemoveLayerGroupRequest>(symbolGroup));
|
||||
changes.emplace_back(std::make_unique<RemoveLayerGroupRequest>(collisionGroup));
|
||||
RenderOrchestratorTeardownTestAccess::enqueue(orchestrator, changes);
|
||||
EXPECT_TRUE(changes.empty());
|
||||
EXPECT_TRUE(orchestrator.particleFastPathDynamicState(TimePoint{}).pendingChanges);
|
||||
unsigned visits = 0;
|
||||
orchestrator.visitLayerGroupsInRange(0, 63, [&](LayerGroupBase&, size_t) { ++visits; });
|
||||
EXPECT_EQ(visits, 2u);
|
||||
orchestrator.processChanges();
|
||||
EXPECT_FALSE(orchestrator.particleFastPathDynamicState(TimePoint{}).pendingChanges);
|
||||
visits = 0;
|
||||
orchestrator.visitLayerGroupsInRange(0, 63, [&](LayerGroupBase&, size_t) { ++visits; });
|
||||
EXPECT_EQ(visits, 0u);
|
||||
EXPECT_EQ(orchestrator.numLayerGroups(), 0u);
|
||||
// This is real queue/registry coverage with test groups, not actual GPU draws.
|
||||
}
|
||||
|
||||
TEST(Step117Safety, RealAsyncCallbacksAndContextStyleCleanupAdvanceContentEpoch) {
|
||||
TaggedScheduler scheduler{Scheduler::GetBackground(), {}};
|
||||
RenderOrchestrator orchestrator(false, scheduler, std::nullopt);
|
||||
std::atomic<int> deferred{0};
|
||||
std::atomic<int> renderJobs{0};
|
||||
std::atomic<int> detached{0};
|
||||
auto source = std::make_unique<TeardownSource>(scheduler, deferred, renderJobs, detached);
|
||||
source->setObserver(&orchestrator);
|
||||
const auto changesEpoch = [&](auto event, RetainedUnderlayReason expected) {
|
||||
const auto before = orchestrator.getRetainedUnderlayContentRevision();
|
||||
event();
|
||||
EXPECT_GT(orchestrator.getRetainedUnderlayContentRevision(), before);
|
||||
EXPECT_EQ(orchestrator.getRetainedUnderlayContentReason(), expected);
|
||||
ParticleFastPathGateInput input{
|
||||
.hasPreparedTree = true,
|
||||
.retainedEnabled = true,
|
||||
.cacheValid = true,
|
||||
.revisionMatches = true,
|
||||
.contentRevisionMatches = true,
|
||||
.cameraMatches = true,
|
||||
.viewportMatches = true,
|
||||
.updateParametersMatch = true,
|
||||
.styleLoaded = true,
|
||||
.boundaryMatches = true,
|
||||
.topologyMatches = true,
|
||||
.staticStable = true,
|
||||
.hasPlacementTransition = false,
|
||||
.hasPendingChanges = false,
|
||||
.hasNonParticleTransition = false,
|
||||
.hasNonParticleRepaint = false,
|
||||
.hasFadingTiles = false,
|
||||
.particleNeedsRepaint = true,
|
||||
.stillImageRequest = false,
|
||||
.continuousMode = true,
|
||||
.debugDisabled = true,
|
||||
.unsupportedContinuousLayer = false,
|
||||
.supportedScene = true,
|
||||
.annotationMutation = false,
|
||||
};
|
||||
input.contentRevisionMatches = before == orchestrator.getRetainedUnderlayContentRevision();
|
||||
EXPECT_EQ(particleFastGateFailureMask(input), 1u << 4);
|
||||
EXPECT_FALSE(evaluateParticleFastPath(input).candidate);
|
||||
EXPECT_EQ(evaluateParticleFastPath(input).reason, ParticleFastPathMissReason::ContentMutation);
|
||||
};
|
||||
changesEpoch([&] {
|
||||
static_cast<RenderSourceObserver&>(orchestrator).onTileChanged(*source, OverscaledTileID{0, 0, {0, 0, 0}});
|
||||
}, RetainedUnderlayReason::TileMutation);
|
||||
changesEpoch([&] {
|
||||
static_cast<GlyphManagerObserver&>(orchestrator).onGlyphsLoaded(FontStack{}, GlyphRange{0, 255});
|
||||
}, RetainedUnderlayReason::GlyphMutation);
|
||||
changesEpoch([&] {
|
||||
static_cast<ImageManagerObserver&>(orchestrator).onStyleImageMissing("step117-image", [] {});
|
||||
}, RetainedUnderlayReason::ImageMutation);
|
||||
changesEpoch([&] { orchestrator.markContextLost(); }, RetainedUnderlayReason::ContextReset);
|
||||
changesEpoch([&] { orchestrator.clearData(); }, RetainedUnderlayReason::StyleMutation);
|
||||
source->setObserver(nullptr);
|
||||
source.reset();
|
||||
scheduler.waitForEmpty();
|
||||
scheduler.runRenderJobs();
|
||||
// Actual callback dispatch, but no network delivery, GPU, or Android assertion.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user