Select to view content in your preferred language

FeatureLayers returning all features on load

164
10
Jump to solution
Wednesday
EricLake1
Emerging Contributor

Starting around version 4.20 of the ESRI JavaScript API, we noticed that FeatureLayers began returning all features from the server when the layer is loaded or made visible, regardless of the current map extent. I now see this behavior is confirmed in the 4.33 release notes and appears to be the new standard.

We manage hundreds of map services, and some layers contain tens of thousands of features. Now, even simple web maps with only 10–15 layers can take 20–30 seconds to load, depending on how many features are in each. This is significantly affecting performance and usability.

We’ve confirmed:

  • Even if the map is zoomed in before the layer is toggled visible, all features are still fetched from the server.

  • This behavior occurs even with small test apps using basic FeatureLayers from various sources.

  • It's not specific to our server; we've tried ArcGIS Server 11 and tested with binary (PBF) format responses—no significant improvement.

Questions:

  1. Why does the FeatureLayer no longer respect the current extent when requesting features?

  2. Is this really the permanent behavior moving forward?

  3. Is the only viable solution to switch to MapImageLayer for every service that contains a large number of features?

  4. Are there any workarounds or configurations (e.g., definitionExpression, featureReduction, etc.) that can force extent-based filtering?

If this is the intended behavior, this change will significantly increase the load on our infrastructure and may require a complete overhaul of our web maps.

We’d really appreciate any insights, solutions, or confirmation from Esri or others who’ve encountered and worked around this.

Thanks in advance.

0 Kudos
1 Solution

Accepted Solutions
JoelBennett
MVP Regular Contributor

You can disable the snapshot behavior by adding this prior to loading the SDK:

<script type="text/javascript">
	window.esriConfig = {
		has: {
			"featurelayer-snapshot-enabled": !1 // disable snapshot
		}
	};
</script>

 

 For example, in your codepen, you'd add it before this line:

<script src="https://js.arcgis.com/4.32/"></script>

 

I don't think I've seen any official documentation for this functionality, but it gets mentioned somewhat casually from time to time, like here and here.

My two cents on this particular issue: Esri would do well to allow developers to make this decision on a layer-by-layer basis similar to how it was done in 3.x.

View solution in original post

0 Kudos
10 Replies
UndralBatsukh
Esri Regular Contributor

Hi there, 

Is it possible for you to share your webmap url with me? You can direct message me if you dont want to share publicly. 

EricLake1
Emerging Contributor

Here is a simple codepen showing the issue. Note that I have tried layers from multiple different servers, like ESRI, PASDA & PA, they all exhibit this behavior.

When this codepen loads, it loads ESRI cities from the sample server though the initial map extent is very small. The right panel queries for all features in the LayerView for the layer and shows the total number of features loaded, which you can also see in the network tab.

FeatureLayer Loading All Features

0 Kudos
UndralBatsukh
Esri Regular Contributor

Hi there,

Thank you for sharing the codepen. However, I’m already very familiar with this behavior, so a basic example won’t help us investigate the issue you originally described. To properly assess and address the performance concerns, we need access to your actual webmap.

Starting with version 4.19, the ArcGIS Maps SDK for JavaScript began supporting the fetching of all features from point feature services at initialization, provided certain conditions are met. As of version 4.33, this behavior has been extended to AGOL-hosted feature services with polygon, polyline, and multipoint geometries, again assuming the appropriate conditions are satisfied. This enhancement improves app responsiveness by loading all features at once and eliminating repeated server requests as users interact with the map.

We need to examine your webmap directly to determine how your data aligns with these conditions. This will help us assess performance and potentially fine-tune the behavior further. Would you be able to share the webmap with us?

0 Kudos
EricLake1
Emerging Contributor
That's fine, but this does not work with large datasets, unless you are
telling me the API should be able to download all 300k+ records when we add
a FeatureLayer to a map. We have quite a few large datasets. The issue we
have is with points, but it gets worse with polylines and polygons as the
amount of data gets even larger.

Is there some documentation that you can provide that would help us make
this work better?

How do I generate or find this webmap? What exactly are you asking for?

Thanks
0 Kudos
mgeorge
Esri Contributor

@EricLake1, in most cases snapshotting features reduces the load on the backend -- that's why we made this change. The alternative is making many tile queries (queries with extents) which then hit the spatial index on the backend. Enterprise can really chug with this as it doesn't yet support caching. Consider map load: assuming the map is full screen, then on a 1440p monitor you will be making a minimum of 15 tile queries if we don't use snapshot mode. As you interact with the map and pan around, that will result in many additional queries being made. With snapshotting the service however, once those initial queries are done, no additional queries need to be made. From our testing snapshotting significantly reduces load on the backend with realistic scenarios (many users interacting with a map over some period of time).

We don't snapshot in every case, and it includes several factors like whether the service is editable, and count thresholds based on how zoomed out are you relative to the total layer's extent.

For polygons & polylines, we make exceedslimit queries to check the vertex and feature count. At the moment, we only snapshot polygons & polylines if the count is 1000-2000 (exact value depends on the % of the layer you are looking at)

If the layer isn't visible, I don't think you should be seeing any features being downloaded. For instance, I don't see pbf data queries getting made with https://codepen.io/matt9222/pen/YPyzaLO?editors=1000

 

0 Kudos
mgeorge
Esri Contributor

Correction: we actually don't snapshot polygons/polylines for non-AGOL hosted at all yet. That is however planned for the near-term. So you shouldn't be seeing this in your environment. 

0 Kudos
EricLake1
Emerging Contributor

You realize this basically eliminates the ability for us to use large datasets with the API? On layers with hundreds of thousands of features, it takes forever for the map to load.

Leave the option to turn this on or off, we can decide it it kills our servers.

0 Kudos
JoelBennett
MVP Regular Contributor

You can disable the snapshot behavior by adding this prior to loading the SDK:

<script type="text/javascript">
	window.esriConfig = {
		has: {
			"featurelayer-snapshot-enabled": !1 // disable snapshot
		}
	};
</script>

 

 For example, in your codepen, you'd add it before this line:

<script src="https://js.arcgis.com/4.32/"></script>

 

I don't think I've seen any official documentation for this functionality, but it gets mentioned somewhat casually from time to time, like here and here.

My two cents on this particular issue: Esri would do well to allow developers to make this decision on a layer-by-layer basis similar to how it was done in 3.x.

0 Kudos
EricLake1
Emerging Contributor

Thanks for showing us this option. I agree, we should be able to make the choice on whether we enable this or not.

0 Kudos