Skip to content

usePrettyWriter and precision options for JSON writing#1340

Merged
eundersander merged 6 commits intofacebookresearch:masterfrom
eundersander:eundersander/json_pretty_and_precision
Jun 24, 2021
Merged

usePrettyWriter and precision options for JSON writing#1340
eundersander merged 6 commits intofacebookresearch:masterfrom
eundersander:eundersander/json_pretty_and_precision

Conversation

@eundersander
Copy link
Copy Markdown
Contributor

Motivation and Context

Turning off the PrettyWriter and reducing precision helps reduce filesize for gfx-replay and arrange_recorder.

I also made a small change to how Quaternions are serialized, again to reduce filesize.

How Has This Been Tested

GfxReplayTest was modified to ensure we test precision of serialized/deserialized Quaternions.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have completed my CLA (see CONTRIBUTING)
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Jun 23, 2021
@eundersander eundersander requested a review from jturner65 June 23, 2021 22:01
objAttrMgr->loadAllJSONConfigsFromPath(
Cr::Utility::Directory::join(TEST_ASSETS, "objects/nested_box"), true);

auto handles = objAttrMgr->getObjectHandlesBySubstring("nested_box");
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to the JSON changes: I'm modifying this test to add a render object instance and verify its pose gets serialized/deserialized with reasonable precision.

Copy link
Copy Markdown
Contributor

@jturner65 jturner65 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Left a couple of comments on some minor things (you can take or leave), but otherwise looks great.

auto document = writeKeyframesToJsonDocument();
esp::io::writeJsonToFile(document, filepath);
// replay::Keyframes use floats (not doubles) so this is plenty of precision
const float maxDecimalPlaces = 7;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make an argument with a default value? (standard magic number stuff, not a big deal)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to let the user make a bad decision here like setting it to 0 or 2. This is a decision for Recorder.

Comment thread src/esp/io/JsonUtils.h Outdated
// when writing to json, we often want to clamp tiny floats to 0.0 so they can
// be serialized concisely as "0.0"
template <typename T>
T squashTinyFloats(T x) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are supporting doubles with this, maybe "squashTinyDecimals" ?

@eundersander eundersander merged commit 498d2ec into facebookresearch:master Jun 24, 2021
@eundersander eundersander deleted the eundersander/json_pretty_and_precision branch June 24, 2021 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants