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

Update Magnum from v2019.10 to latest master #496

Merged
merged 2 commits into from Feb 18, 2020
Merged

Update Magnum from v2019.10 to latest master #496

merged 2 commits into from Feb 18, 2020

Conversation

mosra
Copy link
Collaborator

@mosra mosra commented Feb 14, 2020

Motivation and Context

Obsoletes facebookresearch/habitat-lab#295 and unblocks #489.

Was much less painful than I expected it to be. The critically important things this brings:

The seven megatons of other stuff you didn't ask for but get "by the way":

  • Growable Arrays that aim to be faster than std::vector (blogpost is in the pipeline!)
  • New Utility::copy() utility that works on multi-dimensional strided arrays, plus various other utilities related to strided array views, as those will be central to the new asset pipeline
  • Printing file+line with Debug
  • KHR_lights_punctual support in TinyGltfImporter, in case you'd want to import light setup from a file instead of having it hardcoded (ping: @matthewjmay)
  • TinyGltfImporter now supports interleaved vertex attributes, broadening asset compatibility
  • Color support in StanfordImporter, bringing it closer to what we'll need here for PLY files (see also the benchmark below)
  • Cursor and window icon management in GlfwAppliction, in case you want to spice up the viewer utility
  • Everything else that changed since the v2019.10 tag:

There are no known regressions, and no compatibility breakages that would affect the use in Habitat. I also removed one now-obsolete CMake workaround for the Basis submodule and updated all Find modules. The asset pipeline rework (sneak peek benchmark below) is fortunately still in a branch, otherwise this relatively straightforward upgrade wouldn't be possible. The bigger update is yet to come :)

image

How Has This Been Tested

I trust my code ✔️ (and hope the CIs turn green)

@erikwijmans
Copy link
Contributor

Printing file+line with Debug

Oooo, maybe time for swap away from GLOG?

@mosra
Copy link
Collaborator Author

mosra commented Feb 14, 2020

maybe time for swap away from GLOG?

Depends what else from #121 needs to get implemented :)

... the CI is failing on the JS tests and I have no idea what could cause it -- IIRC there wasn't any significant change affecting glTF import that would cause this to break. Is anybody who has the web build set up be able to reproduce this? Or is there a way to get the diff image out of the CI?

@mathfac
Copy link
Contributor

mathfac commented Feb 14, 2020

@mosra, looks like something in rendering changes as visual comparison with previously saved frames changed: https://app.circleci.com/jobs/github/facebookresearch/habitat-sim/6779

@mosra
Copy link
Collaborator Author

mosra commented Feb 14, 2020

@mathfac yeah I know, which is why I asked if somebody could retrieve the diff image for me ;)

Managed to reproduce the difference using the viewer utility, investigating locally.

@mosra
Copy link
Collaborator Author

mosra commented Feb 14, 2020

Okay, it was due to an unfortunate breaking change in Magnum's math lib that I reverted after rethinking the consequences (plus hardened the tests in mosra/magnum@c85b537 and mosra/magnum@4a0f843 to make sure these important properties don't get broken again), but the CI still reports a 11% difference (instead of 90%) and the threshold is 10%.

Is anybody able to reproduce this and get the diff image to verify that everything is okay? Or should we just bump the threshold a bit more? It's getting late here and I don't want to block you by this for yet another day -- @matthewjmay @aclegg3 @erikwijmans if you can check or think it's fine to bump the threshold to 12% or 15%, feel free to do this on this branch :)

@mosra mosra requested a review from aclegg3 February 14, 2020 21:10
@erikwijmans
Copy link
Contributor

@apsdehal I believe you wrote this test in JS? Do you mind verifying that JS is working as expected on this branch?

@erikwijmans
Copy link
Contributor

@mosra I checked the other sensor output tests we have and for the scenes we have on the CI, they don't pass. Everything looks fine and I would be totally happy with changing the value here https://github.com/facebookresearch/habitat-sim/blob/magnum-master/tests/test_sensors.py#L126 to 5.0e-2 (which seems like that's what it would take to make it pass). Interestingly, the Matterport3D tests still pass with the current value.

@mosra
Copy link
Collaborator Author

mosra commented Feb 17, 2020

Wait, so this is an additional failure apart from the JS fail? Interesting.

Should I bump those numbers or are we waiting for a 3rd person to confirm?

@mathfac
Copy link
Contributor

mathfac commented Feb 17, 2020

@mosra bump those numbers to unblock us here. Or Consider update test frames with new values.
cc @apsdehal

@erikwijmans
Copy link
Contributor

Bump the values IMO, things look completely as expected.

@codecov
Copy link

codecov bot commented Feb 18, 2020

Codecov Report

Merging #496 into master will decrease coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #496      +/-   ##
==========================================
- Coverage   59.28%   59.26%   -0.03%     
==========================================
  Files         165      165              
  Lines        7386     7381       -5     
  Branches       84       84              
==========================================
- Hits         4379     4374       -5     
  Misses       3007     3007
Flag Coverage Δ
#CPP 54.66% <100%> (-0.06%) ⬇️
#JavaScript 10% <ø> (ø) ⬆️
#Python 79.49% <ø> (ø) ⬆️
Impacted Files Coverage Δ
src/esp/geo/geo.cpp 34.28% <ø> (ø) ⬆️
tests/test_sensors.py 100% <ø> (ø) ⬆️
src/tests/SimTest.cpp 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9a1fcb2...ac63719. Read the comment docs.

Fixes a few issues that cropped up lately:

-   Removed the ResourceManager singleton that got deprecated in
    v2019.10 to unbreak multithreaded workflows
-   Resource no longer attempts to fetch updated data when not needed
-   TinyGltfImporter now sets shininess to 80 by default, instead of 1
-   A (partial) workaround for crashy BufferTexture on macOS. There's
    still one corner case left to fix but it can be easily prevented in
    the code (see the apple-buffer-texture-unbind-on-buffer-modify
    workaround for details)

No known regressions or compatibility breakages, apart from the single
missing include and a slight difference in how tinygltf parses
transformations, which warranted an update to comparison thresholds.
Also removed a now-obsolete Basis CMake workaround.
@mosra
Copy link
Collaborator Author

mosra commented Feb 18, 2020

Updated the thresholds to make tests pass.

The slight difference in rendering was bothering me, and I managed to track it down to a commit updating the bundled tiny_gltf (which was needed for the updated light extension) -- mosra/magnum-plugins@8fcbf5d. There's a lot happening so I didn't bother digging further in (and I don't think that's necessary), but all clues point to something happening with how numbers are parsed, leading to transformations being slightly different and thus particular parts of the model positioned slightly differently. That's almost unnoticeable except for aliased polygon edges that get jagged differently, as can be seen in the diff (using https://online-image-comparison.com, thanks @erikwijmans for providing me the before/after images):

image

To be sure, I audited all other commits happening since the v2019.10 tag and this commit was the single one responsible for the difference (in particular, checking out the magnum-plugins submodule to a parent of this commit makes the tests pass even without updated thresholds). For performance reasons I'll be switching to cgltf for glTF parsing at some point in the future, so I expect a similar minor difference happening again, but with the increased thresholds I don't think it will cause more CI failures.

@mosra mosra force-pushed the magnum-master branch 2 times, most recently from 24987d7 to ae4c9cc Compare February 18, 2020 16:16
It was also failing and randomly increasing the threshold lead nowhere,
impossible to actually know if the rendering is correct. With this in
place, you get a full per-pixel diagnostic implicitly in the CI log, and
regenerating ground truth image is as simple as passing
--enable-diagnostic to it.
Copy link
Contributor

@mathfac mathfac left a comment

Choose a reason for hiding this comment

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

Thank you for investigating the difference. Looks good to go for me. We should update the test pictures to compete to new etalon.

@mosra
Copy link
Collaborator Author

mosra commented Feb 18, 2020

The SimTest was failing due to similar reasons and because it tested against a value of a single pixel, which is not nearly enough, I ended up rewriting it using Corrade's TestSuite and Magnum's image comparison features. For comparison, this is what the test prints now in case of failure (the thresholds were increased to 15 and 0.17 since to make the test pass). Note the --save-diagnostic hint at the bottom, which was also used to get the ground truth PNG:

image

Now everything should be finally passing again :)

@aclegg3 aclegg3 merged commit ded6bbb into master Feb 18, 2020
@aclegg3 aclegg3 deleted the magnum-master branch February 18, 2020 18:13
Ram81 pushed a commit to Ram81/habitat-web-sim that referenced this pull request Dec 10, 2020
* Update Magnum from v2019.10 to latest master.

Fixes a few issues that cropped up lately:

-   Removed the ResourceManager singleton that got deprecated in
    v2019.10 to unbreak multithreaded workflows
-   Resource no longer attempts to fetch updated data when not needed
-   TinyGltfImporter now sets shininess to 80 by default, instead of 1
-   A (partial) workaround for crashy BufferTexture on macOS. There's
    still one corner case left to fix but it can be easily prevented in
    the code (see the apple-buffer-texture-unbind-on-buffer-modify
    workaround for details)

No known regressions or compatibility breakages, apart from the single
missing include and a slight difference in how tinygltf parses
transformations, which warranted an update to comparison thresholds.
Also removed a now-obsolete Basis CMake workaround.

* Rewrite SimTest using Corrade's TestSuite.

It was also failing and randomly increasing the threshold lead nowhere,
impossible to actually know if the rendering is correct. With this in
place, you get a full per-pixel diagnostic implicitly in the CI log, and
regenerating ground truth image is as simple as passing
--enable-diagnostic to it.
luoj1 pushed a commit to luoj1/habitat-sim that referenced this pull request Aug 16, 2022
* Bug fix in calculating valid area. Check Eq.(51) in "The Double Sphere
Camera Model"

* No need to caclulate for cos value
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.

None yet

5 participants