Closed Bug 2062329 Opened 3 months ago Closed 2 months ago

Add telemetry for on-device Web Speech

Categories

(Core :: Web Speech, defect)

defect

Tracking

()

RESOLVED FIXED
158 Branch
Tracking Status
firefox158 --- fixed

People

(Reporter: padenot, Assigned: padenot, NeedInfo)

References

Details

Attachments

(5 external files, 3 obsolete files)

No description provided.

session_ended is recorded from Reset(), the one path every teardown goes
through. No transcript text or audio is recorded.

Three timing distributions, all recorded content-side:

  • session_init_time, around the init IPC round trip, is the page-visible wait
    between start() and recognition actually listening.
  • time_to_first_result, from [[started]] to the first result event.
  • result_latency is true capture-to-JS latency, and comes for free from the
    capture timestamps AudioCaptureTiming.h already plumbs end to end.

Recorded in the utility process, where the inference happens:

  • model_fetch_time and model_load_time separate opening an already-installed
    model from reading the GGUF into memory.
  • chunk_inference_time is the per-call compute time.
  • inference_realtime_factor is the session's audio over the time it took, x100
    (400 means 4x faster than real time). Once per session: a per-call mean is
    dominated by short chunks and overstates throughput by an order of magnitude.
    Scaled because custom_distribution samples are integers, and a bare factor
    would quantize away the 1-2x range that decides usability.
  • audio_processed_duration is its denominator, useful on its own.
  • init_failure records why a session failed to start. All these causes reach
    content as the single "network" error code, so this is the only way to tell a
    missing model from a real failure.

The new test does a real recognition against the parakeet model served by
serve_model.py, so it runs in the speech-recognition subsuite. It asserts the
metrics have samples and logs the numbers rather than asserting on them, since
they depend on the machine.

Counts impressions of the notification bar offering to turn speech recognition
back on, and what the user does with it.

  • The observer notification carries which call was blocked, attributing an
    impression to start() or install().
  • An eventCallback counts dismissal, and navigating away for a bar the user
    never acted on. Every removal path reports "disconnected", so this needs the
    interactions to be tracked to tell the two apart.
  • A click listener on the <a is="moz-support-link"> counts "Learn more";
    notificationbox only dispatches button callbacks for <label> elements.

dual_labeled_counter rather than events with string extras, so every dimension
is enumerated. The policy axis separates the managed case, where the bar has no
Enable button.

Counts the prompt asking to download the model, whether the user continued, and
how the download then ended. All enumerated labels plus two numeric
distributions, so there are no free-form string dimensions.

Two arms needed code to be measurable at all:

  • A user cancel and a network failure both arrive as done+!ok, so they were
    indistinguishable. A flag set in the Cancel callback separates them. Pressing
    Cancel closes the panel, so the outcome has to be decided when the
    notification is removed rather than on a progress update -- otherwise a cancel
    is recorded as abandoned.
  • A download whose panel goes away while it is still running produced no
    terminal event at all; that is now recorded as abandoned.

#outcomeRecorded guarantees exactly one outcome per accepted download.

MLModelHubService.downloadModel hardcoded featureId to "ml-model-hub-service",
so every firefox.ai.runtime.model_download event it produced carried the same
featureId regardless of which feature triggered the download. Pass the task name
through, matching getModelBlob(), so downloads started by native callers are
attributable: "speech-recognition" for the speech recognition model.

It also passed a "component" extra key, which model_download does not declare,
so glean rejected the key and flagged every one of these events invalid_value.
This was the only telemetryData caller in the tree, and featureId now carries
that information.

The new test drives a download through the XPCOM service and asserts every step
of it is attributed to the task name.

The severity field is not set for this bug.
:padenot, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(padenot)
Attachment #9627976 - Attachment description: WIP: Bug 2062329 - Add use counters for the SpeechRecognition API. r?#dom-core-reviewers → Bug 2062329 - Add use counters for the SpeechRecognition API. r?#dom-core-reviewers
Attachment #9627977 - Attachment description: WIP: Bug 2062329 - Record speech recognition usage, outcomes and errors with Glean. r?#media-playback-reviewers → Bug 2062329 - Record speech recognition usage, outcomes and errors with Glean. r?#media-playback-reviewers
Attachment #9627978 - Attachment description: WIP: Bug 2062329 - Measure speech recognition latency in the content process. r?#media-playback-reviewers → Bug 2062329 - Measure speech recognition latency in the content process. r?#media-playback-reviewers
Attachment #9627979 - Attachment description: WIP: Bug 2062329 - Measure inference cost and init failures in the HWInference process. r?#media-playback-reviewers → Bug 2062329 - Measure inference cost and init failures in the HWInference process. r?#media-playback-reviewers

MLModelHubService used the constant "ml-model-hub-service" as the feature ID for every native caller, so the existing firefox_ai_runtime.model_download events could not be selected by feature.

Pass the caller-provided task name as featureId, matching getModelBlob(). The browser test downloads through nsIMLModelHub and checks that every lifecycle event is attributed to speech-recognition.

Remove an attribute that was wrongly added and causes this to fail.

Attachment #9627980 - Attachment is obsolete: true
Attachment #9627981 - Attachment is obsolete: true
Attachment #9627982 - Attachment is obsolete: true
Blocks: 2069803
Pushed by padenot@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/84ede0b820c0 https://hg.mozilla.org/integration/autoland/rev/b0e2d3526199 Add use counters for the SpeechRecognition API. r=dom-core-reviewers,webidl,smaug https://github.com/mozilla-firefox/firefox/commit/39db08efe30c https://hg.mozilla.org/integration/autoland/rev/a2b9f81f8b1b Record speech recognition usage, outcomes and errors with Glean. r=media-playback-reviewers,alwu,TravisLong https://github.com/mozilla-firefox/firefox/commit/189550601ac9 https://hg.mozilla.org/integration/autoland/rev/c5006d2e9e0b Measure speech recognition latency in the content process. r=media-playback-reviewers,alwu https://github.com/mozilla-firefox/firefox/commit/7783c6fb9ede https://hg.mozilla.org/integration/autoland/rev/2312e32d921a Measure inference cost and init failures in the HWInference process. r=media-playback-reviewers,alwu https://github.com/mozilla-firefox/firefox/commit/62a4a5d638f3 https://hg.mozilla.org/integration/autoland/rev/a4f920859c24 Attribute MLModelHubService downloads to the requesting task. r=ai-platform-reviewers,valentinp
Pushed by smolnar@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/232fa2949581 https://hg.mozilla.org/integration/autoland/rev/da8e00aa145a Revert "Bug 2062329 - Attribute MLModelHubService downloads to the requesting task. r=ai-platform-reviewers,valentinp" for causing bc failures @ browser_speech_recognition_telemetry.js
Pushed by padenot@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/57d8c026c74d https://hg.mozilla.org/integration/autoland/rev/9f1fad08fb63 Add use counters for the SpeechRecognition API. r=dom-core-reviewers,webidl,smaug https://github.com/mozilla-firefox/firefox/commit/286cd620fde0 https://hg.mozilla.org/integration/autoland/rev/1d0dd56427a7 Record speech recognition usage, outcomes and errors with Glean. r=media-playback-reviewers,alwu,TravisLong https://github.com/mozilla-firefox/firefox/commit/009671a0e927 https://hg.mozilla.org/integration/autoland/rev/ce98eca74cc1 Measure speech recognition latency in the content process. r=media-playback-reviewers,alwu https://github.com/mozilla-firefox/firefox/commit/12943f71e1fc https://hg.mozilla.org/integration/autoland/rev/592602b76336 Measure inference cost and init failures in the HWInference process. r=media-playback-reviewers,alwu https://github.com/mozilla-firefox/firefox/commit/3e87324fc356 https://hg.mozilla.org/integration/autoland/rev/c1131466b7db Attribute MLModelHubService downloads to the requesting task. r=ai-platform-reviewers,valentinp
Pushed by agoloman@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/3dcdff1226ae https://hg.mozilla.org/integration/autoland/rev/ba47c6d5ec8b Revert "Bug 2062329 - Attribute MLModelHubService downloads to the requesting task. r=ai-platform-reviewers,valentinp" for causing bc failures @browser_speech_recognition_telemetry.js.

Backed out for causing bc failures @browser_speech_recognition_telemetry.js.

Pushed by padenot@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/6a95950cec0b https://hg.mozilla.org/integration/autoland/rev/3d9e2eadbf43 Add use counters for the SpeechRecognition API. r=dom-core-reviewers,webidl,smaug https://github.com/mozilla-firefox/firefox/commit/e50a4acd7619 https://hg.mozilla.org/integration/autoland/rev/83e4f40b5a4c Record speech recognition usage, outcomes and errors with Glean. r=media-playback-reviewers,alwu,TravisLong https://github.com/mozilla-firefox/firefox/commit/bcb8676f4a72 https://hg.mozilla.org/integration/autoland/rev/a6cec24d0774 Measure speech recognition latency in the content process. r=media-playback-reviewers,alwu https://github.com/mozilla-firefox/firefox/commit/653de47c22f3 https://hg.mozilla.org/integration/autoland/rev/b19693064953 Measure inference cost and init failures in the HWInference process. r=media-playback-reviewers,alwu https://github.com/mozilla-firefox/firefox/commit/8e24ac8fea44 https://hg.mozilla.org/integration/autoland/rev/d607e1d2efcf Attribute MLModelHubService downloads to the requesting task. r=ai-platform-reviewers,valentinp
Regressions: 2072051
QA Whiteboard: [qa-triage-done-c159/b158]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: