File tree Expand file tree Collapse file tree 6 files changed +53
-0
lines changed
components/textrecognition
toolkit/components/telemetry Expand file tree Collapse file tree 6 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -2324,6 +2324,10 @@ class nsContextMenu {
2324
2324
getImageText ( ) {
2325
2325
let dialogBox = gBrowser . getTabDialogBox ( this . browser ) ;
2326
2326
const imageTextResult = this . actor . getImageText ( this . targetIdentifier ) ;
2327
+ TelemetryStopwatch . start (
2328
+ "TEXT_RECOGNITION_API_PERFORMANCE" ,
2329
+ imageTextResult
2330
+ ) ;
2327
2331
const { dialog } = dialogBox . open (
2328
2332
"chrome://browser/content/textrecognition/textrecognition.html" ,
2329
2333
{
Original file line number Diff line number Diff line change @@ -19,6 +19,13 @@ add_task(async function() {
19
19
! getTelemetryScalars ( ) [ "browser.ui.interaction.content_context" ] ,
20
20
"No telemetry has been recorded yet."
21
21
) ;
22
+ is (
23
+ Services . telemetry
24
+ . getHistogramById ( "TEXT_RECOGNITION_API_PERFORMANCE" )
25
+ . snapshot ( ) . sum ,
26
+ 0 ,
27
+ "No histogram timing was recorded."
28
+ ) ;
22
29
23
30
info ( "Right click image to show context menu." ) ;
24
31
let popupShownPromise = BrowserTestUtils . waitForEvent (
@@ -79,6 +86,13 @@ add_task(async function() {
79
86
is ( p2 . innerText , "Firefox\n" , "The second piece of text matches." ) ;
80
87
}
81
88
89
+ ok (
90
+ Services . telemetry
91
+ . getHistogramById ( "TEXT_RECOGNITION_API_PERFORMANCE" )
92
+ . snapshot ( ) . sum > 0 ,
93
+ "Text recognition API performance was recorded."
94
+ ) ;
95
+
82
96
info ( "Close the dialog box." ) ;
83
97
const close = contentDocument . querySelector ( "#text-recognition-close" ) ;
84
98
close . click ( ) ;
Original file line number Diff line number Diff line change @@ -67,6 +67,13 @@ add_task(async function() {
67
67
const text = contentDocument . querySelector ( ".textRecognitionText" ) ;
68
68
is ( text . children . length , 0 , "No results are listed." ) ;
69
69
70
+ ok (
71
+ Services . telemetry
72
+ . getHistogramById ( "TEXT_RECOGNITION_API_PERFORMANCE" )
73
+ . snapshot ( ) . sum > 0 ,
74
+ "Histogram timing was recorded even though there were no results."
75
+ ) ;
76
+
70
77
info ( "Close the dialog box." ) ;
71
78
const close = contentDocument . querySelector ( "#text-recognition-close" ) ;
72
79
close . click ( ) ;
Original file line number Diff line number Diff line change @@ -45,4 +45,7 @@ function getTelemetryScalars() {
45
45
46
46
function clearTelemetry ( ) {
47
47
Services . telemetry . clearScalars ( ) ;
48
+ Services . telemetry
49
+ . getHistogramById ( "TEXT_RECOGNITION_API_PERFORMANCE" )
50
+ . clear ( ) ;
48
51
}
Original file line number Diff line number Diff line change @@ -46,13 +46,22 @@ class TextRecognitionModal {
46
46
if ( results . length === 0 ) {
47
47
// Update the UI to indicate that there were no results.
48
48
this . showHeaderByID ( "text-recognition-header-no-results" ) ;
49
+ // It's still worth recording telemetry times, as the API was still invoked.
50
+ TelemetryStopwatch . finish (
51
+ "TEXT_RECOGNITION_API_PERFORMANCE" ,
52
+ resultsPromise
53
+ ) ;
49
54
return ;
50
55
}
51
56
52
57
// There were results, cluster them into a nice presentation, and present
53
58
// the results to the UI.
54
59
this . runClusteringAndUpdateUI ( results , direction ) ;
55
60
this . showHeaderByID ( "text-recognition-header-results" ) ;
61
+ TelemetryStopwatch . finish (
62
+ "TEXT_RECOGNITION_API_PERFORMANCE" ,
63
+ resultsPromise
64
+ ) ;
56
65
} ,
57
66
error => {
58
67
// There was an error in the text recognition call. Treat this as the same
@@ -67,6 +76,10 @@ class TextRecognitionModal {
67
76
"browser.ui.interaction.textrecognition_error" ,
68
77
1
69
78
) ;
79
+ TelemetryStopwatch . cancel (
80
+ "TEXT_RECOGNITION_API_PERFORMANCE" ,
81
+ resultsPromise
82
+ ) ;
70
83
}
71
84
) ;
72
85
}
Original file line number Diff line number Diff line change 17077
17077
"alert_emails": ["necko@mozilla.com", "mwoodrow@mozilla.com"],
17078
17078
"description": "Time spent waiting on the main-thread to be available to run AsyncOpen, for image preload requests"
17079
17079
},
17080
+ "TEXT_RECOGNITION_API_PERFORMANCE": {
17081
+ "record_in_processes": ["main"],
17082
+ "products": ["firefox"],
17083
+ "releaseChannelCollection": "opt-out",
17084
+ "alert_emails": ["gtatum@mozilla.com", "nordzilla@mozilla.com"],
17085
+ "expires_in_version": "109",
17086
+ "kind": "exponential",
17087
+ "high": 120000,
17088
+ "n_buckets": 20,
17089
+ "bug_numbers": [1783261],
17090
+ "description": "The milliseconds of time the text recognition results took to display, including the UI time and OS response time."
17091
+ },
17080
17092
"DOWNLOADS_USER_ACTION_ON_BLOCKED_DOWNLOAD": {
17081
17093
"record_in_processes": ["main"],
17082
17094
"products": ["firefox"],
You can’t perform that action at this time.
0 commit comments