For #10434: Handle cases when proc/$pid/stat is not accessible.
parent
0df27742a3
commit
2090b11c97
|
@ -2253,6 +2253,22 @@ startup.timeline:
|
||||||
- perf-android-fe@mozilla.com
|
- perf-android-fe@mozilla.com
|
||||||
- mcomella@mozilla.com
|
- mcomella@mozilla.com
|
||||||
expires: "2020-07-15"
|
expires: "2020-07-15"
|
||||||
|
framework_start_read_error:
|
||||||
|
send_in_pings:
|
||||||
|
- startup-timeline
|
||||||
|
type: boolean
|
||||||
|
description: |
|
||||||
|
An error when attempting to read stats from /proc pseudo-filesystem -
|
||||||
|
privacy managers can block access to reading these files -
|
||||||
|
the application will catch a file reading exception.
|
||||||
|
bugs:
|
||||||
|
- https://github.com/mozilla-mobile/fenix/issues/10434
|
||||||
|
data_reviews:
|
||||||
|
- https://github.com/mozilla-mobile/fenix/pull/10481
|
||||||
|
notification_emails:
|
||||||
|
- perf-android-fe@mozilla.com
|
||||||
|
- mcomella@mozilla.com
|
||||||
|
expires: "2020-07-15"
|
||||||
clock_ticks_per_second:
|
clock_ticks_per_second:
|
||||||
send_in_pings:
|
send_in_pings:
|
||||||
- startup-timeline
|
- startup-timeline
|
||||||
|
|
|
@ -6,6 +6,7 @@ package org.mozilla.fenix.perf
|
||||||
|
|
||||||
import android.os.Process
|
import android.os.Process
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
|
import java.io.FileNotFoundException
|
||||||
import kotlin.math.roundToLong
|
import kotlin.math.roundToLong
|
||||||
import org.mozilla.fenix.GleanMetrics.StartupTimeline as Telemetry
|
import org.mozilla.fenix.GleanMetrics.StartupTimeline as Telemetry
|
||||||
|
|
||||||
|
@ -53,14 +54,23 @@ internal class StartupFrameworkStartMeasurement(
|
||||||
if (applicationInitNanos < 0) {
|
if (applicationInitNanos < 0) {
|
||||||
telemetry.frameworkStartError.set(true)
|
telemetry.frameworkStartError.set(true)
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
telemetry.frameworkStart.setRawNanos(getFrameworkStartNanos())
|
telemetry.frameworkStart.setRawNanos(getFrameworkStartNanos())
|
||||||
|
} catch (e: FileNotFoundException) {
|
||||||
|
// Privacy managers can add hooks that block access to reading system /proc files.
|
||||||
|
// We want to catch these exception and report an error on accessing the file
|
||||||
|
// rather than an implementation error.
|
||||||
|
telemetry.frameworkStartReadError.set(true)
|
||||||
|
}
|
||||||
|
|
||||||
// frameworkStart is derived from the number of clock ticks per second. To ensure this
|
// frameworkStart is derived from the number of clock ticks per second. To ensure this
|
||||||
// value does not throw off our result, we capture it too.
|
// value does not throw off our result, we capture it too.
|
||||||
telemetry.clockTicksPerSecond.add(stat.clockTicksPerSecond.toInt())
|
telemetry.clockTicksPerSecond.add(stat.clockTicksPerSecond.toInt())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @throws [java.io.FileNotFoundException]
|
||||||
|
*/
|
||||||
private fun getFrameworkStartNanos(): Long {
|
private fun getFrameworkStartNanos(): Long {
|
||||||
// Get our timestamps in ticks: we expect ticks to be less granular than nanoseconds so,
|
// Get our timestamps in ticks: we expect ticks to be less granular than nanoseconds so,
|
||||||
// to ensure our measurement uses the correct number of significant figures, we convert
|
// to ensure our measurement uses the correct number of significant figures, we convert
|
||||||
|
|
|
@ -24,6 +24,9 @@ private const val FIELD_POS_STARTTIME = 21 // starttime naming matches field in
|
||||||
*/
|
*/
|
||||||
open class Stat {
|
open class Stat {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws [java.io.FileNotFoundException]
|
||||||
|
*/
|
||||||
@VisibleForTesting(otherwise = PRIVATE)
|
@VisibleForTesting(otherwise = PRIVATE)
|
||||||
open fun getStatText(pid: Int): String = File("/proc/$pid/stat").readText()
|
open fun getStatText(pid: Int): String = File("/proc/$pid/stat").readText()
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue