DYN-10601: Dynamo's Export as 3D Background Preview crashes#17194
Conversation
There was a problem hiding this comment.
See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-10601
There was a problem hiding this comment.
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 distinguishEmptyDrawingvs.NotValidAsImagevs.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
left a comment
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
No longer rethrows the exception ... not a problem, but for reference for note below.
There was a problem hiding this comment.
Thanks @jasonstratton - you're right. I've updated the PR now.
| RenderTargetBitmap workSpaceRender; | ||
| try | ||
| { | ||
| workSpaceRender = GetRender(bounds, minX, minY); |
There was a problem hiding this comment.
GetRender() will catch all exceptions and no longer rethrows. ... Not a problem to keep the try/catch here, but it's unnecessary now.
|



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 aRenderTargetBitmapsized 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 calledGetRender()outside any try/catch, so it propagated toOnRequestExportWorkSpaceAsImage(...)unhandled and crashed Dynamo.Solution:
GetRender()is split intoTryGetRenderBounds(...)that computes bounds, returns false when empty,IsRenderBoundsValidForExport(...)that rejects bounds beyond MaxExportDimension = 16384, andGetRender(bounds, minX, minY)that renders only, logs and returns null on failure, and always restores the RenderTransform in a finally.IsWorkSpaceRenderValidAsImage(...)now maps results toExportImageResult - EmptyDrawing, NotValidAsImage(too large / render or encode fails), orIsValidAsImageso the export shows the "not valid as image" toast instead of crashing. It also fixes a latent bug where a successful export returnedEmptyDrawing.Adds a regression test,
WhenWorkspaceExceedsMaxExportDimensionThenSaveImageIsBlocked, verifying the workspace is flaggedNotValidAsImage, 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