|
|
|
|
|
|
using Unity.UIWidgets.async2; |
|
|
|
using Unity.UIWidgets.foundation; |
|
|
|
using Unity.UIWidgets.ui; |
|
|
|
using UnityEditor.PackageManager; |
|
|
|
using UnityEngine; |
|
|
|
using FrameTiming = Unity.UIWidgets.ui.FrameTiming; |
|
|
|
using Timer = Unity.UIWidgets.async2.Timer; |
|
|
|
|
|
|
D.assert(() => { |
|
|
|
if (debugCurrentCallbackStack == null) { |
|
|
|
throw new UIWidgetsError( |
|
|
|
"scheduleFrameCallback called with rescheduling true, but no callback is in scope.\n" + |
|
|
|
"The \"rescheduling\" argument should only be set to true if the " + |
|
|
|
"callback is being reregistered from within the callback itself, " + |
|
|
|
"and only then if the callback itself is entirely synchronous. \n" + |
|
|
|
"If this is the initial registration of the callback, or if the " + |
|
|
|
"callback is asynchronous, then do not use the \"rescheduling\" " + |
|
|
|
"argument."); |
|
|
|
new List<DiagnosticsNode>() { |
|
|
|
new ErrorSummary( |
|
|
|
"scheduleFrameCallback called with rescheduling true, but no callback is in scope."), |
|
|
|
new ErrorDescription( |
|
|
|
"The \"rescheduling\" argument should only be set to true if the " + |
|
|
|
"callback is being reregistered from within the callback itself, " + |
|
|
|
"and only then if the callback itself is entirely synchronous."), |
|
|
|
new ErrorHint("If this is the initial registration of the callback, or if the " + |
|
|
|
"callback is asynchronous, then do not use the \"rescheduling\" " + |
|
|
|
"argument.") |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
catch (Exception ex) { |
|
|
|
InformationCollector collector = null; |
|
|
|
D.assert(() => { |
|
|
|
collector = (StringBuilder sb) => { |
|
|
|
sb.AppendLine("The TimingsCallback that gets executed was " + callback); |
|
|
|
}; |
|
|
|
IEnumerable<DiagnosticsNode> infoCollect() { |
|
|
|
yield return new DiagnosticsProperty<TimingsCallback>( |
|
|
|
"The TimingsCallback that gets executed was", |
|
|
|
callback, |
|
|
|
style: DiagnosticsTreeStyle.errorProperty); |
|
|
|
} |
|
|
|
collector = infoCollect; |
|
|
|
context: "while executing callbacks for FrameTiming", |
|
|
|
context: new ErrorDescription("while executing callbacks for FrameTiming"), |
|
|
|
informationCollector: collector |
|
|
|
)); |
|
|
|
} |
|
|
|
|
|
|
callbackStack = entry.debugStack; |
|
|
|
return true; |
|
|
|
}); |
|
|
|
|
|
|
|
IEnumerable<DiagnosticsNode> infoCollector() { |
|
|
|
yield return DiagnosticsNode.message("\nThis exception was thrown in the context of a scheduler callback. " + |
|
|
|
"When the scheduler callback was _registered_ (as opposed to when the " + |
|
|
|
"exception was thrown), this was the stack: " + callbackStack); |
|
|
|
} |
|
|
|
|
|
|
|
context: "during a task callback", |
|
|
|
context: new ErrorDescription("during a task callback"), |
|
|
|
: sb => { |
|
|
|
sb.AppendLine("\nThis exception was thrown in the context of a scheduler callback. " + |
|
|
|
"When the scheduler callback was _registered_ (as opposed to when the " + |
|
|
|
"exception was thrown), this was the stack: " + callbackStack); |
|
|
|
} |
|
|
|
: infoCollector |
|
|
|
)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void scheduleFrame() { |
|
|
|
if (_hasScheduledFrame || !_framesEnabled) |
|
|
|
if (_hasScheduledFrame || !framesEnabled) |
|
|
|
return; |
|
|
|
|
|
|
|
D.assert(() => { |
|
|
|
|
|
|
callback(timeStamp); |
|
|
|
} |
|
|
|
catch (Exception ex) { |
|
|
|
IEnumerable<DiagnosticsNode> infoCollector() { |
|
|
|
yield return DiagnosticsNode.message("\nThis exception was thrown in the context of a scheduler callback. " + |
|
|
|
"When the scheduler callback was _registered_ (as opposed to when the " + |
|
|
|
"exception was thrown), this was the stack:"); |
|
|
|
StringBuilder builder = new StringBuilder(); |
|
|
|
foreach (var line in UIWidgetsError.defaultStackFilter( |
|
|
|
callbackStack.TrimEnd().Split('\n'))) { |
|
|
|
builder.AppendLine(line); |
|
|
|
} |
|
|
|
|
|
|
|
yield return DiagnosticsNode.message(builder.ToString()); |
|
|
|
} |
|
|
|
|
|
|
|
context: "during a scheduler callback", |
|
|
|
context: new ErrorDescription("during a scheduler callback"), |
|
|
|
: information => { |
|
|
|
information.AppendLine( |
|
|
|
"\nThis exception was thrown in the context of a scheduler callback. " + |
|
|
|
"When the scheduler callback was _registered_ (as opposed to when the " + |
|
|
|
"exception was thrown), this was the stack:" |
|
|
|
); |
|
|
|
foreach (var line in UIWidgetsError.defaultStackFilter( |
|
|
|
callbackStack.TrimEnd().Split('\n'))) { |
|
|
|
information.AppendLine(line); |
|
|
|
} |
|
|
|
} |
|
|
|
: infoCollector |
|
|
|
)); |
|
|
|
} |
|
|
|
|
|
|
|