feat(diag): full input logging + read barrel from pointerFlags; focal-jump reject
All checks were successful
CI / Windows build (push) Successful in 12m44s
All checks were successful
CI / Windows build (push) Successful in 12m44s
Buttons (likely fix + ground truth): device diag showed ptr=12577 pen=10056 — WM_POINTER reaches the observer and GetPointerPenInfo succeeds, so the buttons were just read from the wrong field. Native now resolves the barrel from BOTH penFlags(PEN_FLAG_BARREL) AND pointerInfo.pointerFlags(POINTER_FLAG_SECONDBUTTON) — many pens use the latter. It also emits the full raw set (pointerFlags, penFlags, penMask, ButtonChangeType, tilt) plus OR-accumulated flags so a single session reveals exactly which field each button sets. Comprehensive logging (per user request "用好用的log库 / 我手动开启日志再记录"): new DiagnosticLogger emits through dart:developer log(name 'badnote.input') — capturable via `flutter run` / DevTools / `flutter logs` — AND mirrors to a file (path shown in the overlay) for the packaged GUI build that has no console. Manually enabled by the toolbar diagnostic toggle; off by default. PEN lines log on raw-field change; ZOOM lines log every scale frame + rebaselines. Zoom: scale-only glitch rejection didn't stop the jumping, so add focal/position glitch rejection — drop a 2-finger frame whose focal jumps >250px (a touch misread). The full per-frame trace (raw scale, pointerCount, applied change, focal jump, drops) is now logged so the residual cause is unambiguous. InputDiagnostics singleton accumulates the stats; the overlay shows summary + last trace lines + log path + reset. Removed the ad-hoc inline zoom min/max. Dart: analyze clean, 66/66 tests, linux build green. Native compiles on CI. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
90
lib/editor/canvas/input_diagnostics.dart
Normal file
90
lib/editor/canvas/input_diagnostics.dart
Normal file
@@ -0,0 +1,90 @@
|
||||
// lib/editor/canvas/input_diagnostics.dart
|
||||
//
|
||||
// Live zoom/pan diagnostics for the pen canvas. PenInteractiveViewer records one
|
||||
// entry per scale-update frame; the editor's diagnostic overlay displays the
|
||||
// accumulated summary + a rolling trace so a SINGLE device session reveals the
|
||||
// nature of any "跳变" (is it a raw-scale spike, a focal/position jump, or a
|
||||
// pointer-count oscillation?). All numbers reset via [reset].
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../input/diagnostic_logger.dart';
|
||||
|
||||
class InputDiagnostics extends ChangeNotifier {
|
||||
InputDiagnostics._();
|
||||
static final InputDiagnostics instance = InputDiagnostics._();
|
||||
|
||||
int frames = 0;
|
||||
int scaleDropped = 0; // frames rejected as a scale glitch
|
||||
int focalDropped = 0; // frames rejected as a focal/position glitch
|
||||
int rebaselines = 0; // pointer-count re-baselines
|
||||
int pointerCountMax = 0;
|
||||
double rawScaleMin = double.infinity, rawScaleMax = 0;
|
||||
double scaleMin = double.infinity, scaleMax = 0;
|
||||
double maxFocalJumpPx = 0; // largest single-frame local focal delta
|
||||
double maxAppliedScaleJump = 1; // largest single-frame applied scale ratio
|
||||
|
||||
final List<String> _trace = <String>[];
|
||||
List<String> get trace => List.unmodifiable(_trace);
|
||||
|
||||
void recordRebaseline() {
|
||||
rebaselines++;
|
||||
DiagnosticLogger.instance.log('ZOOM rebaseline');
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void recordScaleFrame({
|
||||
required double rawScale,
|
||||
required int pointerCount,
|
||||
required double currentScale,
|
||||
required double appliedChange, // 1.0 when the frame was dropped
|
||||
required double focalJumpPx,
|
||||
required bool scaleDrop,
|
||||
required bool focalDrop,
|
||||
}) {
|
||||
frames++;
|
||||
if (scaleDrop) scaleDropped++;
|
||||
if (focalDrop) focalDropped++;
|
||||
if (rawScale < rawScaleMin) rawScaleMin = rawScale;
|
||||
if (rawScale > rawScaleMax) rawScaleMax = rawScale;
|
||||
final double resulting = currentScale * appliedChange;
|
||||
if (resulting < scaleMin) scaleMin = resulting;
|
||||
if (resulting > scaleMax) scaleMax = resulting;
|
||||
if (pointerCount > pointerCountMax) pointerCountMax = pointerCount;
|
||||
if (focalJumpPx > maxFocalJumpPx) maxFocalJumpPx = focalJumpPx;
|
||||
final double jump = appliedChange >= 1 ? appliedChange : 1 / appliedChange;
|
||||
if (jump > maxAppliedScaleJump) maxAppliedScaleJump = jump;
|
||||
|
||||
final String line = 'p$pointerCount raw=${rawScale.toStringAsFixed(3)} '
|
||||
'ch=${appliedChange.toStringAsFixed(3)} '
|
||||
'cur=${currentScale.toStringAsFixed(3)} '
|
||||
'fj=${focalJumpPx.toStringAsFixed(0)}'
|
||||
'${scaleDrop ? " SDROP" : ""}${focalDrop ? " FDROP" : ""}';
|
||||
_trace.add(line);
|
||||
if (_trace.length > 24) _trace.removeAt(0);
|
||||
DiagnosticLogger.instance.log('ZOOM $line');
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
frames = scaleDropped = focalDropped = rebaselines = pointerCountMax = 0;
|
||||
rawScaleMin = scaleMin = double.infinity;
|
||||
rawScaleMax = scaleMax = 0;
|
||||
maxFocalJumpPx = 0;
|
||||
maxAppliedScaleJump = 1;
|
||||
_trace.clear();
|
||||
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'
|
||||
' maxFocalJump=${maxFocalJumpPx.toStringAsFixed(0)}px '
|
||||
'maxScaleJump=${_f(maxAppliedScaleJump)}';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user