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

This commit is contained in:
David Kemp 2013-07-10 19:57:24 -04:00 committed by Andrew Grieve
parent 2fe6d14e56
commit 8202ab83fa

View File

@ -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);