Comments (17)
This issue should be resolved with the most recent 4.1.0 release. I have been able to use the 4.1.0 dist directly in WebWorkers now greatly speeding up computations :)
from h3-js.
It looks like the bug on the Emscripten side (emscripten-core/emscripten#14198) was fixed as of November of last year. Would it be possible to cut a new h3-js release with the latest emscripten, which hopefully will make this library React Native compatible?
from h3-js.
It looks like the bug on the Emscripten side (emscripten-core/emscripten#14198) was fixed as of November of last year. Would it be possible to cut a new h3-js release with the latest emscripten, which hopefully will make this library React Native compatible?
I'm trying to use h3-js in a web-worker and I have the same problem. It would be great if a new h3-js release was published with the latest emscripten version
from h3-js.
With Deno's recent support for npm packages, you may now use a regular import like
import * as h3 from "npm:[email protected]";
Easy enough, but non-standard and won't help people on other runtimes (and not even Deno Deploy as the feature is experimental). It would be great if h3-js could simply get rid of the document
-reference.
from h3-js.
See #35 - this is a known issue. We're not currently targeting React Native; I'd like this to work, obviously, but the issue is deep in the emscripten internals and hard to remove. There's a fork here that tries to address this, but I haven't had time to see if it can be fixed in the main library, and I don't have a great way to test the fix.
from h3-js.
A very simple way to fix it is to change the generated code in dist from:
if (document.currentScript) {
scriptDirectory = document.currentScript.src;
}
to
if (ENVIRONMENT_IS_WEB) {
if (document.currentScript) {
scriptDirectory = document.currentScript.src;
}
}
Note that ENVIRONMENT_IS_WEB should be defined. I think it is generated by emscripten
=> emscripten-core/emscripten#6717
I created an issue on their github
from h3-js.
I will note that the reason why emscripten was not updated for this project was due to performance regressions with asm.js compilation on newer releases of emscripten than the version that is in use (likely due to asm.js being a less-common usage of emscripten these days).
Upgrading emscripten is not without trade-offs.
from h3-js.
I will note that the reason why emscripten was not updated for this project was due to performance regressions with asm.js
Oh interesting, I wasn't aware! Are there benchmarks for how large the impact would be on this library if it adopted the latest emscripten? Making this compatible with h3 would be really nice, but of course not at the cost of a significant performance regression for other users!
from h3-js.
It was a few years ago that we noticed the regression. I searched but couldn't find the benchmark we did back then. As I recall some functions were unaffected but most functions were 10-20% slower and a few were more than 50% slower but since it has literally been years in the meantime, it's probably a good idea to try again and re-benchmark against the current version of emscripten.
from h3-js.
I would also be interested in a version of h3-js that works on the server.
I tried updating to the latest version of Emscripten to at least get a benchmark but I couldn't get it to work.
MODULARIZE_INSTANCE=1
is deprecated so you have to useMODULARIZE=1
instead, which returns a function which returns a promise that resolves to an instance.- Also I think you need to explicitly export
_free
now.
from h3-js.
I would also be interested in a version of h3-js that works on the server.
To be clear, h3-js
works fine on a server running Node. It only has issues running in React Native.
from h3-js.
Sorry I misspoke. It doesn't work with vercel's edge runtime / middleware.
Same error as react native.
ReferenceError: document is not defined
from h3-js.
Thanks for the clarification, that's good to know.
from h3-js.
This issue will bite any JavaScript runtime that has no global document
.
For Deno I found a workaround a while ago that involved dynamic import:
const document = {};
const h3 = await import("https://esm.sh/[email protected]");
const h3Index = h3.latLngToCell(37.3615593, -122.0553238, 7);
console.warn(h3Index);
// 87283472bffffff
from h3-js.
I've encountered this issue when trying to use h3 inside a web-worker as well; edited, I didn't see @padawannn 's comment :)
from h3-js.
Related discussion, with benchmarks for the emscripten upgrade issue: #163 (comment)
from h3-js.
Thanks @4nthonylin! Closing for now - there may be other blockers for React Native or unusual environments, but hopefully this is a reasonable fix for many of the affected situations.
from h3-js.
Related Issues (20)
- Documentation of the [lat, lng] tuple HOT 4
- some h3index values create distorted long horizontal line on map HOT 1
- compactCells throws error HOT 1
- Openlayers instead of Mapbox HOT 1
- Count the number of points in the aggregated bins of H3-hexagons HOT 3
- Upgrade emscripten to 3.X.X? HOT 7
- Integrating with google maps HOT 1
- How to replace firestore geofire with h3? HOT 3
- Potential memory leak in polygonToCells HOT 10
- Load and Display H3-JS binned dataset in Mapbox HOT 1
- Consider buffer radius in addition to H3 resolution when counting points in the aggregated bins of H3-hexagons HOT 2
- Inverted coordinates HOT 1
- H3-JS binning resoluion in OpenLayers HOT 1
- Incorrect result from polygonToCells for bigger screen/ higher dimensions HOT 6
- Error when passing zero area polygon to h3.polygonToCells HOT 2
- Does h3-js send any data to the server? HOT 1
- I am unable to load h3-JS in my quasar project HOT 3
- H3 with dynamodb
- Different output from h3-js and postgis using cellToBoundary function HOT 1
- Hexagons Resolution HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from h3-js.