Can't open more than 20 or so tabs with JS map

1273
6
11-09-2021 08:34 PM
JasonDoingMaps
New Contributor III

In MS Edge (v95.0.1020.44 64-bit) and Google Chrome (v95.0.4638.69 64-bit), if I open more than 20 or so browser tabs with an ArcGIS JS map, the browser tabs all crash.

For example, this page - https://developers.arcgis.com/javascript/latest/ - opened about 25 times, will crash all tabs with this page open. See attached for error in Chrome. Error in MS Edge is much the same. Using the JS API on my own site gives the same outcome. I've had other users run the same test, and report getting the crash with more like 10 - 15 tabs.

I don't get the same result in Firefox (v94.0.1 64-bit).

I've tried going down the path of hiding / disposing of maps when the page isn't visible, thinking it's a memory or other resource contention issue, but that doesn't seem to help. I get the impression I'm not effectively freeing up memory from the map, much like reported here - https://community.esri.com/t5/arcgis-api-for-javascript-questions/arcgis-javascript-memory-leak/m-p/...

I'm not sure how to mitigate for this scenario.

0 Kudos
6 Replies
ReneRubalcava
Frequent Contributor

It sound like you might be running into webgl contexts issues. There is a max number of webgl contexts (instances of Maps/Scenes) in a browser and this is shared across tabs in the browsers. This limit can vary from browser to browser, machine to machine. This was briefly discussed here.

CourtneyMenikheim
Occasional Contributor

This does sound like a memory issue. Each browser (and the machine its on) will have different limits. When that limit is reached, things start conflicting, which is why the browser crashes. (Error code: STATUS_BREAKPOINT in your screenshot refers to a hardware defined breakpoint - there's not enough memory for what you're trying to do).

Hiding the webpages with the maps won't free up the memory. The browser still has to keep that memory allocated for when the user needs to open that tab again.

Every webpage is affected by this limit. Webpages with webmaps might hit that limit sooner than a webpage with static text and images, but that is because of the resources used in rendering an interactive webmap and its data. (This is why playing something like an MMO is done in a desktop application that communicates with a server, rather than through a browser; there's too much of a memory demand).

Why are you trying to open so many tabs with maps? Is this a workflow could be adjusted? If you're doing work that requires processing lots of maps at once, would one of Esri's desktop products be more appropriate?

Courtney Menikheim | Application Developer | @thecmenikheim
JeffreyWilkerson
Occasional Contributor III

Not sure why you need to open the same page more than 25 times, but I opened your first link and it didn't do the same thing to me (MS Edge Version 95.0.1020.44 (Official build) (64-bit) or Chrome Version 95.0.4638.69 (Official Build) (64-bit)).  In fact, this page is like the 34th or something.  Maybe it's in your system setup or something.

0 Kudos
JasonDoingMaps
New Contributor III

might be running into webgl contexts issues

Sounds feasible. I'm definitely not dead-set that it's a memory issue (be it heap, stack, addressing, or other). Just that it seems to be a resource contention issue. So yeah, it could be reaching a limit on webgl contexts, and that certainly goes a way to explaining why Firefox isn't affected - it might treat those resources differently.

 

@CourtneyMenikheimwrote:

Hiding the webpages with the maps won't free up the memory. The browser still has to keep that memory allocated for when the user needs to open that tab again.


Totally get that. What I was exploring as a possible mitigation though, was using the page visibility API to detect when the page is hidden (e.g. it's in an inactive tab), and use that as an opportunity to manually free up whatever resources the map is using. If the map isn't visible to the user, I don't need it using up resources. It would mean a bit of slow-down when the tab becomes visible again and I have to re-build it, but that's a reasonable trade-off compared to all tabs crashing.

 


@CourtneyMenikheimwrote:

Why are you trying to open so many tabs with maps? Is this a workflow could be adjusted?


It's somewhat coincidental that a map is involved. It's a project system where many things are displayed on the page, including a map of the location. It's not that the user needs to interact with lots of maps at once, but there are other things on the pages that the user may want to interact with in bulk / across many tabs.

 


@JeffreyWilkersonwrote:

Not sure why you need to open the same page more than 25 times... Maybe it's in your system setup or something.


To re-iterate from earlier: I've had other users run the same test, and report getting the crash with more like 10 - 15 tabs. It's definitely not particular to my own system setup, and results vary on how many tabs it takes to produce the issue. You may look at 25 tabs and say "that's silly". But is 10 tabs silly? Without fully understanding the factors that affect tab count, I can't even be certain that some users wouldn't be affected at 5 tabs, or 2! Thanks for sharing that you can get to 34 tabs without a crash though. That's further evidence that particulars of the system are a factor. How much system RAM do you have?

 

I'm trying to get a better understanding of what resources it's running out of, and how I might be able to selectively release those resources to mitigate (or ideally prevent) the issue altogether. I appreciate what some of you are saying in terms of trying a different approach - deal with the maps workflow differently, use the desktop app, etc. And it may come to that. But for now my focus is really on the crash itself, better understanding its cause and factors, and mitigating or eliminating it as-is.

0 Kudos
JasonDoingMaps
New Contributor III

I'm finding now, that the way the tabs are opened makes a difference. The "duplicate tab" functionality (keyboard shortcut ctrl+shift+k in MS Edge) will lead to a crash at about 15 tabs (on my PC at least). But opening each as a new tab (ctrl+t keyboard shortcut in just about every browser), then pasting in the URL, can get past 50 tabs without issue. In all these cases, I'm waiting for the ArcGIS map to fully load before opening another tab, just in case there's an issue particular to the load-time behaviour.

In my own app, users typically open tabs from a project list that uses JS function window.open. It's not doing anything with the return object from that function call (not even assigning it to a variable). But its performance seems to roughly match the "duplicate tab" scenario, as though the browser goes down one path for duplicate tab and window.open, but a different path for "new tab".

I'm beginning to wonder if this is a case for a Chromium bug report. Although I can only replicate the issue by using an ArcGIS map, perhaps the important factor is not ArcGIS JS, but just that it's a browser window that's using "quite a bit" of memory. (And, the internal behaviour of window.open and duplicate tab vs new tab).

0 Kudos
CourtneyMenikheim
Occasional Contributor

Duplicating a tab will not just open the same page that you are on, it will also copy over the history of any previous pages you viewed on that tab (so the "back" navigation will work the same on either tab). Opening a new tab and navigating to the same page won't contain as much history, so it won't be using as much memory.

Courtney Menikheim | Application Developer | @thecmenikheim