Apache Cordova
  1. Apache Cordova
  2. CB-5487

Add preference to enable Remote Debugging for Android 4.4+ (KitKat) Chrome based WebView

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.2.0
    • Fix Version/s: None
    • Component/s: Android
    • Labels:
      None

      Description

      You have to explicitly enable remote debugging for kitkat chrome-based webview:
      https://developers.google.com/chrome-developer-tools/docs/remote-debugging#debugging-webviews

      As far as I am aware there are no performance implication to leaving this flag on at all time (i.e. when releasing your app) – however, the feature was implemented as an opt-in so that users cannot inspect your webview based application without your (the developer) explicit consent. I think cordova should respect that decision and leave the preference off by default.

      CB-3494 is related.

        Activity

        Michal Mocny created issue -
        Hide
        Andrew Grieve added a comment -

        Instead of a <preference>, how about just linking it with the "debuggable" AndroidManifest parameter. This is shown in the example code from the linked page.

        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            if ( 0 != ( getApplcationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE ) ) {
                WebView.setWebContentsDebuggingEnabled(true);
            }
        }
        
        Show
        Andrew Grieve added a comment - Instead of a <preference>, how about just linking it with the "debuggable" AndroidManifest parameter. This is shown in the example code from the linked page. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if ( 0 != ( getApplcationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE ) ) { WebView.setWebContentsDebuggingEnabled( true ); } }
        Hide
        Michal Mocny added a comment -

        Also, a community member has already written a nice plugin for this, with a great guide to boot:
        http://plugins.cordova.io/#/com.jamiestarke.webviewdebug

        Show
        Michal Mocny added a comment - Also, a community member has already written a nice plugin for this, with a great guide to boot: http://plugins.cordova.io/#/com.jamiestarke.webviewdebug
        Hide
        Dirk-Jan Hoek added a comment -

        Andrew Grieve, linking the setting to the 'debuggable' parameter means you can't leave it on when releasing the app (Play Store won't allow 'debuggable'=true). I'd like to be sure of what it implicated in the description: "there is no performance implication to leaving this flag on at all time". Is there anyone who can confirm/refute this?

        Jamie Starke's plugin works great by the way

        Show
        Dirk-Jan Hoek added a comment - Andrew Grieve , linking the setting to the 'debuggable' parameter means you can't leave it on when releasing the app (Play Store won't allow 'debuggable'=true). I'd like to be sure of what it implicated in the description: "there is no performance implication to leaving this flag on at all time". Is there anyone who can confirm/refute this? Jamie Starke's plugin works great by the way
        Hide
        Michal Mocny added a comment -

        I now think that we should ship this the way andrew suggests, so that you get debugging "out of the box" for local dev and disabled by default when you ship your app with release build.

        If you want to leave debugging on with your released app, just install the plugin or override the platform code.

        Show
        Michal Mocny added a comment - I now think that we should ship this the way andrew suggests, so that you get debugging "out of the box" for local dev and disabled by default when you ship your app with release build. If you want to leave debugging on with your released app, just install the plugin or override the platform code.
        Joe Bowser made changes -
        Field Original Value New Value
        Assignee Joe Bowser [ bowserj ]
        Hide
        ASF subversion and git services added a comment -

        Commit ea1f041e1167de9add5346a7d4fe6afec095d910 in branch refs/heads/master from Joe Bowser
        [ https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;h=ea1f041 ]

        CB-5487: Remote Debugging is on when your Android app is debuggable.

        Show
        ASF subversion and git services added a comment - Commit ea1f041e1167de9add5346a7d4fe6afec095d910 in branch refs/heads/master from Joe Bowser [ https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;h=ea1f041 ] CB-5487 : Remote Debugging is on when your Android app is debuggable.
        Hide
        Joe Bowser added a comment -

        Shipping it the way Andrew Grieve suggested.

        Show
        Joe Bowser added a comment - Shipping it the way Andrew Grieve suggested.
        Joe Bowser made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Joe Bowser
            Reporter:
            Michal Mocny
          • Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development