Select to view content in your preferred language

Evaulating Popup with Expression using FeatureSetByRelationshipName Crashes App

447
4
05-08-2024 12:05 PM
Justin_Greco
Frequent Contributor

I have a layer that is consistently crashing my app when evaluating the popup expressions.  I have narrowed it down to three Arcade expressions, which are all using FeatureSetByRelationshipName to get features from related tables.  The feature layer is not a hosted service, but is a feature service published from a file geodatabase on ArcGIS Server.

One thing I have tested is evaluating each expression using the ArcadeEvaluator.  I am able to successfully evaluate each expression.  It only seems to be an issue when using popup.evaluateExpressions().  I also see the same behavior in the Kotlin SDK as well.

My work around has been to adjust my Arcade to do a filter on the table, rather than getting related features.

0 Kudos
4 Replies
Destiny_Hochhalter
Esri Contributor

Hi Justin,

Can you share a small reproducible case using popup.evaluateExpressions()? Also, does this call result in a specific error or crash?

Alternatively, if evaluating each expression using ArcadeEvaluator works, you could try to further evaluate the popup using the evaluate method that takes profile variables. Here is an example of evaluating an arcade expression for a popup from a geotrigger notification for reference:

var messageExpression: ArcGIS.ArcadeExpression
var popup: Popup

let evaulator = ArcadeEvaluator(expression: messageExpression, profile: .geotriggerNotification)
try await evaulator.load()

let profileVariables: [String: Any] = [
    "$fencefeature": popup.geoElement,
    "$fencenotificationtype": "entered"
]
let result = try await evaulator.evaluate(withProfileVariables: profileVariables)

if let result = result.result(as: .dictionary) as? [String: Any] {
    if let message = result["message"] as? String {
        print(message)
    }
}

 

0 Kudos
Justin_Greco
Frequent Contributor

Its just a crash, no specific error, just "heap corruption detected".  However, I probably should have posted this in the Kotlin SDK community, since for Swift I am using the PopupView from the toolkit, so its just passing the popup to PopupView.  Though I imagine its still the evaluateExpressions function internal to the toolkit that is causing the crash.

Here is one of the Arcade expressions that causes the crash.

var url = 'https://services.wakegov.com/realestate/photos/mvideo/'
var condos = FeatureSetByRelationshipName($feature, 'PROPERTY_CONDO', ['*'], false)
var photos = FeatureSetByRelationshipName(First(condos), 'CONDO_PHOTOS')
var photo = First(Filter(photos, 'PRIMARYIMAGE = 1'))
if (photo != null) {
    return Concatenate([url,photo.IMAGEDIR, '/', photo.IMAGENAME])
}

 

0 Kudos
Destiny_Hochhalter
Esri Contributor

Thanks for the reproducible case. The Toolkit's PopupView does use the evaluateExpressions() method. Since this crash is reproducible using the Kotlin SDK then this could be a bug at the SDK level and not in the Toolkit.

0 Kudos
Destiny_Hochhalter
Esri Contributor

Hi Justin,

To further debug this crash, could you please provide a crash log?  Thanks.

0 Kudos