Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

WebViewRenderProcessClient

abstract class WebViewRenderProcessClient
kotlin.Any
   ↳ androidx.webkit.WebViewRenderProcessClient

Used to receive callbacks on WebView renderer events. WebViewRenderProcessClient instances may be set or retrieved via WebViewCompat#setWebViewRenderProcessClient(WebView,Executor,WebViewRenderProcessClient) and WebViewCompat#getWebViewRenderProcessClient(WebView). Instances may be attached to multiple WebViews, and thus a single renderer event may cause a callback to be called multiple times with different WebView parameters.

Summary

Public constructors

Used to receive callbacks on WebView renderer events.

Public methods

abstract Unit
onRenderProcessResponsive(@NonNull view: WebView, @Nullable renderer: WebViewRenderProcess?)

Called once when an unresponsive renderer currently associated with view becomes responsive.

abstract Unit
onRenderProcessUnresponsive(@NonNull view: WebView, @Nullable renderer: WebViewRenderProcess?)

Called when the renderer currently associated with view becomes unresponsive as a result of a long running blocking task such as the execution of JavaScript.

Public constructors

<init>

WebViewRenderProcessClient()

Used to receive callbacks on WebView renderer events. WebViewRenderProcessClient instances may be set or retrieved via WebViewCompat#setWebViewRenderProcessClient(WebView,Executor,WebViewRenderProcessClient) and WebViewCompat#getWebViewRenderProcessClient(WebView). Instances may be attached to multiple WebViews, and thus a single renderer event may cause a callback to be called multiple times with different WebView parameters.

Public methods

onRenderProcessResponsive

abstract fun onRenderProcessResponsive(@NonNull view: WebView, @Nullable renderer: WebViewRenderProcess?): Unit

Called once when an unresponsive renderer currently associated with view becomes responsive.

After a WebView renderer becomes unresponsive, which is notified to the application by WebViewRenderProcessClient#onRenderProcessUnresponsive, it is possible for the blocking renderer task to complete, returning the renderer to a responsive state. In that case, this method is called once to indicate responsiveness.

No action is taken by WebView as a result of this method call.

Parameters
view WebView: The android.webkit.WebView for which responsiveness was detected.
renderer WebView: The WebViewRenderProcess that has become responsive, or null if WebView is running in single process mode.

onRenderProcessUnresponsive

abstract fun onRenderProcessUnresponsive(@NonNull view: WebView, @Nullable renderer: WebViewRenderProcess?): Unit

Called when the renderer currently associated with view becomes unresponsive as a result of a long running blocking task such as the execution of JavaScript.

If a WebView fails to process an input event, or successfully navigate to a new URL within a reasonable time frame, the renderer is considered to be unresponsive, and this callback will be called.

This callback will continue to be called at regular intervals as long as the renderer remains unresponsive. If the renderer becomes responsive again, will be called once, and this method will not subsequently be called unless another period of unresponsiveness is detected.

The minimum interval between successive calls to onRenderProcessUnresponsive is 5 seconds.

No action is taken by WebView as a result of this method call. Applications may choose to terminate the associated renderer via the object that is passed to this callback, if in multiprocess mode, however this must be accompanied by correctly handling android.webkit.WebViewClient#onRenderProcessGone for this WebView, and all other WebViews associated with the same renderer. Failure to do so will result in application termination.

Parameters
view WebView: The android.webkit.WebView for which unresponsiveness was detected.
renderer WebView: The WebViewRenderProcess that has become unresponsive, or null if WebView is running in single process mode.