fix: coalesce pinch updates and stop live zoom write-back
All checks were successful
CI / Windows build (push) Successful in 9m55s
All checks were successful
CI / Windows build (push) Successful in 9m55s
Surface Aug6 diag showed sDrop=0 but ~220 same-ms dual ZOOM frames and √2 cur ping-pong from reading currentZoom back into pinch state. Flush once per microtask and embed gitSha in diagnostic meta. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -16,7 +16,8 @@ class InputDiagnostics extends ChangeNotifier {
|
||||
static final InputDiagnostics instance = InputDiagnostics._();
|
||||
|
||||
int frames = 0;
|
||||
int scaleDropped = 0; // frames rejected as a scale glitch
|
||||
int scaleDropped = 0; // frames HARD-rejected (legacy; prefer soft-clamp)
|
||||
int softClamped = 0; // frames whose step was soft-clamped (still applied)
|
||||
int focalDropped = 0; // frames rejected as a focal/position glitch
|
||||
int rebaselines = 0; // pointer-count re-baselines
|
||||
int pointerCountMax = 0;
|
||||
@@ -42,13 +43,16 @@ class InputDiagnostics extends ChangeNotifier {
|
||||
required double focalJumpPx,
|
||||
required bool scaleDrop,
|
||||
required bool focalDrop,
|
||||
bool softClamped = false,
|
||||
double? liveScale,
|
||||
}) {
|
||||
frames++;
|
||||
if (scaleDrop) scaleDropped++;
|
||||
if (softClamped) this.softClamped++;
|
||||
if (focalDrop) focalDropped++;
|
||||
if (rawScale < rawScaleMin) rawScaleMin = rawScale;
|
||||
if (rawScale > rawScaleMax) rawScaleMax = rawScale;
|
||||
final double resulting = currentScale * appliedChange;
|
||||
final double resulting = currentScale;
|
||||
if (resulting < scaleMin) scaleMin = resulting;
|
||||
if (resulting > scaleMax) scaleMax = resulting;
|
||||
if (pointerCount > pointerCountMax) pointerCountMax = pointerCount;
|
||||
@@ -56,16 +60,21 @@ class InputDiagnostics extends ChangeNotifier {
|
||||
final double jump = appliedChange >= 1 ? appliedChange : 1 / appliedChange;
|
||||
if (jump > maxAppliedScaleJump) maxAppliedScaleJump = jump;
|
||||
|
||||
final liveBit = liveScale == null
|
||||
? ''
|
||||
: ' live=${liveScale.toStringAsFixed(3)}';
|
||||
final String line = 'p$pointerCount raw=${rawScale.toStringAsFixed(3)} '
|
||||
'ch=${appliedChange.toStringAsFixed(3)} '
|
||||
'cur=${currentScale.toStringAsFixed(3)} '
|
||||
'cur=${currentScale.toStringAsFixed(3)}$liveBit '
|
||||
'fj=${focalJumpPx.toStringAsFixed(0)}'
|
||||
'${scaleDrop ? " SDROP" : ""}${focalDrop ? " FDROP" : ""}';
|
||||
'${softClamped ? " SCLAMP" : ""}'
|
||||
'${scaleDrop ? " SDROP" : ""}'
|
||||
'${focalDrop ? " FDROP" : ""}';
|
||||
_trace.add(line);
|
||||
if (_trace.length > 24) _trace.removeAt(0);
|
||||
FrameSampler.instance.recordZoom(
|
||||
rawScale: rawScale,
|
||||
scaleDrop: scaleDrop,
|
||||
scaleDrop: scaleDrop || softClamped,
|
||||
focalDrop: focalDrop,
|
||||
focalJumpPx: focalJumpPx,
|
||||
);
|
||||
@@ -74,7 +83,8 @@ class InputDiagnostics extends ChangeNotifier {
|
||||
}
|
||||
|
||||
void reset() {
|
||||
frames = scaleDropped = focalDropped = rebaselines = pointerCountMax = 0;
|
||||
frames = scaleDropped = softClamped = focalDropped = rebaselines =
|
||||
pointerCountMax = 0;
|
||||
rawScaleMin = scaleMin = double.infinity;
|
||||
rawScaleMax = scaleMax = 0;
|
||||
maxFocalJumpPx = 0;
|
||||
@@ -83,15 +93,15 @@ class InputDiagnostics extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
String _f(double v) => v.isFinite ? v.toStringAsFixed(2) : '-';
|
||||
|
||||
String summary() {
|
||||
if (frames == 0) return 'zoom: (pinch to record)';
|
||||
return 'zoom f=$frames sDrop=$scaleDropped fDrop=$focalDropped '
|
||||
'rebase=$rebaselines pMax=$pointerCountMax\n'
|
||||
' raw=${_f(rawScaleMin)}..${_f(rawScaleMax)} '
|
||||
'scale=${_f(scaleMin)}..${_f(scaleMax)}\n'
|
||||
final rawLo = rawScaleMin.isFinite ? rawScaleMin.toStringAsFixed(2) : '-';
|
||||
final rawHi = rawScaleMax > 0 ? rawScaleMax.toStringAsFixed(2) : '-';
|
||||
final scLo = scaleMin.isFinite ? scaleMin.toStringAsFixed(2) : '-';
|
||||
final scHi = scaleMax > 0 ? scaleMax.toStringAsFixed(2) : '-';
|
||||
return 'zoom f=$frames sDrop=$scaleDropped sClamp=$softClamped '
|
||||
'fDrop=$focalDropped rebase=$rebaselines pMax=$pointerCountMax\n'
|
||||
' raw=$rawLo..$rawHi scale=$scLo..$scHi\n'
|
||||
' maxFocalJump=${maxFocalJumpPx.toStringAsFixed(0)}px '
|
||||
'maxScaleJump=${_f(maxAppliedScaleJump)}';
|
||||
'maxScaleJump=${maxAppliedScaleJump.toStringAsFixed(2)}';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user