-
Notifications
You must be signed in to change notification settings - Fork 636
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
Switch off 3D rendering on out of memory #10535
Changes from 3 commits
8708787
e6730b2
83bae96
64a87ef
8bc14a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,9 @@ | |
using Dynamo.Graph.Nodes.CustomNodes; | ||
using Dynamo.Graph.Workspaces; | ||
using Dynamo.Logging; | ||
using Dynamo.Models; | ||
using Dynamo.Selection; | ||
using Dynamo.UI.Prompts; | ||
using Dynamo.ViewModels; | ||
using Dynamo.Visualization; | ||
using Dynamo.Wpf.Properties; | ||
|
@@ -219,7 +221,7 @@ protected override void OnActiveStateChanged() | |
} | ||
|
||
public event Action<Model3D> RequestAttachToScene; | ||
protected void OnRequestAttachToScene(Model3D model3D) | ||
protected virtual void OnRequestAttachToScene(Model3D model3D) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unfortunately this method will likely be removed / unused in the helix-upgrade branch - it might be possible to retain it and redirect it to do something useful with the new helix api though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this affect us when we cherry pick this test into helix-upgrade now? To build this as a unit test I just needed an overridable method called from |
||
{ | ||
if (RequestAttachToScene != null) | ||
{ | ||
|
@@ -829,7 +831,17 @@ public override void GenerateViewGeometryFromRenderPackagesAndRequestUpdate(Rend | |
var meshPackages = packages.Cast<HelixRenderPackage>().Where(rp => rp.MeshVertexCount % 3 == 0); | ||
|
||
RemoveGeometryForUpdatedPackages(meshPackages); | ||
AggregateRenderPackages(meshPackages); | ||
try | ||
{ | ||
AggregateRenderPackages(meshPackages); | ||
} | ||
catch (OutOfMemoryException) | ||
{ | ||
// This can happen when the amount of packages to render is too large | ||
string summary = Resources.RenderingMemoryOutageSummary; | ||
var description = Resources.RenderingMemoryOutageDescription; | ||
(dynamoModel as DynamoModel).Report3DPreviewOutage(summary, description); | ||
} | ||
#if DEBUG | ||
renderTimer.Stop(); | ||
Debug.WriteLine(string.Format("RENDER: {0} ellapsed for compiling assets for rendering.", renderTimer.Elapsed)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using Dynamo.Models; | ||
using Dynamo.ViewModels; | ||
using Dynamo.Wpf.ViewModels.Watch3D; | ||
using DynamoCoreWpfTests.Utility; | ||
using HelixToolkit.Wpf.SharpDX; | ||
using Moq; | ||
using Moq.Protected; | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace WpfVisualizationTests | ||
{ | ||
[TestFixture] | ||
public class Preview3DMemoryOutageTest : VisualizationTest | ||
{ | ||
private Mock<DynamoModel> modelMock; | ||
|
||
/// <summary> | ||
/// Creates a mock DynamoModel that does not show a task dialog but instead sets its call | ||
/// as a verifiable call. | ||
/// </summary> | ||
/// <param name="configuration">Default DynamoModel configuration</param> | ||
/// <returns>Mock DynamoModel</returns> | ||
protected override DynamoModel CreateModel(DynamoModel.IStartConfiguration configuration) | ||
{ | ||
modelMock = new Mock<DynamoModel>(configuration) | ||
{ | ||
CallBase = true | ||
}; | ||
modelMock.Setup(m => m.OnRequestTaskDialog(It.IsAny<object>(), It.IsAny<TaskDialogEventArgs>())) | ||
.Callback(() => { }) // Prevent dialog from blocking the test | ||
.Verifiable(); | ||
|
||
return modelMock.Object; | ||
} | ||
|
||
/// <summary> | ||
/// Sets up a mock HelixWatch3DViewModel which will throw OutOfMemoryException when rendering. | ||
/// </summary> | ||
/// <returns>DynamoViewModel configuration referencing the mock 3D preview</returns> | ||
protected override DynamoViewModel.StartConfiguration CreateViewModelStartConfiguration() | ||
{ | ||
var watch3DMock = new Mock<HelixWatch3DViewModel>(null, new Watch3DViewModelStartupParams(Model)) | ||
{ | ||
CallBase = true | ||
}; | ||
watch3DMock.Protected().Setup("OnRequestAttachToScene", ItExpr.IsAny<Model3D>()).Throws<OutOfMemoryException>(); | ||
return new DynamoViewModel.StartConfiguration() | ||
{ | ||
Watch3DViewModel = watch3DMock.Object | ||
}; | ||
} | ||
|
||
/// <summary> | ||
/// Opens any file that produces geometry and checks that the 3D preview is disabled after the error | ||
/// and also that a dialog is shown. | ||
/// </summary> | ||
[Test] | ||
public void HandlesRenderMemoryOutageGracefully() | ||
{ | ||
Assert.Greater(ViewModel.Watch3DViewModels.Count(), 0); | ||
Assert.True(ViewModel.Watch3DViewModels.All(w => w.Active)); | ||
|
||
OpenVisualizationTest("ASM_cuboid.dyn"); | ||
|
||
Assert.True(ViewModel.Watch3DViewModels.All(w => !w.Active)); | ||
modelMock.Verify(); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about wording this as
The amount of generated geometry might be too large. If it is necessary to create them, it might be necessary to disable .... or consider generating fewer geometry objects.
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it kind of a contradiction to ask to
consider generating fewer geometry objects
after sayingIf it is necessary to create them
? Also this message does not really mention the hint of switching off preview for some nodes, which should be useful.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to leave the part about disabling preview from your original message, which is what the
...
(ellipses) indicates. I just thought that instead of geometry is not "correct" you should mention that the amount of geometry created is large.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. The message actually says
amount of generated geometry is correct
. I meant to say that the amount may be large by accident. For instance, the user could have inadvertently enabled therepeat
parameter ofList.Combinations
when it was not needed.