@@ -144,6 +144,11 @@ public final class WebViewCore {
144144 private int mChromeCanFocusDirection ;
145145 private int mTextSelectionChangeReason = TextSelectionData .REASON_UNKNOWN ;
146146
147+ // Used to determine if we should monitor the WebCore thread for responsiveness.
148+ // If it "hangs", for example a web page enters a while(true) loop, we will
149+ // prompt the user with a dialog allowing them to terminate the process.
150+ private static boolean sShouldMonitorWebCoreThread ;
151+
147152 // The thread name used to identify the WebCore thread and for use in
148153 // debugging other classes that require operation within the WebCore thread.
149154 /* package */ static final String THREAD_NAME = "WebViewCoreThread" ;
@@ -176,9 +181,13 @@ public WebViewCore(Context context, WebViewClassic w, CallbackProxy proxy,
176181 Log .e (LOGTAG , Log .getStackTraceString (e ));
177182 }
178183
179- // Start the singleton watchdog which will monitor the WebCore thread
180- // to verify it's still processing messages.
181- WebCoreThreadWatchdog .start (sWebCoreHandler );
184+ if (sShouldMonitorWebCoreThread ) {
185+ // Start the singleton watchdog which will monitor the WebCore thread
186+ // to verify it's still processing messages. Note that this is the only
187+ // time we need to check the value as all the other public methods on
188+ // the WebCoreThreadWatchdog are no-ops if start() is not called.
189+ WebCoreThreadWatchdog .start (sWebCoreHandler );
190+ }
182191 }
183192 // Make sure the Watchdog is aware of this new WebView.
184193 WebCoreThreadWatchdog .registerWebView (w );
@@ -3061,6 +3070,10 @@ protected DeviceOrientationService getDeviceOrientationService() {
30613070 return mDeviceOrientationService ;
30623071 }
30633072
3073+ static void setShouldMonitorWebCoreThread () {
3074+ sShouldMonitorWebCoreThread = true ;
3075+ }
3076+
30643077 private native void nativeSetIsPaused (int nativeClass , boolean isPaused );
30653078 private native void nativePause (int nativeClass );
30663079 private native void nativeResume (int nativeClass );
0 commit comments