feat(testing): pointer-trace recorder + capture format (#20)#67
Merged
Conversation
Debug capture mode: when DebugSettings.PREF_RECORD_INPUT_TRACES is on, each completed gesture session is dumped to filesDir/input_traces/trace-<ms>.json (InputPointers x/y/t/id + committed word + keyboard geometry/locale), for the JUnit replay harness (#21). - Hooked in onUpdateTailBatchInputCompleted (where committed word + InputPointers + keyboard are all synchronously available on the UI thread), not onEndBatchInput. - TraceRecorder copies the pointer arrays synchronously (InputPointers isn't thread-safe) then writes off a single-threaded executor; app context, no IME leak. - Default off -> a single boolean check in normal use. Format documented in KDoc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements #20 (A3a) — a debug capture mode that dumps real gesture sessions to replayable trace files, building toward the JUnit replay harness (#21) and, through it, the ability to verify the gated spacing/recognition epics.
What
When the new debug pref
PREF_RECORD_INPUT_TRACES(Settings → Debug, default off) is on, each completed gesture/batch session is written tofilesDir/input_traces/trace-<epochMillis>.json.Format (v1, documented in TraceRecorder KDoc)
{ "version":1, "createdAt":<ms>, "keyboard": {"width":<px>,"height":<px>,"mainLayout":"qwerty","locale":"<bcp47>"}, "committedWord":"<word>", "pointers":[{"id":<int>,"x":<int>,"y":<int>,"t":<ms>}, ...] }pointersis theInputPointersflattened in index order — the exact trace fed to the recognizer (a merged trail for multi-part gestures), which is the most faithful replay input.Implementation notes
InputLogic.onUpdateTailBatchInputCompleted— chosen overonEndBatchInputbecause that's where the committed word (composedText),mWordComposer.getInputPointers(), and the keyboard are all synchronously available on the UI thread (the word is computed async by InputLogicHandler).TraceRecordercopies the pointer arrays synchronously on the caller thread (InputPointers is mutable/reused), then writes off a single-threaded executor. Uses the application context (no IME-service leak).Verification
:app:testOfflineRunTestsUnitTest= 4 failed, all the Windows-only ParserTest set — zero new failures.input_traces/*.json— not yet exercised end-to-end by me; worth a quick check when convenient.Next: #21 (JUnit replay harness + golden corpus) consumes this format. Built by a subagent; coordinator reviewed (thread-safety, hook correctness), compiled, ran the suite. Base
dev.