Skip to content

Conversation

@saintentropy
Copy link
Contributor

@saintentropy saintentropy commented Oct 26, 2022

Purpose

The purpose of this PR is to modify the behavior of the AggregateRenderPackages method. Current method is triggered based on the NodeModel.RenderPackagesUpdated event. Currently a the AggregateRenderPackages modify the RenderPackage object it is handed via the event when it is processing data to add to the view. The issue with this modification is that other consumers this event will receive a modified RenderPackage which does not contain the original data. The PR changes the the RenderPackage data is processed so that it is not modified.

In testing this PR I also noticed some scenarios today which Render incorrectly. Edge cases where a list is created combining objects that are rendered via instance data, objects with texture maps, and regular geometry.

Todo

  • Add tests for broken render scenarios
  • Add tests to validate no changes to the RenderPackage

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

Release Notes

Update API behavior for AggregateRenderPackages.
Fix regressions in background preview render for some list of objects.

Reviewers

@mjkkirschner @aparajit-pratap

FYIs

@twastvedt

@mjkkirschner
Copy link
Member

Hi @saintentropy

  1. please use the reviewers section in github when possible
  2. It seems there are 2 failing tests here that are real, one is a UI test that is flaky. FYI @QilongTang
  3. What release is this intended for?

@mjkkirschner
Copy link
Member

@saintentropy to review this for correctness I think I'm going to need a more detailed description about what was changed/ how it works - at this point I have no memory of / bandwidth to get deep into this code.

@mjkkirschner mjkkirschner added this to the 2.17.0 milestone Oct 28, 2022
@mjkkirschner mjkkirschner self-requested a review October 29, 2022 02:58
Copy link
Member

@mjkkirschner mjkkirschner left a comment

Choose a reason for hiding this comment

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

it seems okay, a few questions, and I think it would be good if we could create a regression test for the failure - maybe 2 subscribers to the event?

ViewModel.RenderPackageFactoryViewModel.ShowEdges = true;
//this graph displays a grid, cones, cone edges, cube instances, cube edge instances.
Assert.AreEqual(3, BackgroundPreviewGeometry.NumberOfVisibleCurves());
Assert.AreEqual(2, BackgroundPreviewGeometry.NumberOfVisibleCurves());
Copy link
Member

Choose a reason for hiding this comment

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

grid lines, cube edges and cone edges are not 3 visible curve objects?

Copy link
Contributor Author

@saintentropy saintentropy Nov 3, 2022

Choose a reason for hiding this comment

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

Yeah this is where there was a error in the original test. NumbersOfVisibleCurves removes grids from the number it returns. So the expected behavior is 2. Cube edges and Cone Edges. Not sure what the third was before. Probably an empty item.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same for the axes but I can't remember if that is curve or mesh geometry.

var startIndex = range.Item1; //Start line vertex index
var count = range.Item2 - range.Item1 + 1; //Count of line vertices
var uniqueId = baseId + ":" + j + LinesKey;
var uniqueId = baseId + ":" + j + LinesKey + "_Instance";
Copy link
Member

Choose a reason for hiding this comment

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

whats this change about?

Copy link
Contributor Author

@saintentropy saintentropy Nov 3, 2022

Choose a reason for hiding this comment

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

The current implementation has a collision on uniqueIds if a render package contains instanced mesh and multiple texture maps. This change just makes sure the unique Ids for each type of helix geometry is actually unique.

var startIndex = range.Item1; //Start mesh vertex index
var count = range.Item2 - range.Item1 + 1; //Count of mesh vertices
var uniqueId = baseId + ":" + j + MeshKey;
var uniqueId = baseId + ":" + j + MeshKey + "_Texture";
Copy link
Member

Choose a reason for hiding this comment

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

oh I see, just to make debugging it easier?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See above but yes

@twastvedt
Copy link
Contributor

it seems okay, a few questions, and I think it would be good if we could create a regression test for the failure - maybe 2 subscribers to the event?

I'm looking into making this test. As far as I can tell I need to be able to modify the feature flags, as the issue only happens when the graphics-primitive-instancing flag is false, but in test mode that flag is set to true. I did a little looking around but didn't see another place where those flags are being modified. Does that sound right, and is that possible?

@mjkkirschner
Copy link
Member

mjkkirschner commented Nov 10, 2022

it seems okay, a few questions, and I think it would be good if we could create a regression test for the failure - maybe 2 subscribers to the event?

I'm looking into making this test. As far as I can tell I need to be able to modify the feature flags, as the issue only happens when the graphics-primitive-instancing flag is false, but in test mode that flag is set to true. I did a little looking around but didn't see another place where those flags are being modified. Does that sound right, and is that possible?

Hi @twastvedt - maybe @saintentropy can confirm - I thought this issue only happened when instancing was true!?

But if you need to modify the flags during your test for some reason - I think what you can do is make this property internal and set it:
https://github.com/DynamoDS/Dynamo/blob/master/src/Tools/DynamoFeatureFlags/FeatureFlagsClient.cs#L86
then set it back.

or maybe it's easier to just override this cache, since it's in the same process:

AllFlagsCache = JsonConvert.DeserializeObject<Dictionary<string, object>>(dataFromCLI);

@twastvedt
Copy link
Contributor

Hi @twastvedt - maybe @saintentropy can confirm - I thought this issue only happened when instancing was true!?

OK, found a couple things.

  1. Now remembering that Craig tried to tell me that I can just test the multiple texture maps part of this, as that doesn't depend on a feature flag. Doing that!
  2. But, for reference, it looks like AggregateRenderPackages only modifies the render package if the geometry uses instancing but the flag is set to false (https://github.com/DynamoDS/Dynamo/blob/master/src/DynamoCoreWpf/ViewModels/Watch3D/HelixWatch3DViewModel.cs#L1868-L1869). Otherwise I think it's just sending the render package with instancing embedded directly to Helix. I'm fuzzy on the details still though.

At any rate, I added a test which I verified fails before the PR, now passes. Still looking at the rendering edge cases.

@twastvedt twastvedt removed the WIP label Nov 15, 2022
@twastvedt
Copy link
Contributor

@mjkkirschner I think this is ready to go? Just wanted to give you the chance to look at the test I added, if you want to. It's pretty straightforward though. I added an image comparison test which checks for the render bug Craig discovered in the process of this PR. I verified that it renders something different (the bug) before this PR's changes.

@mjkkirschner
Copy link
Member

thanks @twastvedt - I will merge now, can you please cherry pick the squashed commit to 2.17?

@mjkkirschner mjkkirschner merged commit 104ac05 into DynamoDS:master Nov 15, 2022
twastvedt added a commit that referenced this pull request Nov 15, 2022
#13437)

* Leave RP data intact

* Fix tests

* Remove unnessary code

* Spelling typos and clean up

* clean up

* clean up

* Add regression test for render package mutation.

* Unsubscribe from event.

* Add image comparison test for render bug.

* Fix test image size.

Co-authored-by: Craig Long <craig.long@autodesk.com>
Co-authored-by: Trygve Wastvedt <trygve.wastvedt@autodesk.com>
(cherry picked from commit 104ac05)
QilongTang pushed a commit that referenced this pull request Nov 16, 2022
#13437) (#13519)

* Leave RP data intact

* Fix tests

* Remove unnessary code

* Spelling typos and clean up

* clean up

* clean up

* Add regression test for render package mutation.

* Unsubscribe from event.

* Add image comparison test for render bug.

* Fix test image size.

Co-authored-by: Craig Long <craig.long@autodesk.com>
Co-authored-by: Trygve Wastvedt <trygve.wastvedt@autodesk.com>
(cherry picked from commit 104ac05)

Co-authored-by: Craig Long <craig.alan.long@gmail.com>
QilongTang pushed a commit that referenced this pull request Jul 12, 2023
#13437)

* Leave RP data intact

* Fix tests

* Remove unnessary code

* Spelling typos and clean up

* clean up

* clean up

* Add regression test for render package mutation.

* Unsubscribe from event.

* Add image comparison test for render bug.

* Fix test image size.

Co-authored-by: Craig Long <craig.long@autodesk.com>
Co-authored-by: Trygve Wastvedt <trygve.wastvedt@autodesk.com>
@QilongTang QilongTang mentioned this pull request Jul 12, 2023
9 tasks
QilongTang added a commit that referenced this pull request Jul 13, 2023
* Fixing horizontal center (#13312)

* Fix Trusted Message behavior (#13355)

* Fix Trusted Message behavior

* Extract Business Logic as a function

* Moving API to Preferences

* Adding unit test

* Leave RenderPackage data intact when passed to AggregateRenderPackages (#13437)

* Leave RP data intact

* Fix tests

* Remove unnessary code

* Spelling typos and clean up

* clean up

* clean up

* Add regression test for render package mutation.

* Unsubscribe from event.

* Add image comparison test for render bug.

* Fix test image size.

Co-authored-by: Craig Long <craig.long@autodesk.com>
Co-authored-by: Trygve Wastvedt <trygve.wastvedt@autodesk.com>

* DYN-5437 Export image button shortcut (#13550)

* Insert the export command in the shortcut view model

* remove test method

* Dyn 5317 check webview2 installed (#13464)

* DYN-5317-Check-WebView2-Installed

I added a validation that before starting the DynamoSandbox app we will check if the WebView2 Runtime is installed or not, if is not installed we will show a MessageBox with the  link of the WebView2 installer and then after pressing the OK button close Dynamo.
Also in the DynamoMessageBox I added a RichTextBox that will be visible under very specific circumstances, this RichTextBox allows to have a blue hyperlink as a part of the text so the user can click it and open the webview2 installer webpage.

* DYN-5317-Check-WebView2-Installed

removing extra comment

* DYN-5674-CustomNode-Renamed (#13854)

After the auto-save functionality is triggered when we are located in the Custom Node edit tab when the node in the Home Workspace is being renamed to "backup". Then after my fix first is checking if it has a name and file associated (that usually happen when you create/edit a custom node) if that is the case then we don't execute the rename process.
Also I added a test that will validate that the Save functionality doesn't rename the CustomNode name.

* clean up

---------

Co-authored-by: jesusalvino <96534278+jesusalvino@users.noreply.github.com>
Co-authored-by: Craig Long <craig.alan.long@gmail.com>
Co-authored-by: Craig Long <craig.long@autodesk.com>
Co-authored-by: Trygve Wastvedt <trygve.wastvedt@autodesk.com>
Co-authored-by: filipeotero <89042471+filipeotero@users.noreply.github.com>
Co-authored-by: Roberto T <61755417+RobertGlobant20@users.noreply.github.com>
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