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

Too Much Recursion #30

Open
yourealwaysbe opened this issue Feb 7, 2015 · 4 comments
Open

Too Much Recursion #30

yourealwaysbe opened this issue Feb 7, 2015 · 4 comments

Comments

@yourealwaysbe
Copy link

Hi,

I've been playing with the PBF parser for reading OSM data into a (experimental) web app. However, reading large files results in a "too much recursion error"

too much recursion osm-read-pbf.js:2269

This happens, for example, with the South Yorkshire PBF available here.

Is it possible to fix this, or is it an intrinsic problem with trying to read PBF in Javascript :)

@nrenner
Copy link
Collaborator

nrenner commented Feb 9, 2015

Can reproduce the error in Firefox. Chromium works with South Yorkshire (14,4 MB), but hangs with a larger file (older Berlin, 29,4 MB).

I'm having some troubles debugging this in Firefox, and updating dependencies needs some work. Will look further into this.

Don't know what your use case is, but for rendering on a map, splitting the data into vector tiles might help.

@yourealwaysbe
Copy link
Author

Thanks for looking into it. This was just for an experiment which i've concluded successful enough (but continue to play with), so there's no rush on a fix :)

@nrenner
Copy link
Collaborator

nrenner commented Feb 14, 2015

The reason for this error is trying to execute Node.js-style callback code synchronously in the Browser. The recursive loop in visitNextBlock then leads the call stack to pile up.

As a fix I added an asynchronous call in the arrayBufferReader.

In addition, there is now a new reader for the HTML5 File API that uses async, sliced reading, see README and example/file.html on how to use it. Furthermore, you can already load a PBF file yourself with FileReader.readAsArrayBuffer() and pass the result as buffer option. Both ways of using the File API have the advantage that there is no restriction on accessing local files as there is when using XHR (implicitly by passing a filePath).

This was just for an experiment ...

Nice idea to tile into indexedDB! Would be great if this could be used with an existing renderer/map lib. My approach requires the Mapsplit commandline tool to generate PBF tiles.

@yourealwaysbe
Copy link
Author

Cool, many thanks for this. I'll check it out :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants