Skip to content

Commit

Permalink
[drape] [iOS] Changes to catch a source of crash at CHECK(IsEnoughMem…
Browse files Browse the repository at this point in the history
…ory) in LineRawBatch::BatchData. MAPSME-12898
  • Loading branch information
tomilov authored and Arsentiy Milchakov committed Oct 16, 2020
1 parent 34bab2a commit aabece6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 6 additions & 3 deletions drape/batcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ void Batcher::ChangeBuffer(ref_ptr<GraphicsContext> context, ref_ptr<CallbacksWr
RenderState const & state = wrapper->GetState();
FinalizeBucket(context, state);

CHECK(m_buckets.find(state) == m_buckets.end(), ());
ref_ptr<RenderBucket> bucket = GetBucket(state);
wrapper->SetVAO(bucket->GetBuffer());
}
Expand All @@ -251,17 +252,19 @@ ref_ptr<RenderBucket> Batcher::GetBucket(RenderState const & state)
ref_ptr<RenderBucket> result = make_ref(buffer);
result->SetFeatureMinZoom(m_featureMinZoom);

m_buckets.emplace(state, std::move(buffer));
if (!m_buckets.emplace(state, std::move(buffer)).second)
CHECK(false, ());

return result;
}

void Batcher::FinalizeBucket(ref_ptr<GraphicsContext> context, RenderState const & state)
{
auto const it = m_buckets.find(state);
ASSERT(it != m_buckets.end(), ("Have no bucket for finalize with given state"));
CHECK(it != m_buckets.end(), ("Have no bucket for finalize with given state"));
drape_ptr<RenderBucket> bucket = std::move(it->second);
m_buckets.erase(state);
if (m_buckets.erase(state) == 0)
CHECK(false, ());

bucket->GetBuffer()->Preflush(context);
m_flushInterface(state, std::move(bucket));
Expand Down
5 changes: 3 additions & 2 deletions drape/batcher_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,16 @@ void LineRawBatch::BatchData(ref_ptr<GraphicsContext> context, ref_ptr<Attribute
uint32_t avVertex = GetAvailableVertexCount();
uint32_t avIndex = GetAvailableIndexCount();
uint32_t vertexCount = streams->GetVertexCount();
CHECK_GREATER_OR_EQUAL(vertexCount, 2, ());
CHECK_GREATER_OR_EQUAL(vertexCount, 2, (vertexCount));
auto const indexCount = static_cast<uint32_t>(m_indices.size());

if (!IsEnoughMemory(avVertex, vertexCount, avIndex, indexCount))
{
ChangeBuffer(context);
avVertex = GetAvailableVertexCount();
avIndex = GetAvailableIndexCount();
CHECK(IsEnoughMemory(avVertex, vertexCount, avIndex, indexCount), ());
CHECK(IsEnoughMemory(avVertex, vertexCount, avIndex, indexCount),
(avVertex, vertexCount, avIndex, indexCount));
}

uint32_t startIndex = 0;
Expand Down

0 comments on commit aabece6

Please sign in to comment.