-
Notifications
You must be signed in to change notification settings - Fork 202
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
MAYA-104552 improve diagnostics #2799
Conversation
Improve the message batching to be usable for errors too. Also, remove hard-coded crash when we can. We should never explicitly choose crash Maya under the user's feet just because of some-sub-system is unhappy. Errors are fine for those cases. Use the diagnostic batch context in places that caused problems due to the flood of error messages when loading large scene with missing textures or layers. Unfortunately, there are some messages that comes from OGS and which require a Maya fix to avoid flooding the script editor, those cannot be fixed in the plugin. (Well, it would need investigation why the VP2 delegate does what it does and causs those OGS errors.)
- Always accumulate and coalesce messages. - Use a thread to peridodically write messages. - Only write messages if there are some pending and at least a second has passed. - For low-volume messages, this will print all messages. - For high-violumes messages, this avoids a flood of messages. The design goes like this: - All messages are accumulated by the above delegates. - A thread, periodicFlusher, wakes up every second to conditionally flush pending messages. - The condition for flushing are that a forced flush is requested or some messages have been received and one second has elapsed. - Requesting a flushing of accumulated messages is done by queuing a task to be run on idle in the main thread. If a task is already queued, nothing is done. - The main-thread task takes (extract and removes) all accumulted messages and prints them in the script console via MGlobal. - This can only be done in the main thread because that is what MGlobal supports. - Only start to batch message if more than a threshold are received within one second. - Flush directly if flushing is triggered in the main thread. Use the batching context to force a flush of diagnostic messages in unit tests that assert about messages.
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.
Looks good
Hey folks, we've stopped receiving TF warnings and errors in our unit test log files if we don't perform a diagnostic flush on teardown. I tried setting the |
Hi,
We've changed the code so that when too many warnings or errors and issued all at once, they get batched. You can change the maximum number of messages before batching in multiple ways:
* In Python, call mayaUsd.lib.SetMaximumUnbatchedDiagnostics(1000 * 1000)
* In C++ use the UsdMayaDiagnosticBatchContext(1000 * 1000)
* Set the environment variable MAYAUSD_MAXIMUM_UNBATCHED_DIAGNOSTICS to some similar high value.
It was changed in this pull request: #2799
|
Oh, wait, you are right, due to the way the message are buffered now, you might indeed need a flush. We probably should register an exit callback in the diagnostic delegate do it automatically or support not batching any messages, you are right. |
Ah ok - it would be great to ensure messages are flushed on exit so we wouldn't have to introduce any new env vars or function calls to our unit tests, but being able to explicitly disable batching also seems like a good idea... Thanks! |
I've looked at the code. I could try to fix it, but given that I don't have repro step to make sure I've fixed the issue in your particular case, I'll describe what could be modified. You could tried it on your side and submit a PR.
I think #2 would be enough to ensure flushing in your case, but #1 could be a nice extra. |
I went ahead I wrote what I described in the PR: #2830 |
Improve the message batching to be usable for errors too. Also, remove
hard-coded crash when we can. We should never explicitly choose crash Maya
under the user's feet just because of some-sub-system is unhappy. Errors are
fine for those cases.
Unfortunately, there are some messages that comes from OGS and which require a
Maya fix to avoid flooding the script editor, those cannot be fixed in the
plugin. (Well, it would need investigation why the VP2 delegate does what it
does and causes those OGS errors.)
The design goes like this:
any message arrives.
further messages from being written out when a burst is detected,
outside of burst of messages.
to avoid writing too many messages in the log.
or indirectly.
main thread.
main thread. If a task is already queued, nothing is done, to avoid
queuing multiple redundant tasks to do the same thing.
and prints them in the script console via MGlobal.
only print a sample of the message followed by "and X similar".