Label Item disappears from the scene after constantly calling setText()

506
5
09-20-2023 01:14 AM
FatmaAkdemir
Occasional Contributor II

We have a label item showing the info about a track on the 3D SceneGraphicsView, just as below. There are many tracks on scene and each track has its own label.

Esri::ArcGISRuntime::Graphic *mpLabelItem = nullptr;
Esri::ArcGISRuntime::TextSymbol *mpTextSymbol = nullptr;


mpTextSymbol = new TextSymbol("", QColor(Qt::white), 10.0, HorizontalAlignment::Center, VerticalAlignment::Bottom, this);
mpTextSymbol->setOffsetX(10);
mpTextSymbol->setOffsetY(10);
mpLabelItem = new Graphic(Point(0, 0), mpTextSymbol, this);
QString labelStr(GetSource());
labelStr.append("-label");
mpLabelItem->attributes()->insertAttribute("source", labelStr);
mpLabelItem->attributes()->insertAttribute("id", pId);

mpMapViewer->AddToTracksOverlay(mpLabelItem);

 

However when we try to set text of this textSmbol once in every second, we face the problem of all labels disappearing from the scene after one day.

 

void PpiTrackItem::SetText()
{
QString mText = QString("T").append(attributes()->attributeValue("id").toString());
mText.append("\n");
mText.append("R:");
mText.append(QString::number(AstrxUnitConverter::ConvertMeterToNM(attributes()->attributeValue("range").toDouble()), 'f', 2));
mText.append("nm ");
mText.append("B:");
mText.append(QString::number(attributes()->attributeValue("bearing").toDouble(), 'f', 2));
mText.append("\u00B0");
mText.append("\n");
mText.append("S:");
mText.append(QString::number(Calculations::CovertMsToKnots(attributes()->attributeValue("speed").toDouble()), 'f', 2) + " knot");
attributes()->replaceAttribute("text", mText);
mpTextSymbol->setText(mText);
}

 

Tags (1)
0 Kudos
5 Replies
GuillaumeBelz
Esri Contributor

Hello Fatma,

I tried to reproduce your problem, with a map and a scene, and 50000 text symbols in graphic overlay. Everything looks good.

Can you share a code and procedure to reproduce this problem?

Thank you.

FatmaAkdemir
Occasional Contributor II

Hi @GuillaumeBelz ,

Thanks four your reply. In order to reproduce the problem, you might change the text of those 50000 symbols once in every second indefinitely. It might be a while loop or a QTimer. Setting the text of the symbols with random text would be enough.

0 Kudos
GuillaumeBelz
Esri Contributor

Hello,

I tried with a new 3D project with C++/Widgets API, on Mac and Windows, with version 200.2, but I can't reproduce the problem.

m_graphicsOverlay = new GraphicsOverlay(this);
m_sceneView->graphicsOverlays()->append(m_graphicsOverlay);

constexpr int N =1000;
for (int i = 0; i < N; ++i)
{
    Esri::ArcGISRuntime::TextSymbol* m_symbol = nullptr;
    m_symbol = new TextSymbol("a symbol", QColor(Qt::red), 10.0, HorizontalAlignment::Center, VerticalAlignment::Bottom, this);
    m_symbol->setOffsetX(10);
    m_symbol->setOffsetY(10);
    m_graphic = new Graphic(Point(randInRange(10000), randInRange(10000), 10000000), m_symbol, this);
    m_graphic->attributes()->insertAttribute("source", "text in attribute");
    m_graphic->attributes()->insertAttribute("id", 1234);
    m_symbols.push_back(m_symbol);
    m_graphicsOverlay->graphics()->append(m_graphic);
}

QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, [this]()
        {
            for (int i = 0; i < N; ++i)
            {
                m_symbols[i]->setText(QString::number(randInRange(100000)));
            }
        });
timer->start(1000);

Can you add more details to reproduce this problem?

 - Which version of SDK?

- How many symbols?

- How long to wait to reproduce the problem?

Thank you

0 Kudos
FatmaAkdemir
Occasional Contributor II

Hi @GuillaumeBelz ,

We observe the problem after 24 hours of the executable up and working. There are approximately 200 symbols on the view. And version of the SDK is 100.8.

0 Kudos
GuillaumeBelz
Esri Contributor

Hello,

I'm running a 24 hours test to check if I can reproduce the problem (200.2, Windows).

There was a known issue before 100.14 with memory leak in symbols. Maybe it's related. Did you tried an updated version of SDK (last version is 100.15)? Did you see a memory leak?

EDIT: I ran this test more than 30 hours (Windows, 200.2) without problem. It looks like it's specific to an old version of SDK.

0 Kudos