Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/webkit/TracingController#pubctors) \| [Methods](https://developer.android.com/reference/android/webkit/TracingController#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/webkit/TracingController#inhmethods)

# TracingController

*** ** * ** ***


`
public


abstract
class
TracingController
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.webkit.TracingController |

<br />

*** ** * ** ***

Manages tracing of WebViews. In particular provides functionality for the app
to enable/disable tracing of parts of code and to collect tracing data.
This is useful for profiling performance issues, debugging and memory usage
analysis in production and real life scenarios.


The resulting trace data is sent back as a byte sequence in json format. This
file can be loaded in "chrome://tracing" for further analysis.


Example usage:

```
TracingController tracingController = TracingController.getInstance();
tracingController.start(new TracingConfig.Builder()
                 .addCategories(TracingConfig.CATEGORIES_WEB_DEVELOPER).build());
...
tracingController.stop(new FileOutputStream("trace.json"),
                       Executors.newSingleThreadExecutor());
```

<br />

<br />

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/webkit/TracingController#TracingController()() ` *This constructor is deprecated. This class should not be constructed by applications, use `https://developer.android.com/reference/android/webkit/TracingController#getInstance()` instead to fetch the singleton instance.* |

| ### Public methods ||
|---|---|
| ` static https://developer.android.com/reference/android/webkit/TracingController` | ` https://developer.android.com/reference/android/webkit/TracingController#getInstance()() ` Returns the default TracingController instance. |
| ` abstract boolean` | ` https://developer.android.com/reference/android/webkit/TracingController#isTracing()() ` Returns whether the WebView framework is tracing. |
| ` abstract void` | ` https://developer.android.com/reference/android/webkit/TracingController#start(android.webkit.TracingConfig)(https://developer.android.com/reference/android/webkit/TracingConfig tracingConfig) ` Starts tracing all webviews. |
| ` abstract boolean` | ` https://developer.android.com/reference/android/webkit/TracingController#stop(java.io.OutputStream,%20java.util.concurrent.Executor)(https://developer.android.com/reference/java/io/OutputStream outputStream, https://developer.android.com/reference/java/util/concurrent/Executor executor) ` Stops tracing and flushes tracing data to the specified outputStream. |

### Inherited methods

From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

Indicates whether some other object is "equal to" this one.


`


void` `
https://developer.android.com/reference/java/lang/Object#finalize()()
`

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.


`


final

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

Wakes up a single thread that is waiting on this object's
monitor.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

Wakes up all threads that are waiting on this object's monitor.


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait()()
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*.


## Public constructors

### TracingController

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

```
public TracingController ()
```


**This constructor is deprecated.**   

This class should not be constructed by applications, use `https://developer.android.com/reference/android/webkit/TracingController#getInstance()`
instead to fetch the singleton instance.

<br />

<br />

## Public methods

### getInstance

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

```
public static TracingController getInstance ()
```

Returns the default TracingController instance. At present there is
only one TracingController instance for all WebView instances,
however this restriction may be relaxed in a future Android release.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/webkit/TracingController` | The default TracingController instance. This value cannot be `null`. <br /> |

### isTracing

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

```
public abstract boolean isTracing ()
```

Returns whether the WebView framework is tracing.

<br />

| Returns ||
|---|---|
| `boolean` | True if tracing is enabled. <br /> |

### start

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

```
public abstract void start (TracingConfig tracingConfig)
```

Starts tracing all webviews. Depending on the trace mode in traceConfig
specifies how the trace events are recorded.

For tracing modes `https://developer.android.com/reference/android/webkit/TracingConfig#RECORD_UNTIL_FULL` and
`https://developer.android.com/reference/android/webkit/TracingConfig#RECORD_CONTINUOUSLY` the events are recorded
using an internal buffer and flushed to the outputStream when
`https://developer.android.com/reference/android/webkit/TracingController#stop(java.io.OutputStream,%20java.util.concurrent.Executor)` is called.

<br />

| Parameters ||
|---|---|
| `tracingConfig` | `TracingConfig`: Configuration options to use for tracing. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If the configuration is invalid (e.g. invalid category pattern or invalid tracing mode). |
| `https://developer.android.com/reference/java/lang/IllegalStateException` | If the system is already tracing. |

### stop

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

```
public abstract boolean stop (OutputStream outputStream, 
                Executor executor)
```

Stops tracing and flushes tracing data to the specified outputStream.

The data is sent to the specified output stream in json format typically
in chunks by invoking `https://developer.android.com/reference/java/io/OutputStream#write(byte[])`. On completion
the `https://developer.android.com/reference/java/io/OutputStream#close()` method is called.

<br />

| Parameters ||
|---|---|
| `outputStream` | `OutputStream`: The output stream the tracing data will be sent to. If null the tracing data will be discarded. <br /> |
| `executor` | `Executor`: The `https://developer.android.com/reference/java/util/concurrent/Executor` on which the outputStream `https://developer.android.com/reference/java/io/OutputStream#write(byte[])` and `https://developer.android.com/reference/java/io/OutputStream#close()` methods will be invoked. This value cannot be `null`. Callback and listener events are dispatched through this `https://developer.android.com/reference/java/util/concurrent/Executor`, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use `https://developer.android.com/reference/android/content/Context#getMainExecutor()`. Otherwise, provide an `https://developer.android.com/reference/java/util/concurrent/Executor` that dispatches to an appropriate thread. <br /> |

| Returns ||
|---|---|
| `boolean` | False if the WebView framework was not tracing at the time of the call, true otherwise. <br /> |