-
Notifications
You must be signed in to change notification settings - Fork 469
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
Core Metadata: Language pass for binary table format #493
Conversation
Two questions questions below, copied because these lines aren't part of the diff —
I'm not sure that I understand the recommendation of "highest precision floats available". For a normalized UINT16 value, float32 (23-bit mantissa) should be sufficient. For a normalized UINT8 value, float16 (11-bit mantissa) should be sufficient. Does this note intend to suggest float64 in both cases, or could we rephrase this? For example:
Similarly this may need to be clarified, but I'd like to check the intended meaning first. JSON allows floating-point numbers of any precision, but obviously programming languages have limitations. Would this be a fair way of rephrasing the line?
Similarly – many (but not all) JSON parsers will round int64 and friends. Do we:
|
I'd have to re-read the "before" and "after" versions in parallel with the diffs (also that of the individual commits) in order to better understand the actual changes (but in doubt, I could focus on reading the resulting state and see whether something pops out).
A wild guess: This was probably phrased like this to be "on the safe side", as in ~"you cannot do anything wrong with Regarding the number encoding in JSON ... you know that there has been an extensive discussion about that at KhronosGroup/glTF#1574 (just as a pointer for ptrgags/lilleyse ). The relevant part of how this was resolved seems to be the statement that was added at https://github.com/KhronosGroup/glTF/pull/1997/files#diff-ca628c11679a8c4c0c4031440c7c1cda27c8896ebc87c3bd1e8640efc8942d99R424
Edit: Sorry, this referred to the non-integer numbers. For integer numbers, the spec refers to https://datatracker.ietf.org/doc/html/rfc8259#section-6 which points out possible issues with interoperabiltiy, and gives more details about the constraints. As I said in the PR: It's difficult for a "file format spec (that is built on JSON)" to specify aspects of JSON itself. Explicit warnings about |
Thanks @javagl! I agree about not specifying aspects of JSON itself, and I don't think that strict requirements with regard to serialization or deserialization would improve this PR. Most of the 3D Tiles spec is JSON, so any such requirements should probably go in the base specification's JSON encoding section rather than here. Proposed:
I suggest that we rephrase this in terms of appropriate precision instead of highest precision. There is no reason to use Float64 to store the result of a denormalized uint8.
Perhaps neither of these should be included? I don't really know what the first line intends to prevent. And the second is merely a suggestion for efficiency, which (a) might fit better in the base specification, and (b) is incompatible with 64-bit types here.
I do think that if we are defining a JSON encoding that purports to support 64-bit types — which neither glTF nor the base 3D Tiles specification do — we must be clear about how that is supported, or that it isn't supported. At this point, my own suggestion would be to prohibit 64-byte types in the JSON encoding. The only viable implementation on the web today would involve (de)serializing them as strings... JSON.stringify(
{value: 12345678912345678912n},
(_, v) => typeof v === 'bigint' ? v.toString() : v
); ...and we probably don't want to add that complexity without need. We can consider loosening the restriction later if there's a need and a feasible way to implement it, but given the JSON encoding is intended for small amounts of human-readable data, it does not seem like 64-bit types are a critical use case for it. |
Might need @ptrgags's insight here, but your suggestion seems good.
I agree that we need language like this in the core 3D Tiles spec. Some examples that come to mind
That was the intent behind the language Essentially I'm good with copying the glTF rules for JSON encoding and putting them in the JSON encoding section. That's what we originally did, glTF's rules just got more precise over time and the 3D Tiles spec never got updated 😄
Not sure what to do here for 64-bit integers, but it goes beyond this spec (thinking back to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@donmccurdy almost there, just a couple small tweaks.
Oh and make sure to resolve the merge conflict |
oh to answer the questions above:
yeah that's tricky... I would still allow 64-bit integer types anywhere, just maybe put an implementation note that JSON doesn't support values outside the safe range. e.g. we wouldn't want to rule out a Yeah "appropriate" precision makes sense here.
keep the existing wording by @lilleyse's reasoning. Though do mention that it's |
Didn't quite follow your meaning in "JSON doesn't support values outside the safe range..." ... I don't think the JSON format has any such limitation, even though most implementations probably do. So you're suggesting an implementation note warning that many implementations will not support values outside [define safe range here]? And if so, do we mean the safe range of IEEE-754 double precision float?
With "must" we're making a strong requirement, and I don't think this wording is enough – IEEE-754 includes up to octuple-precision float256, additionally. How about:
(SHOULD italicized and capitalized for emphasis in this comment only) |
@donmccurdy ah you're right, it's not the JSON but the implementations (JS in particular) that have issues. But yes, I think we should leave this as an implementation note for now. And yes safe range for a 64-bit int within a IEEE-754 double-precision number. The thing with "should" is does that imply that the number could be encoded in some non-IEEE-754 format? e.g. a fixed-point float? we don't want that. If all the numbers fit in a |
@ptrgags sounds good to me, OK with something like this?
I think that's the situation, though — "should" might be the best we can do here. We're supporting int64 and uint64, and those values in JSON encoding (or their min/max in schema for binary encoding) could be outside of the IEEE-754 double precision safe range. Similarly, the glTF specification only uses "should", perhaps partly to require JSON encoders to do things that the JSON spec does not itself require. |
@donmccurdy okay, let's go with this new wording |
292f869
to
04f1b93
Compare
Core Metadata: Hierarchy and table format language pass. Core Metadata: Clean up. Update specification/Metadata/README.md Co-authored-by: Peter Gagliardi <ptrgags@gmail.com>
04f1b93
to
d30ff55
Compare
The updates look good, thanks @donmccurdy! |
This PR is branched from #490 (which removes the raster format); it may be better to review that PR first.
Changes:
Next PR will add language changes for JSON table format.