Skip to content

Commit

Permalink
improve performance of bubbleINfo (#15129)
Browse files Browse the repository at this point in the history
* improve performance of bubbleINfo

* Create Performance-Test.dyn
  • Loading branch information
pinzart90 authored Apr 22, 2024
1 parent c9f6dda commit a127282
Show file tree
Hide file tree
Showing 6 changed files with 36,142 additions and 35 deletions.
4 changes: 4 additions & 0 deletions src/DynamoCore/Graph/Nodes/NodeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,10 @@ internal ObservableHashSet<Info> Infos
get { return infos; }
}

/// <summary>
/// BlockInfoBubbleUpdates is flag used to block InfoBubble updates during (or immediately after) graph execution.
/// </summary>
internal bool BlockInfoBubbleUpdates = false;

/// <summary>
/// A publicly accessible collector of all Info/Warning/Error data
Expand Down
8 changes: 8 additions & 0 deletions src/DynamoCore/Graph/Workspaces/HomeWorkspaceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,11 @@ private void OnUpdateGraphCompleted(AsyncTask task)
var node = workspace.Nodes.FirstOrDefault(n => n.GUID == guid);
if (node == null)
continue;

// Block Infos updates during the many errors/warnings/notifications added here
// InfoBubbles will be updated on NodeViewModel's EvaluationCompleted handler.
using (node.PropertyChangeManager.SetPropsToSuppress(nameof(NodeModel.Infos), nameof(NodeModel.State)))
using (Disposable.Create(() => { node.BlockInfoBubbleUpdates = true; }, () => { node.BlockInfoBubbleUpdates = false; }))
{
node.Warning(warning.Value); // Update node warning message.
}
Expand All @@ -711,7 +715,11 @@ private void OnUpdateGraphCompleted(AsyncTask task)
var node = workspace.Nodes.FirstOrDefault(n => n.GUID == guid);
if (node == null)
continue;

// Block Infos updates during the many errors/warnings/notifications added here
// InfoBubbles will be updated on NodeViewModel's EvaluationCompleted handler.
using (node.PropertyChangeManager.SetPropsToSuppress(nameof(NodeModel.Infos), nameof(NodeModel.State)))
using (Disposable.Create(() => { node.BlockInfoBubbleUpdates = true; }, () => { node.BlockInfoBubbleUpdates = false; }))
{
node.Info(string.Join(Environment.NewLine, info.Value.Select(w => w.Message)));
}
Expand Down
29 changes: 19 additions & 10 deletions src/DynamoCoreWpf/ViewModels/Core/NodeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1256,10 +1256,17 @@ private void UpdateErrorBubbleWidth()
/// </summary>
private void BuildErrorBubble()
{
if (ErrorBubble == null) ErrorBubble = new InfoBubbleViewModel(this)
if (ErrorBubble == null)
{
IsCollapsed = this.IsCollapsed
};
ErrorBubble = new InfoBubbleViewModel(this)
{
IsCollapsed = this.IsCollapsed,
// The Error bubble sits above the node in ZIndex. Since pinned notes sit above
// the node as well and the ErrorBubble needs to display on top of these, the
// ErrorBubble's ZIndex should be the node's ZIndex + 2.
ZIndex = ZIndex + 2
};
}

ErrorBubble.NodeInfoToDisplay.CollectionChanged += UpdateOverlays;
ErrorBubble.NodeWarningsToDisplay.CollectionChanged += UpdateOverlays;
Expand All @@ -1273,14 +1280,8 @@ private void BuildErrorBubble()
WorkspaceViewModel.Errors.Add(ErrorBubble);
});
}

// The Error bubble sits above the node in ZIndex. Since pinned notes sit above
// the node as well and the ErrorBubble needs to display on top of these, the
// ErrorBubble's ZIndex should be the node's ZIndex + 2.
ErrorBubble.ZIndex = ZIndex + 2;

// The Node displays a count of dismissed messages, listening to that collection in the node's ErrorBubble

ErrorBubble.DismissedMessages.CollectionChanged += DismissedNodeMessages_CollectionChanged;
}

Expand Down Expand Up @@ -1464,7 +1465,15 @@ private void DisposeErrorBubble()

public void UpdateBubbleContent()
{
if (DynamoViewModel == null) return;
if (NodeModel.BlockInfoBubbleUpdates)
{
return;
}

if (DynamoViewModel == null)
{
return;
}

bool hasErrorOrWarning = NodeModel.IsInErrorState || NodeModel.State == ElementState.Warning;
bool isNodeStateInfo = NodeModel.State == ElementState.Info || NodeModel.State == ElementState.PersistentInfo;
Expand Down
8 changes: 5 additions & 3 deletions src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,8 @@ void Model_NodeRemoved(NodeModel node)
lock (Nodes)
{
nodeViewModel = Nodes.First(x => x.NodeLogic == node);
Errors.Remove(nodeViewModel.ErrorBubble);
if (nodeViewModel.ErrorBubble != null)
Errors.Remove(nodeViewModel.ErrorBubble);
Nodes.Remove(nodeViewModel);
}
//unsub the events we attached below in NodeAdded.
Expand All @@ -904,8 +905,9 @@ void Model_NodeAdded(NodeModel node)
{
Nodes.Add(nodeViewModel);
}
Errors.Add(nodeViewModel.ErrorBubble);

if (nodeViewModel.ErrorBubble != null)
Errors.Add(nodeViewModel.ErrorBubble);

PostNodeChangeActions();
}

Expand Down
Loading

0 comments on commit a127282

Please sign in to comment.