Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maps] GeoJSON Upload failing with Uncaught RangeError: Maximum call stack size exceeded #39317

Closed
nickpeihl opened this issue Jun 19, 2019 · 12 comments
Labels
bug Fixes for quality problems that affect the customer experience [Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation v7.3.2 v7.4.0 v8.0.0

Comments

@nickpeihl
Copy link
Member

nickpeihl commented Jun 19, 2019

Kibana version:
master

Describe the bug:
Upload GeoJSON Vector File in the Maps app fails as Uncaught RangeError: Maximum call stack size exceeded when uploading this large points file.
tanker_traffic_pnw.json.zip

This error occurs in both Firefox and Chrome.

Errors in browser console (if relevant):
Uncaught Error: Uncaught RangeError: Maximum call stack size exceeded (blob:http://localhost:5601/2840fa13-6fc7-4d85-ba8e-baa72aab16c2:1) at push../src/legacy/ui/public/notify/notify.js.window.onerror (notify.js:153)

Screen Shot 2019-06-19 at 5 48 39 PM

@nickpeihl nickpeihl added bug Fixes for quality problems that affect the customer experience [Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation labels Jun 19, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-gis

@nreese
Copy link
Contributor

nreese commented Jun 19, 2019

The Uncaught RangeError: Maximum call stack size exceeded is a problem with angular and circular dependencies in scope and is not related to geojson upload #39087

@nreese
Copy link
Contributor

nreese commented Jun 19, 2019

The Uncaught RangeError: Maximum call stack size exceeded is a problem with angular and circular dependencies in scope and is not related to geojson upload

Looks like that is not the case and the issues are separate. I commented out the angular $scope.indexPatterns declaration and the problem still occurs so looks like this is related to geojson upload and not angular.

@thomasneirynck
Copy link
Contributor

thomasneirynck commented Jul 1, 2019

this is failing for me in a different way:

image

And then the application just keeps hanging on

image

the actual visualization is fine though: (this is the in-mem GeojsonSource-version used in preview-mode.

image

@kindsun
Copy link
Contributor

kindsun commented Jul 1, 2019

This issue isn't specific to the GeoJSON Upload feature, it's related generally to the Maps app handling of geojson. If you attempt to load the same layer as a Custom Vector Source layer, the same issue persists. This should narrow it down to the current Maps GeoJSON handling

@thomasneirynck
Copy link
Contributor

thomasneirynck commented Jul 1, 2019

@aaronjcaldwell wrt #39317 (comment)

that's not quite the case when it comes to the error outlined here #39317 (comment)

they're likely two separte issues altogether then

@thomasneirynck
Copy link
Contributor

I'm not really seeing any issues with loading this file as a custom vector source,

e.g.:

map.regionmap:
      layers:
       - name: "tanker tracks self hosted"
         attribution: "tanker source"
         url: "http://localhost:8081/tanker_traffic_pnw.json"
         fields:
          - name: "MMSI"
            description: "MMSI identifier"

seems to load just fine.

It's only around 90000 points, which is on the low end, and the file is not particularly large either.

@kindsun
Copy link
Contributor

kindsun commented Jul 1, 2019

I'm seeing the same issue originally identified when loading as a custom vector source. When we identified it, it appeared to work sometimes and not others

image

map:
  regionmap:
    layers:
    - name: "Tanker traffic"
      url: "http://localhost:8000/tanker_traffic_pnw.json"

@nickpeihl
Copy link
Member Author

nickpeihl commented Jul 5, 2019

I spent the day debugging this with @thomasneirynck. Thomas could not recreate the issue consistently while I could.

I tested with Chrome Version 75.0.3770.100 and Firefox Version 67.0.4 on Mac OS Mojave Version 10.14.5.

For debugging, I self-hosted the file per these instructions.

Then I added featureCollection.features.length = <some_number> before this line where some_number is chosen by brute force and binary search until the first array index that causes the error is found. For my situation, the error started occurring at index 4201 in Chrome and 7901 in Firefox. However, this appears to be a rather unique edge case for this dataset.

I decided to stress test the Maps app by generating a million point feature class and loading it into the map (see this patch). Aside from taking a very long time to load 1M features, I received no error.

The only success I found was by commenting out this line. However, I can not determine why that makes a difference. The id is sequentially generated and comes nowhere near the MAX_SAFE_INTEGER. Perhaps there is some issue with mapbox-gl using the id in feature state?

EDIT: I also attempted to re-create a simplified example of how we load data into Kibana to test the dataset. The data loads without error here. However, now I realize we do modify the GeoJSON data to set the feature.id and feature.properties.id. Perhaps we need to test this modified dataset in my example app?

@nickpeihl
Copy link
Member Author

The error appears to throw in the web workers created by mapbox-gl. These workers are minified in the vendor library, however, we can change the imports in Kibana's code to use the unminified library.
import 'mapboxgl' from 'mapbox-gl/dist/mapbox-gl-dev';

Now we can track the error to the specific line in the web worker that is failing. In my testing, the error throws on line 15937 (a sort function). This sort function is self-invoking which might explain the recursion error. However, I'm having trouble today consistently re-creating the error leading me to believe the error is related to available resources on the client machine.

@nickpeihl
Copy link
Member Author

The error appears to be caused by sending an array of already sorted ids to the quicksort function in the mapbox-gl worker code. Sorting an already sorted array is one of the worst-case scenarios for a simple quicksort algorithm which results in the call stack error on client machines without sufficient resources.

@nreese
Copy link
Contributor

nreese commented Oct 4, 2019

closed by #40803

@nreese nreese closed this as completed Oct 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience [Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation v7.3.2 v7.4.0 v8.0.0
Projects
None yet
Development

No branches or pull requests

7 participants