Forward HIDInputReportEvent.timeStamp to button listeners - #59
Open
mouadennasri wants to merge 1 commit into
Open
Forward HIDInputReportEvent.timeStamp to button listeners#59mouadennasri wants to merge 1 commit into
mouadennasri wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
Problem
Consumers of this library running real-time audio routing on top of HID button input need to know when the user actually pressed the button, not when the JS handler eventually ran.
Under main-thread starvation (long React renders, focus handlers, etc.) the
inputreportevent sits in the browser event queue for hundreds of ms before dispatch. Today the event'stimeStampis read offevent.dataand discarded insideonInputReport/handleButtonPress, so theButtonEventListenercallback has no way to recover the press time.Symptom: under load, every nav appears to happen "now" (handler-fire time), so any logic that correlates HID input with audio frames (speech onset, transcription windows, etc.) misroutes when the queue delay exceeds the audio window. DOM events (
keydown,pointerdown, etc.) all exposeevent.timeStampnatively, so HID is the only input modality where queue-aware back-dating isn't possible today.Change
Forward
event.timeStampfrom the underlyingHIDInputReportEventthroughhandleButtonPressto eachButtonEventListener, as a third positional argument:Touched:
dictation_device_base.ts,speechmike_hid_device.ts(override + proxy-device propagation path).Compatibility
The added parameter is positional and additive. Existing
ButtonEventListenerimplementations that take(device, bitMask)are still assignable to the new type — TypeScript permits assigning a fewer-arg function where more-arg is expected, and JavaScript ignores extra arguments at runtime. No call site update is required for consumers that don't need the timestamp.Tests
Updated
check_button_mappingto assert the new arg viajasmine.any(Number). Added an expliciteventTimeStampvalue to the SpeechMike proxy-device propagation test so the forwarded value is verified end-to-end. Webpack build compiles cleanly.