浏览代码

update scheduler

/siyaoH-1.17-PlatformMessage
xingweizhu 4 年前
当前提交
1e839c89
共有 2 个文件被更改,包括 56 次插入33 次删除
  1. 75
      com.unity.uiwidgets/Runtime/scheduler2/binding.cs
  2. 14
      com.unity.uiwidgets/Runtime/scheduler2/ticker.cs

75
com.unity.uiwidgets/Runtime/scheduler2/binding.cs


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
));
}

14
com.unity.uiwidgets/Runtime/scheduler2/ticker.cs


using System;
using System.Collections.Generic;
using System.Text;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;

D.assert(() => {
if (isActive) {
throw new UIWidgetsError(
"A ticker was started twice.\nA ticker that is already active cannot be started again without first stopping it.\n" +
"The affected ticker was: " + toString(debugIncludeStack: true));
new List<DiagnosticsNode>() {
new ErrorSummary("A ticker was started twice."),
new ErrorDescription(
"A ticker that is already active cannot be started again without first stopping it."),
describeForError("The affected ticker was: ")
});
return true;
});

}
return _future;
}
DiagnosticsNode describeForError(string name) {
return new DiagnosticsProperty<Ticker>(name, this, description: toString(debugIncludeStack: true));
}
public void stop(bool canceled = false) {

正在加载...
取消
保存