Skip to content

Conversation

zeusongit
Copy link
Contributor

@zeusongit zeusongit commented Jul 9, 2025

Purpose

This PR:

  • Adds deferred node load for graphs above 150 node count.
  • Simplifies node styles
  • Adds node cached images as resx resources.
  • Node progress counter

Profile results (time denotes when the workspace becomes available)

512

OLD NEW
11.41s 4.73s
10.59s 7.2s
9.89s 5.2s

Manekin

OLD NEW
85s 50.5s
82s 48.9s
83s 47.2s

Defload_zoomin
Defload_zoomout
DynamoSandbox_9ZGsSO1zIa

Declarations

Check these if you believe they are true

  • 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
  • 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
  • This PR contains no files larger than 50 MB
  • This PR introduces new feature code involve network connecting and is tested with no-network mode.

Release Notes

Adds deferred node load for graphs above 150 node count.

Reviewers

(FILL ME IN) Reviewer 1 (If possible, assign the Reviewer for the PR)

(FILL ME IN, optional) Any additional notes to reviewers or testers.

FYIs

@achintyabhat

zeusongit and others added 13 commits July 1, 2025 23:05
Introduced a new middleware to handle user authentication for protected routes. This ensures that only authenticated users can access certain endpoints, improving application security.
Replaces the static node loading indicator with an animated progress spinner and detailed loading status in NotificationsControl.xaml. Makes LoadedNodesCount and NodesLoading properties public in WorkspaceViewModel for better data binding. Caches node images after conversion in NodeView.xaml.cs to improve performance.
DYN-8303: Static Field Optimizations
@zeusongit zeusongit requested review from saintentropy, a team and Copilot July 9, 2025 19:15
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-8303

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables deferred loading of node visuals for large graphs, simplifies node styling, and integrates cached node images as embedded resources.

  • Implements deferred node rendering above a node-count threshold with a progress counter
  • Refactors zoom fade styles into shared bindings and cleans up animated styles
  • Adds embedded resource support for node images and wiring in the workspace view model

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
NodeView.xaml.cs Introduces deferred UI loading, bitmap-based port markers, new style bindings, and resource-based node images
WorkspaceViewModel.cs Tracks loaded node count, exposes NodesLoading, and logs load times
PublicAPI.Unshipped.txt Exposes new LoadedNodesCount, NodesLoading, and GetNodeImage APIs
DynamoCoreWpf.csproj Embeds NodeCacheImages.resx as a resource
NotificationsControl.xaml Displays node-loading progress spinner and counter
Comments suppressed due to low confidence (3)

src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs:198

  • [nitpick] Private fields are typically prefixed with _ (e.g. _nodeLoadStopwatch) to distinguish them from properties. Consider renaming for consistency.
        private Stopwatch nodeLoadStopwatch = new Stopwatch();

src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs:605

  • The new NodesLoading property and related deferred-load behavior appear untested. Consider adding unit or integration tests to verify the loading indicator and count logic.
        public bool NodesLoading

src/DynamoCoreWpf/Views/Core/NodeView.xaml.cs:1453

  • Ensure that the embedded resource name matches the manifest path of NodeCacheImages.resx. A mismatch here can cause a null stream and silent failures.
                        var stream = assembly.GetManifestResourceStream("Dynamo.Wpf.NodeCacheImages.resources");

@@ -423,7 +440,7 @@ public NodeView()
Background = Brushes.Transparent,
};

Canvas.SetZIndex(renameIndicator, 5);
SetValue(Panel.ZIndexProperty, 5);
Copy link
Preview

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

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

Calling SetValue here applies ZIndex to the NodeView itself rather than to renameIndicator. You should use renameIndicator.SetValue(Panel.ZIndexProperty, 5); to target the correct element.

Suggested change
SetValue(Panel.ZIndexProperty, 5);
renameIndicator.SetValue(Panel.ZIndexProperty, 5);

Copilot uses AI. Check for mistakes.

var writeableBitmap = new WriteableBitmap(bitmap);

// Define rectangle position and size
int width = 5, height = 29;
Copy link
Preview

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

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

[nitpick] These magic numbers (5, 29) are not self-documenting. Consider extracting them into named constants or adding a comment explaining their origin.

Copilot uses AI. Check for mistakes.

private static readonly Dictionary<string, BitmapImage> _cachedImages =
new Dictionary<string, BitmapImage>(StringComparer.OrdinalIgnoreCase);

//Freeze the static resource to reduce memory overhead... Not sure we need this.
Copy link
Preview

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

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

[nitpick] This TODO-style comment is ambiguous. Either clarify whether freezing is still required or remove it to keep the codebase clean.

Suggested change
//Freeze the static resource to reduce memory overhead... Not sure we need this.
// Freeze the static resources to reduce memory overhead and improve performance.

Copilot uses AI. Check for mistakes.

return result;

// Define the specific invalid characters to remove
char[] invalidChars = { '/', '\\', ':', '*', '?', '"', '<', '>', '|' };
Copy link
Preview

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider using Path.GetInvalidFileNameChars() instead of hard-coding invalid filename characters to keep this list in sync with the underlying OS.

Copilot uses AI. Check for mistakes.

<StackPanel
Orientation="Horizontal" Margin="5,0"
VerticalAlignment="Center">
<Image Name="downloadingIcon"
Copy link
Preview

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

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

[nitpick] Use x:Name instead of Name in XAML to ensure uniqueness across templates and avoid potential conflicts.

Copilot uses AI. Check for mistakes.

<StackPanel
Orientation="Horizontal" Margin="5,0"
VerticalAlignment="Center">
<Image Name="downloadingIcon"
Copy link
Preview

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

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

The progress spinner lacks an automation name or tooltip for screen readers. Consider adding AutomationProperties.Name="Loading nodes" or similar.

Copilot uses AI. Check for mistakes.

}

// Write transparent pixels to the left 5px of the image
writeableBitmap.WritePixels(
Copy link
Preview

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

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

[nitpick] Calling WritePixels in a loop for each port marker may cause UI thread stalls on large graphs. Evaluate batching or offloading to a background thread to improve responsiveness.

Copilot uses AI. Check for mistakes.

zeusongit added 3 commits July 9, 2025 16:55
Replaces the hardcoded list of invalid filename characters with System.IO.Path.GetInvalidFileNameChars() when sanitizing node names. Also removes obsolete API entries related to node image retrieval from the public API file.
@avidit
Copy link
Contributor

avidit commented Jul 30, 2025

@cursor review

Copy link

cursor bot commented Jul 30, 2025

Skipping Bugbot: Unable to authenticate your request. Please make sure Bugbot is properly installed and configured for this repository.

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