Select to view content in your preferred language

Intersects() making smartform open very slow

155
4
Friday
PaulPetersen1
Frequent Contributor

I only have this issue with 25.2.x. The issue does not exist in 25.1 when I open the same map.

Basically if I add any arcade calculation that use Intersects(), the smartform opens very slowly (10 seconds) when adding new features with the + button. For some reason if I edit an existing feature, the issue does not occur...the smartform opens as expected.

Anyone else having this issue? I'm just using very basic scripts like the one shown below. I've been using scripts like this for field calculations for years, never had an issue until now.

// Create a feature set using the 'Regions' layer in the map
var regions = FeatureSetByName($map, 'Regions', ['name'])

// Intersect the current location with the regions and
// get the first region
var region = First(Intersects($feature, regions))

// If the current location does intersect a feature,
// return the name of the region. Otherwise, return null
if (!IsEmpty(region)) {
return region['name']
} else {
return null
}

0 Kudos
4 Replies
JamesMiller36
Emerging Contributor

This sounds like a performance regression in 25.2.x. Since Intersects() is being evaluated on a new feature each time, it can slow SmartForm loading. A few workarounds:

  1. Use a smaller or filtered feature set in FeatureSetByName to reduce the number of features checked.

  2. Pre-calculate intersections where possible instead of on-the-fly.

  3. Consider using Intersects() in an attribute rule or during editing, rather than in a SmartForm expression, if feasible.

It’s worth reporting this to Esri Support, as it doesn’t happen in 25.1 and may be a version-specific issue.

0 Kudos
DannyGant
Emerging Contributor

Same issue here.  Have been using the same workflow for almost a year now and all of a sudden the SmartForm loading is taking up to 10 mins at times.  As soon as we pull the Intersects() function from the expression, immediate loading.  This coincides with our FM update to 25.2.5 (our devices were a few versions behind before updating them last week).  We've tried many things.  Filtering the FeatureSet does improve performance, but it's still too slow for field use.  Intersecting against a layer with 10K features total can take up to 2-3 mins.  

Our workflow is to basically drop a new point feature atop an existing sewer infrastructure.  The expression with Intersects() allows us to pull attributes from the parent sewer feature onto our new point.  One thing we did notice was IF location services was ON, then it seemed to perform better.  

0 Kudos
kmsmikrud
Frequent Contributor

Thanks for finding this issue and sharing. We use the intersects function in a number of Field Map data collection apps but now is not the field season for most of the biologists. Are you working offline or online for data collection? We are mostly offline/remote.

This would be yet another FM update that has made the app way slower to use this go around. I will check into this on our end. 

I hope FM team can get this fixed and back functioning the way it was in the previous version.

Thanks,
Kathy

0 Kudos
PaulPetersen1
Frequent Contributor

@kmsmikrud , I found the issue when working online (I'm just doing configuration and testing at this point). That said, I tried it offline, and I do not get the issue. So that is good, as we usually instruct our field users to work in offline mode even when they have cell coverage. But either way, it's a pretty bad regression from 25.1.

Also, I have found a workaround by using something like the code below, and just applying a very small buffer. I have no idea why Intersects() alone would be so much more expensive than querying a nearby feature via buffer() + intersects(). But I'll probably convert everything to this kind of script for the time being. At some point I have to stop banging my head and just move forward with something that works.

// If feature doesn't have geometry return null
if (IsEmpty(Geometry($feature))) { return null }

// Get the parcels layer
var parcels = FeatureSetByName($map, 'Parcels')

// Buffer the current location and intersect with parcels
var bufferedLocation = Buffer($feature, 100, 'feet')
var candidateParcels = Intersects(parcels, bufferedLocation)

// Calculate the distance between the parcel and the current location
// Store the feature and distance as a dictionary and push it into an array
var featuresWithDistances = []
for (var f in candidateParcels) {
    Push(featuresWithDistances, 
        {
            'distance': Distance($feature, f, 'feet'),
            'feature': f
        }
    )
}

// Sort the candidate parcels by distance using a custom function
function sortByDistance(a, b) {
    return a['distance'] - b['distance']
}
var sorted = Sort(featuresWithDistances, sortByDistance)

// Get the closest feature
var closestFeatureWithDistance = First(sorted)

// If there was no feature, return null
if (IsEmpty(closestFeatureWithDistance)) { return null }

// Return the address
return `${closestFeatureWithDistance['feature']['ADDNUM']} ${closestFeatureWithDistance['feature']['ADDRESSNAM']}`

 

0 Kudos