public abstract class TracingController
extends Object



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());
 

Summary

Public constructors

TracingController()

This constructor is deprecated. This class should not be constructed by applications, use getInstance() instead to fetch the singleton instance.

Public methods

static TracingController getInstance()

Returns the default TracingController instance.

abstract boolean isTracing()

Returns whether the WebView framework is tracing.

abstract void start(TracingConfig tracingConfig)

Starts tracing all webviews.

abstract boolean stop(OutputStream outputStream, Executor executor)

Stops tracing and flushes tracing data to the specified outputStream.

Inherited methods

From class java.lang.Object

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

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

void finalize()

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

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

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

final void notifyAll()

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

String toString()

Returns a string representation of the object.

final void wait(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 wait(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 wait()

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

Public constructors

TracingController

public TracingController ()

This constructor is deprecated.
This class should not be constructed by applications, use getInstance() instead to fetch the singleton instance.

Public methods

getInstance

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.

Returns
TracingController The default TracingController instance.
This value cannot be null.

isTracing

public abstract boolean isTracing ()

Returns whether the WebView framework is tracing.

Returns
boolean True if tracing is enabled.

stop

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 OutputStream.write(byte[]). On completion the OutputStream.close() method is called.

Parameters
outputStream OutputStream: The output stream the tracing data will be sent to. If null the tracing data will be discarded.
executor Executor: The Executor on which the outputStream OutputStream.write(byte[]) and OutputStream.close() methods will be invoked.
This value cannot be null.
Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.
Returns
boolean False if the WebView framework was not tracing at the time of the call, true otherwise.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2026-02-26 UTC.