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

Avoid Helix crash due to edge double values #11031

Merged
merged 2 commits into from
Aug 24, 2020

Conversation

mmisol
Copy link
Collaborator

@mmisol mmisol commented Aug 20, 2020

Purpose

This prevents the display of geometry located in positions considered
invalid by Helix. This includes the special values PositiveInfinity,
NegativeInfinity and NaN.

Also NaN is checked as a special value when unmarhsalling data from an
FFI. Special values PositiveInfinity and NegativeInfinity were already
handled. This allows to generate a warning over the node with an
appropriate message.

Here is a screenshot of how the message looks:

NaN

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated

Reviewers

@mjkkirschner @aparajit-pratap

FYIs

@DynamoDS/dynamo

This prevents the display of geometry located in positions considered
invalid by Helix. This includes the special values PositiveInfinity,
NegativeInfinity and NaN.

Also NaN is checked as a special value when unmarhsalling data from an
FFI. Special values PositiveInfinity and NegativeInfinity were already
handled. This allows to generate a warning over the node with an
appropriate message.
if (!package.Points.Positions.Any(v => v.IsInvalid()) &&
!package.Lines.Positions.Any(v => v.IsInvalid()) &&
!package.Mesh.Positions.Any(v => v.IsInvalid()))
{
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this will cause a significant slowdown.

Copy link
Member

@mjkkirschner mjkkirschner Aug 20, 2020

Choose a reason for hiding this comment

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

it sure seems like it could - for an alternative, what about checking this during package creation, since at that point we have to iterate over every vertex anyway.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The checks should be quick. The amount will grow with geometry, but should be a very low percentage in comparison.

@mjkkirschner What do you mean by package creation? To check it as soon as the geometry is added to the package?

Copy link
Member

Choose a reason for hiding this comment

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

yes, exactly, since we already need to iterate over each vertex at that point. It may not be possible though if some render packages are created in LibG code.

Copy link
Member

Choose a reason for hiding this comment

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

GetRenderPackagesFromMirrorData is the function I am thinking of.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

unfortunately, these tests don't tessellation or view interactions at the moment. 😢

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought @QilongTang added the ability to measure tessellation performance as well: #9651

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Did a couple of runs with the tests I added here. I would say the results were not conclusive:

With a sampling of 3, total time in seconds compiling assets for rendering:

First run:
Master: 60.68702
Branch: 63.96409

Second run:
Master: 62.36558
Branch: 58.82862

Theoretically, doing the check first or later should not make a difference. This is still o(n) based on the size of the packages collection. Also, not sure if it's a good idea to change GetRenderPackagesFromMirrorData for a Helix-specific check. I would say to leave it like this unless there are any objections.

// Nodes should be set to warning status with an appropriate message
var nanNode = Model.CurrentWorkspace.Nodes.First(n => n.Name == "NaN");
Assert.AreEqual(ElementState.Warning, nanNode.State);
StringAssert.Contains("'NaN' is being cast to 'Double'", nanNode.ToolTipText);
Copy link
Contributor

@aparajit-pratap aparajit-pratap Aug 20, 2020

Choose a reason for hiding this comment

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

@mmisol are these warning messages coming from .net or are we creating them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They come from us, from CLRObjectMarshaller.

Copy link
Contributor

@aparajit-pratap aparajit-pratap left a comment

Choose a reason for hiding this comment

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

Couple of questions.

@mmisol mmisol merged commit 1a1addf into DynamoDS:master Aug 24, 2020
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.

3 participants