Skip to content
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

Auto-debug ExtCitizenInstanceManager.StartPathFind() #834

Merged
merged 7 commits into from
Apr 14, 2020
Merged

Conversation

originalfoo
Copy link
Member

@originalfoo originalfoo commented Apr 12, 2020

Fixes #840

If an exception occurs in StartPathFind() we don't get much information in the logs to help us determine what specifically caused it.

This commit tries to remedy that by intercepting the exception, then repeating the StartPathFind() only this time with full debug logging. The original exception is then rethrown.

The only performance overheads during normal operation should be:

  • Adding a token to the stack for the try .. catch
  • An additional method call, that will likely be inlined by the jitter
  • Setting two bools true|false on each invocation (previously they were const and false in RELEASE builds.)
  • A bunch of conditional checks (eg. if (logParkingAi) { ... }), one for each log call
    • Due to branching in InternalStartPathFind() only a few will be encountered.
    • I assume branch predication will quickly optimise things for nromal operation

Hopefully the performance impacts will be negligible, but that remains to be tested.

This PR is result of by Nijamods (ninjanoobslayer) issue report in #825 (comment) and subsequent log files in #825 (comment) . I've sent a build of TMPE with this modification to Ninja to test so we should know if it works with followup in #825.

If an exception occurs in `StartPathFind()` we don't get much information in the logs to help us determine what caused it.

This commit tries to remedy that by intercepting the exception then checking a `TernaryBool` (TB):

* `Undefined` = Set the TB to `True`
* `True` = Set the TB to `False`
* `False` = Do nothing

The original exception is then rethrown.

When the TB is `True`, the internal debug logging (all of it) is enabled for the next invocation of `StartPathFind()` which will dump all sorts of useful info to the `TMPE.log` file.

When an exception occurs, it's usually recurrent on subsequent calls to `StartPathFind()` so hopefully the debug logging will give us insight in to what specifically caused the problem.
@originalfoo originalfoo added technical Tasks that need to be performed in order to improve quality and maintainability PATHFINDER Pathfinding tweaks or issues labels Apr 12, 2020
@originalfoo originalfoo self-assigned this Apr 12, 2020
@originalfoo
Copy link
Member Author

Actually, I can just repeat the call to the internal method to debug the specific params that caused the error... update incoming...

Rather than debugging the subsequent invocation, just repeat the current one (the one that failed) but with debugging enabled.
Most of the logging was previously filtered in non-`DEBUG` builds. This commit changes that to ensure the logging is always present, even in `RELEASE` builds, but only occurs if the relevant logging toggles are `true`. Downside is that there are now lots of checks for those toggles.
Make sure only one set of trace goes in to log, and reduce amount of stack tracing. Log should be a bit easier to digest now.
Copy link
Collaborator

@kvakvs kvakvs left a comment

Choose a reason for hiding this comment

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

nice

User will see error dialog per error anyway, so might as well do the full debug log per error to get more info.
@originalfoo
Copy link
Member Author

I've updated this so now it does the logging on each occurrence of the error, simplifying state management in the process. User has to click on-screen error box anyway so they won't be caring about split second it takes to do the full debug log.

Copy link
Member

@krzychu124 krzychu124 left a comment

Choose a reason for hiding this comment

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

Looks good, added info how to fix null ref

Unity has weird `==` operator, that returns fake null - see: https://blogs.unity3d.com/2014/05/16/custom-operator-should-we-keep-it/

More details in #834 (review)
@originalfoo
Copy link
Member Author

@krzychu124 is this ok for merge?

@originalfoo originalfoo merged commit ee617c3 into master Apr 14, 2020
@originalfoo originalfoo deleted the auto-debug branch April 14, 2020 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PATHFINDER Pathfinding tweaks or issues technical Tasks that need to be performed in order to improve quality and maintainability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug in StartPathFind() when building not present
3 participants