Skip to content

DYN-10601: Dynamo's Export as 3D Background Preview crashes#17194

Merged
jasonstratton merged 4 commits into
DynamoDS:masterfrom
ivaylo-matov:DYN-10601-Dynamo's-Export-as-3D-Background-Preview-crashes
Jun 30, 2026
Merged

DYN-10601: Dynamo's Export as 3D Background Preview crashes#17194
jasonstratton merged 4 commits into
DynamoDS:masterfrom
ivaylo-matov:DYN-10601-Dynamo's-Export-as-3D-Background-Preview-crashes

Conversation

@ivaylo-matov

Copy link
Copy Markdown
Contributor

Purpose

Purpose
This PR fixes a crash in DYN-10601 that occurs when exporting a very large workspace as an image. Instead of crashing, the export now fails gracefully and informs the user that the workspace cannot be exported as an image.

Problem:
When exporting the workspace as an image, WorkspaceView.GetRender() builds a RenderTargetBitmap sized to the bounding box of all nodes, notes, and annotations. For very large graphs this exceeds the maximum bitmap dimension, so the render throws. The original code rethrew the exception and called GetRender() outside any try/catch, so it propagated to OnRequestExportWorkSpaceAsImage(...) unhandled and crashed Dynamo.

Solution:
GetRender() is split into TryGetRenderBounds(...) that computes bounds, returns false when empty, IsRenderBoundsValidForExport(...) that rejects bounds beyond MaxExportDimension = 16384, and GetRender(bounds, minX, minY) that renders only, logs and returns null on failure, and always restores the RenderTransform in a finally.

IsWorkSpaceRenderValidAsImage(...) now maps results to ExportImageResult - EmptyDrawing, NotValidAsImage (too large / render or encode fails), or IsValidAsImage so the export shows the "not valid as image" toast instead of crashing. It also fixes a latent bug where a successful export returned EmptyDrawing.

Adds a regression test, WhenWorkspaceExceedsMaxExportDimensionThenSaveImageIsBlocked, verifying the workspace is flagged NotValidAsImage, no file is written, and a toast is shown.

Declarations

Check these if you believe they are true

Release Notes

This PR fixes a crash in that occurs when exporting a very large workspace as an image. Instead of crashing, the export now fails gracefully and informs the user that the workspace cannot be exported as an image.

Reviewers

@DynamoDS/eidos
@jasonstratton
@johnpierson

FYIs

@dnenov

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

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-10601

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 addresses a crash in Dynamo’s “Export Workspace as Image” flow for very large graphs by validating the render bounds up-front and ensuring rendering failures return a non-crashing “not valid” result that the UI can surface to the user.

Changes:

  • Refactors workspace image export rendering into (1) bounds calculation, (2) bounds validation against a maximum export dimension, and (3) render-only logic that logs failures, returns null, and always restores transforms.
  • Updates IsWorkSpaceRenderValidAsImage(...) to correctly distinguish EmptyDrawing vs. NotValidAsImage vs. IsValidAsImage, preventing unhandled exceptions from propagating.
  • Adds a UI regression test that constructs an oversized workspace and verifies export is blocked, no file is written, and a toast is shown.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
test/DynamoCoreWpfTests/CoreUITests.cs Adds a regression test ensuring oversized workspaces are blocked from image export and surface a toast.
src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs Splits image export into bounds computation + validation + safe render, and updates export validation result mapping to avoid crashes.

@jasonstratton jasonstratton left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just one bit of feedback about an unnecessary try/catch, but it's mostly noise.

Approving, but will wait to hear back before merging.

}
finally
{
throw;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No longer rethrows the exception ... not a problem, but for reference for note below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @jasonstratton - you're right. I've updated the PR now.

RenderTargetBitmap workSpaceRender;
try
{
workSpaceRender = GetRender(bounds, minX, minY);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

GetRender() will catch all exceptions and no longer rethrows. ... Not a problem to keep the try/catch here, but it's unnecessary now.

@sonarqubecloud

Copy link
Copy Markdown

@jasonstratton jasonstratton merged commit 5436532 into DynamoDS:master Jun 30, 2026
28 of 30 checks passed
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