MapQuickView identifyLayerAsync sometimes stuck forever

400
3
10-30-2023 10:20 AM
radimbachb
New Contributor III

I transformed the identify raster cell sample (Identify raster cell | ArcGIS Maps SDK for Qt | ArcGIS Developers) to use the new identifyLayerAsync method using QFutures. However, sometimes the QFuture never finishes.

On every MapQuickView::hoverMoved event I'd like to update the raster cell value and display it on the map.

	connect(m_mapView, &MapQuickView::hoverMoved, this, [this](QHoverEvent& e) {
		if (!m_identifyLayerFuture.isFinished()) {
			qDebug() << "Still identifying...";
			return;
		}

		qDebug() << "IdentifyingLayer";
		m_identifyLayerFuture = m_mapView->identifyLayerAsync(m_rasterLayer, e.position(), 10, false, 1);
		m_identifyLayerFuture.then(this, [this](IdentifyLayerResult* rawIdentifyResult) {
			qDebug() << "Finished identifying";
			const auto identifyResult = std::unique_ptr<IdentifyLayerResult>(rawIdentifyResult);
			const auto elements = identifyResult->geoElements();
			for (GeoElement* geoElement : elements) {
				if (RasterCell* rasterCell = dynamic_cast<RasterCell*>(geoElement)) {
					const AttributeListModel* attributes = rasterCell->attributes();
					const QStringList attributeNames = rasterCell->attributes()->attributeNames();

					for (int i = 0; i < attributeNames.size(); ++i) {
						const QString value = QVariant((*attributes)[attributeNames[i]]).toString();
						if (attributeNames[i] == "Band_0") {
							setRasterValue(value);
						}
					}
				}
			}

			qDebug() << "Finished processing result";
		});
	});

While moving the mouse, panning, zooming, leaving the raster cell area, usually after a few seconds the identifyLayerAsync QFuture suddenly does not finish anymore. If I use qFuture.waitForFinished() the application is stuck. Sometimes the application also crashes due to access violations.

Please find attached the IdentifyRasterCell.cpp, IdentifyRasterCell.h, IdentifyRasterCell.qml files that I use.

Am I doing something wrong in general, or might this be a bug?

0 Kudos
3 Replies
GuillaumeBelz
Esri Contributor

Hello,

I tried to reproduce this issue, but everything looks good (Mac, Qt 6.5.3, ArcGIS Maps SDK for Qt 200.2). Which platform do you use? Is there some specific moves to do to reproduce it?

Thank you

0 Kudos
radimbachb
New Contributor III

Hi @GuillaumeBelz 

Thank you for getting back to me. I've attached a zip containing 2 webm files showing how I get the issues.

An important distinction is that the issues are mostly prevalent in Debug configuration. In Release configuration the issues happen much less frequently.

We use Qt 6.5.3, ArcGISQtSDK 200.2, running on Microsoft Windows 10 Enterprise Version 10.0.19044

The issue usually happens after hovering for a few seconds over the raster layer. Often times the QFutures also get stuck when leaving the raster layer and then hovering back into the raster layer.

 

 

0 Kudos
GuillaumeBelz
Esri Contributor

Hi,

Sorry, I was on vacation. I'll work on your issue this week.

Thank you

0 Kudos