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

[WIP] Handling unsafe integers #115

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

zachasme
Copy link

@zachasme zachasme commented Dec 12, 2019

Hi there!

This is related to #44 and mostly intended to initiate a discussion about integers larger than MAX_SAFE_INTEGER.

It is also the result of me trying to figure out why managing a single feature (from a vector source) on my Mapbox GL map sometimes affected multiple features.

The problem, as far as I can tell, is that there is no distinction between 32bit and 64bit varint. That means subtle bugs may (silently) be introduced when (de)serializing numbers above MAX_SAFE_INTEGER (2^53 - 1).

In my case the features on my map are hexagons based on Ubers h3 hierarchical grid (represented using uint64 ids, and generated using PostGIS' ST_AsMVT). When setting feature state on some of the higher resolution hexagons, the equally check breaks and multiple cells are affected even though their ids are unique (in the protobuf).

I can't see any way to solve this without introducing a breaking change that represents 64bit integers as either strings, number arrays or BigInt.

This PR uses BigInt because it was the simplest, but as stated earlier I am mostly interested in your thoughts on the issue. My goal is to achieve support for uint64 ids Mapbox GL JS vector sources.

@zachasme
Copy link
Author

zachasme commented Oct 5, 2020

BigInt support has landed in Safari.

Any thoughts on the PR?

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

Successfully merging this pull request may close these issues.

None yet

1 participant