From 2462c8f87d19906bdc994032402b1fdd9acba19e Mon Sep 17 00:00:00 2001 From: odino Date: Tue, 5 Jan 2016 11:39:53 -0800 Subject: [PATCH] Enables webview debugging Summary: 2 things that I want to clarify / ask for feedback: * do we really need to make sure we're running on the UI thread? I guess `onPageStarted` maybe already runs there? Couldnt find anything [here](http://developer.android.com/reference/android/webkit/WebView.html) though * everytime a page starts we re-enable debugging -- it's a bit useless but I also don't think it's a huge problem, as debugging should only be enabled in dev Relates to issue #4857, where we switched debugging off as, in some circumstances, it would crash the application as debugging was invoked outside the UI thread. Closes https://github.com/facebook/react-native/pull/5071 Reviewed By: svcscm Differential Revision: D2803649 Pulled By: astreet fb-gh-sync-id: 523d3b442b196d6c54b14ba0c2b29601095c3363 --- .../react/views/webview/ReactWebViewManager.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java index 22b6c01d9..5400210d6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java @@ -74,13 +74,6 @@ public class ReactWebViewManager extends SimpleViewManager { private WebViewConfig mWebViewConfig; - static { - if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - // TODO(T9455950): re-enable debugging - // WebView.setWebContentsDebuggingEnabled(true); - } - } - private static class ReactWebViewClient extends WebViewClient { private boolean mLastLoadFailed = false; @@ -248,6 +241,11 @@ public class ReactWebViewManager extends SimpleViewManager { ReactWebView webView = new ReactWebView(reactContext); reactContext.addLifecycleEventListener(webView); mWebViewConfig.configWebView(webView); + + if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + WebView.setWebContentsDebuggingEnabled(true); + } + return webView; }