Skip to content

Commit

Permalink
DYN-6449 Graph Loading Performance Improving (#14929)
Browse files Browse the repository at this point in the history
* DYN-6449 Graph Loading Performance Improving

Using Jetbrains dotTrace I noticed that creating the NodeView for Watch nodes was taking too much time when loading the Graph (due that was creating the PreviewControl), then due that Watch nodes doesn't have Preview I've added code for preventing the creation of the PreviewControl, this improved the Graph loading time.
Also I've noticed that the call nodeView.UpdateLayout() was consuming loading time so I've modified the code in a way that the method call will be executed asynchronous in background.

* DYN-6449 Graph Loading Performance Improving Code Review

Removing the nodeView.UpdateLayout(); call in the PythonNode.

* DYN-6449 Graph Loading Performance Improving Code Review

Deleting not necessary call to nodeView.UpdateLayout() for CustomNodes
  • Loading branch information
RobertGlobant20 authored Feb 14, 2024
1 parent 0ecd795 commit a4d26ea
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Windows.Controls;
using System.Windows.Threading;
using Dynamo.Controls;
using Dynamo.Graph.Nodes.CustomNodes;
using Dynamo.Graph.Workspaces;
Expand Down Expand Up @@ -59,8 +61,6 @@ public void CustomizeView(Function function, NodeView nodeView)

publishCustomNodeItem.Command = nodeView.ViewModel.DynamoViewModel.PublishSelectedNodesCommand;
publishCustomNodeItem.CommandParameter = functionNodeModel;

nodeView.UpdateLayout();
}

private void EditCustomNodeProperties()
Expand Down Expand Up @@ -136,4 +136,4 @@ public void Dispose()

}
}
}
}
8 changes: 7 additions & 1 deletion src/DynamoCoreWpf/Views/Core/NodeView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
Expand Down Expand Up @@ -551,6 +551,9 @@ private void OnNodeViewMouseLeave(object sender, MouseEventArgs e)
{
ViewModel.ZIndex = oldZIndex;

//Watch nodes doesn't have Preview so we should avoid to use any method/property in PreviewControl class due that Preview is created automatically
if (ViewModel.NodeModel != null && ViewModel.NodeModel is CoreNodeModels.Watch) return;

// If mouse in over node/preview control or preview control is pined, we can not hide preview control.
if (IsMouseOver || PreviewControl.IsMouseOver || PreviewControl.StaysOpen || IsMouseInsidePreview(e) ||
(Mouse.Captured is DragCanvas && IsMouseInsideNodeOrPreview(e.GetPosition(this)))) return;
Expand Down Expand Up @@ -731,6 +734,9 @@ internal void TogglePreviewControlAllowance()
{
previewEnabled = !previewEnabled;

//Watch nodes doesn't have Preview so we should avoid to use any method/property in PreviewControl class due that Preview is created automatically
if (ViewModel.NodeModel != null && ViewModel.NodeModel is CoreNodeModels.Watch) return;

if (previewEnabled == false && !PreviewControl.StaysOpen)
{
if (PreviewControl.IsExpanded)
Expand Down
4 changes: 2 additions & 2 deletions src/Libraries/PythonNodeModelsWpf/PythonNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Threading;
using Dynamo.Configuration;
using Dynamo.Controls;
using Dynamo.Graph.Nodes;
Expand Down Expand Up @@ -99,8 +100,7 @@ public void CustomizeView(PythonNode nodeModel, NodeView nodeView)
PythonEngineManager.Instance.AvailableEngines.CollectionChanged += PythonEnginesChanged;

nodeView.MainContextMenu.Items.Add(learnMoreItem);

nodeView.UpdateLayout();


nodeView.MouseDown += View_MouseDown;
nodeModel.DeletionStarted += NodeModel_DeletionStarted;
Expand Down

0 comments on commit a4d26ea

Please sign in to comment.