Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# JankData

*** ** * ** ***

```
class JankData
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.view.SurfaceControl.JankData](https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#) |

Jank information to be fed back via `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.OnJankDataListener`.

Apps may register a `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.OnJankDataListener` to get periodic batches of jank classification data from the [composer](https://source.android.com/docs/core/graphics/surfaceflinger-windowmanager) regarding rendered frames. A frame is considered janky if it did not reach the display at the intended time, typically due to missing a rendering deadline. This API provides information that can be used to identify the root cause of the scheduling misses and provides overall frame scheduling statistics.

This API can be used in conjunction with the `https://developer.android.com/reference/kotlin/android/view/FrameMetrics` API by associating jank classification data with `https://developer.android.com/reference/kotlin/android/view/FrameMetrics` data via the frame VSync id.

## Summary

| Constants ||
|---|---|
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#JANK_APPLICATION:kotlin.Int` Bitmask for jank due to deadlines missed by the application. |
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#JANK_COMPOSER:kotlin.Int` Bitmask for jank due to deadlines missed by the composer. |
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#JANK_NONE:kotlin.Int` No jank detected, the frame was on time. |
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#JANK_OTHER:kotlin.Int` Bitmask for jank due to deadlines missed by other system components. |
| static [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#PRESENTATION_TIME_UNKNOWN:kotlin.Long` The presentation time is unknown. |
| static [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#PRESENTATION_TIME_UNSET:kotlin.Long` The presentation time is unset. |

| Public methods ||
|---|---|
| open [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#getActualAppFrameTimeNanos()()` Returns the actual time in nanoseconds taken by the application to render this frame. |
| open [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#getDesiredPresentTimeNanos()()` Returns the time in nanoseconds the frame was intended to be presented, such as the one set by android. |
| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#getJankType()()` Returns the bitmask indicating the types of jank observed. |
| open [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#getPresentTimeNanos()()` Returns the time in nanoseconds the frame was actually presented. |
| open [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#getScheduledAppFrameTimeNanos()()` Returns the duration in nanoseconds the application was scheduled to use to render this frame. |
| open [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#getVsyncId()()` Returns the id of the frame for this jank classification. |
| open [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#toString()()` Returns a string representation of the object. |

## Constants

### JANK_APPLICATION

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
static val JANK_APPLICATION: Int
```

Bitmask for jank due to deadlines missed by the application.

    Value: 2

### JANK_COMPOSER

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
static val JANK_COMPOSER: Int
```

Bitmask for jank due to deadlines missed by the composer.

    Value: 1

### JANK_NONE

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
static val JANK_NONE: Int
```

No jank detected, the frame was on time.

    Value: 0

### JANK_OTHER

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
static val JANK_OTHER: Int
```

Bitmask for jank due to deadlines missed by other system components.

    Value: 4

### PRESENTATION_TIME_UNKNOWN

Added in [API level 37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
static val PRESENTATION_TIME_UNKNOWN: Long
```

The presentation time is unknown.

    Value: -1L

**See Also**

- `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#getPresentTimeNanos()`

### PRESENTATION_TIME_UNSET

Added in [API level 37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
static val PRESENTATION_TIME_UNSET: Long
```

The presentation time is unset.

    Value: 0L

**See Also**

- `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#getDesiredPresentTimeNanos()`
- `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#getPresentTimeNanos()`

## Public methods

### getActualAppFrameTimeNanos

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun getActualAppFrameTimeNanos(): Long
```

Returns the actual time in nanoseconds taken by the application to render this frame.   
Value is a non-negative duration in nanoseconds.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html` | the actual app time in ns. Value is a non-negative duration in nanoseconds. |

### getDesiredPresentTimeNanos

Added in [API level 37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun getDesiredPresentTimeNanos(): Long
```

Returns the time in nanoseconds the frame was intended to be presented, such as the one set by android.view.SurfaceControl.Transaction#setDesiredPresentTime. Will be `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#PRESENTATION_TIME_UNSET:kotlin.Long` if a desired present time was not set for this frame.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html` | the desired present time in ns |

### getJankType

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun getJankType(): Int
```

Returns the bitmask indicating the types of jank observed.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | the jank type bitmask. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#JANK_NONE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#JANK_COMPOSER:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#JANK_APPLICATION:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#JANK_OTHER:kotlin.Int` |

### getPresentTimeNanos

Added in [API level 37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun getPresentTimeNanos(): Long
```

Returns the time in nanoseconds the frame was actually presented. If the frame was not presented (for example, if it was replaced by a new frame before being sent to the display), this value will be `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#PRESENTATION_TIME_UNSET:kotlin.Long`. If the presentation status of the frame is unknown (for example, if the device does not support display present fences), this value will be `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.JankData#PRESENTATION_TIME_UNKNOWN:kotlin.Long`.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html` | the present time in ns |

### getScheduledAppFrameTimeNanos

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun getScheduledAppFrameTimeNanos(): Long
```

Returns the duration in nanoseconds the application was scheduled to use to render this frame.

Note that this may be higher than the frame interval to allow for CPU/GPU parallelization of work.   
Value is a non-negative duration in nanoseconds.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html` | scheduled app time in ns. Value is a non-negative duration in nanoseconds. |

### getVsyncId

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun getVsyncId(): Long
```

Returns the id of the frame for this jank classification.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html` | the frame id |

**See Also**

- `https://developer.android.com/reference/kotlin/android/view/FrameMetrics#FRAME_TIMELINE_VSYNC_ID:kotlin.Int`
- `https://developer.android.com/reference/kotlin/android/view/Choreographer.FrameTimeline#getVsyncId()`
- `https://developer.android.com/reference/kotlin/android/view/SurfaceControl.Transaction#setFrameTimeline(kotlin.Long)`

### toString

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun toString(): String
```

Returns a string representation of the object.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | a string representation of the object. |