You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/07/17 03:19:42 UTC

[2/2] android commit: [CB-4133] Add main thread warning for plugins that run too long

[CB-4133] Add main thread warning for plugins that run too long


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/48849281
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/48849281
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/48849281

Branch: refs/heads/3.0.x
Commit: 488492813dc55a535d82c13984104b0c22dabc3d
Parents: 0b6e90b
Author: David Kemp <dr...@chromium.org>
Authored: Wed Jul 10 19:57:24 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Jul 16 21:19:36 2013 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/PluginManager.java | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/48849281/framework/src/org/apache/cordova/PluginManager.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/PluginManager.java b/framework/src/org/apache/cordova/PluginManager.java
index 3d0169a..277e7ac 100755
--- a/framework/src/org/apache/cordova/PluginManager.java
+++ b/framework/src/org/apache/cordova/PluginManager.java
@@ -225,7 +225,12 @@ public class PluginManager {
         }
         try {
             CallbackContext callbackContext = new CallbackContext(callbackId, app);
+            long pluginStartTime = System.currentTimeMillis();
             boolean wasValidAction = plugin.execute(action, rawArgs, callbackContext);
+            long duration = System.currentTimeMillis() - pluginStartTime;
+            if (duration > 16) {
+                Log.w(TAG, "THREAD WARNING: exec() call to " + service + "." + action + " blocked the main thread for " + duration + "ms. Plugin should use CordovaInterface.getThreadPool().");
+            }
             if (!wasValidAction) {
                 PluginResult cr = new PluginResult(PluginResult.Status.INVALID_ACTION);
                 app.sendPluginResult(cr, callbackId);