Skip to content

Conversation

@mjkkirschner
Copy link
Member

@mjkkirschner mjkkirschner commented Sep 27, 2019

Purpose

Dynamo Sandbox should not crash silently.

  • To avoid this snippet of stack trace and exception are shown in a message box from system.windows (not forms) to avoid adding any other dependencies that might fail to load.
  • ASM load is now wrapped in a try catch
  • okay button in message box navigates to dynamo builds wiki page with info on using sandbox.
  • filter out ASM locations that don't include tsplinesA - as these installs of ASM will not work with Dynamo. Discovered this as a cause of a silent crash with help from users on the forum and internal users.

UPDATE:

  • changed filemask to ASMH*A.dll to better match what dependencies we actually have, and also filter results that don't include tbb and tbbmalloc.dll
  • raise an event when preload fails and trigger a messagebox to note the location we tried to load from - will be useful if we encounter other odd geometry library configurations in the future.
  • Dynamo will now start, even if the preload fails. Geometry nodes will of course not work though.

Screen Shot 2019-09-27 at 6 08 54 PM
Screen Shot 2019-09-27 at 6 09 52 PM

TODO:

  • use resx files

Screen Shot 2019-09-27 at 1 34 11 AM

Declarations

Check these if you believe they are true

  • The code base is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning, and are documented in the API Changes document.

Reviewers

@aparajit-pratap
@ColinDayOrg

FYIs

@TheBIMsider

filter out ASM locations which dont include tsplines A
}
catch
{
Console.WriteLine("Failed to load ASM binaries");
Copy link
Contributor

@aparajit-pratap aparajit-pratap Sep 27, 2019

Choose a reason for hiding this comment

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

Won't the exception be silently swallowed out here? I don't see a throw?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, okay, after discussing a bit I see what you're saying - I think instead of Dynamo starting with no geometry - it is likely more useful to throw and message to the user where the geometry library failed to load from - this will also help us later get to the bottom of crash reports without needing to recreate the users local adsk install setup.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess I'm okay with launching Dynamo without the geometry library but in addition to doing that I think it would be useful to display a message to users saying that the geometry library failed to load due to these reasons but if they wish they can still continue to use Dynamo.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think at this point doing either or is the least risky thing, we don't have access to the dynamo logger here - and if we have to choose right now then I think showing the offending path to the user is actually more useful.

Copy link
Contributor

@aparajit-pratap aparajit-pratap Sep 27, 2019

Choose a reason for hiding this comment

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

I guess I meant to ask if it's possible to show the message box, the user clicks "ok", and is able to continue to use Dynamo?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so - not without a larger refactoring - but I can look at that if you think it's worth it.

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm - for some context, we should not introduce a dependency on system.windows into the preloader - which needs to be cross platform - but the other message box raised in dynamoSandbox only is shown when it is too late to recover.

Copy link
Member Author

Choose a reason for hiding this comment

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

@aparajit-pratap PTAL - figured out a way to do this while avoiding big set of changes or new public apis. We may want to do that as part of the followup we discussed.

@mjkkirschner mjkkirschner changed the title [WIP] sandbox should not crash silently sandbox should not crash silently Sep 27, 2019
@mjkkirschner mjkkirschner added the PTAL Please Take A Look 👀 label Sep 27, 2019
throw exception with more info when asm fails to load
fix bug in message from old method
add new line to message dialog
{
//show a message dialog box with the exception so the user
//can effectively report the issue.
var shortStackTrace = String.Join(Environment.NewLine,e.StackTrace.Split(Environment.NewLine.ToCharArray()).Take(10));
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is pointing to the wiki, we will need to update there how to file issue related to start up failure.

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, I will do that there.

}
catch
{
throw new FileNotFoundException($"Could not load geometry library binaries from : {asmLocation}");
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the only kind of cause exception? @mjkkirschner @aparajit-pratap

Copy link
Member Author

Choose a reason for hiding this comment

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

this should just be Exception - I will change it.

@aparajit-pratap
Copy link
Contributor

aparajit-pratap commented Sep 27, 2019

@mjkkirschner I'm a little confused. With your first commit (without rethrowing from the try-catch around ASM preloading), how were you able to display the message box with the stacktrace around ASM preload? Wouldn't it have simply swallowed that exception and launched Dynamo?


//filter install locations missing tsplinesA
installations = installations.Cast<KeyValuePair<string, Tuple<int,int,int,int>>>().
Where(x => Directory.EnumerateFiles(x.Key, "tsplines*A.dll").Any());
Copy link
Contributor

@aparajit-pratap aparajit-pratap Sep 27, 2019

Choose a reason for hiding this comment

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

Does it make sense to fold this check into getASMInstallsFunc? Also my previous question was why don't we do this check for "ASM*A.dll" as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. I can try to fold it in there -
  2. we're already checking for that in the findProductInstallations function when we pass "ASMAHL*.dll" isn't this - essentially doing the same check twice?

Copy link
Contributor

@aparajit-pratap aparajit-pratap Sep 27, 2019

Choose a reason for hiding this comment

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

There could be an ASMAHL*A.dll and an ASMAHL*I.dll?

Copy link
Member Author

Choose a reason for hiding this comment

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

kind of, the offending folder has the ASMA.dlls and tsplinesI.dll

@mjkkirschner
Copy link
Member Author

@mjkkirschner I'm a little confused. With your first commit (without rethrowing from the try-catch around ASM preloading), how were you able to display the message box with the stacktrace around ASM preload? Wouldn't it have simply swallowed that exception and launched Dynamo?

  • the first commit would have swallowed the exception and started dynamo - the message box I showed in the image was for any other unhandled exception - for example - if all the dlls are blocked.

@aparajit-pratap
Copy link
Contributor

the first commit would have swallowed the exception and started dynamo - the message box I showed in the image was for any other unhandled exception - for example - if all the dlls are blocked.

So the message box showing ASM related exception was just a contrived example?

@mjkkirschner
Copy link
Member Author

the first commit would have swallowed the exception and started dynamo - the message box I showed in the image was for any other unhandled exception - for example - if all the dlls are blocked.

So the message box showing ASM related exception was just a contrived example?

yes - I threw away all the libG folders 😉

use $string interpolation for some old messages
log  to console for CLI clients

//filter install locations missing tbb and tbbmalloc.dll
return installs.Cast<KeyValuePair<string, Tuple<int, int, int, int>>>().
Where(x => Directory.EnumerateFiles(x.Key, "tbb*.dll").Count() >1);
Copy link
Contributor

@aparajit-pratap aparajit-pratap Sep 30, 2019

Choose a reason for hiding this comment

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

I think we can make this check more strict by specifically checking for both tbb.dll and tbbmalloc.dll just so we don't have any other surprises like tbbX.dll being present but not being the same as one or the other above.

Copy link
Member Author

Choose a reason for hiding this comment

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

okay, will do.

@aparajit-pratap
Copy link
Contributor

Thanks, LGTM!

@aparajit-pratap aparajit-pratap added LGTM Looks good to me and removed PTAL Please Take A Look 👀 labels Sep 30, 2019
@mjkkirschner
Copy link
Member Author

@smangarole brining this in, will cherry pick next.

@mjkkirschner mjkkirschner merged commit 2c4e82b into DynamoDS:master Sep 30, 2019
@horatiubota horatiubota added the error/warning/crash Issues mentioning a Dynamo error, warning or crash message label Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

error/warning/crash Issues mentioning a Dynamo error, warning or crash message LGTM Looks good to me

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants